-
-
Notifications
You must be signed in to change notification settings - Fork 17
feat: Add TLS certificate util crate #736
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
57 commits
Select commit
Hold shift + click to select a range
c6d8d35
Initial commit
Techassi 4a00b7f
Merge branch 'main' into feat/tls-cert-generation
Techassi ced1d2b
Use certs crate
Techassi 4f65367
Add first rough plans
Techassi 8b985db
Merge changelog changes
Techassi eead4ac
Add ED25519 signing key support
Techassi c7e3236
Add RSA signing key
Techassi 1384083
Finish initial CA creation, slowly start to refine code
Techassi 4efd3c1
Start to add K8s traits
Techassi 797dee7
Add SecretReference
Techassi 3ab1b28
Add more errors, add more helper traits
Techassi e5470b1
Make certificate authority generic over the signing key
Techassi 0d80f4e
Start to add leaf certificate generation
Techassi fc2e73e
Add more interop code, clean up trait impls and errors
Techassi df672bc
Slightly simplify wrapper types and trait impls
Techassi 4271715
Start to work through initial round of TODOs
Techassi e03ad1c
Remove unwraps, add error handling
Techassi ba82b36
Move k8s code into own file
Techassi 4810ed7
Merge branch 'main' into feat/tls-cert-generation
Techassi 2970688
Remove initial manager code
Techassi cba32cd
Add a few more (doc) comments
Techassi 13f5816
Add more doc comments for constants
Techassi 2ad66c5
Apply suggestions
Techassi 6c8db86
Add fixups for code suggestions
Techassi 9c21a1c
Change default RSA bit size
Techassi 0d5c001
Add RSA bit size guard
Techassi c27f43c
Add doc comments, add leaf cert helper functions
Techassi 2b80739
Add doc comments for CertificatePairExt trait
Techassi 5e67e50
Rename rustls feature to webhook
Techassi c43f2e2
Fix doc comment reference
Techassi 0a2a8e0
Add secret type guard
Techassi 6b89c3a
Remove unused trait function
Techassi 7b45b50
Initial commit
Techassi 7a6fc12
Add const for Kubernetes TLS secret type
Techassi 573814d
Turn the RSA bit size into an enum
Techassi 12100ee
Use enum discriminants
Techassi 7461374
Remove hashset of serial numbers
Techassi 597ec94
Remove customizable line endings
Techassi 7c435bd
Adjust root CA subject
Techassi ec52972
Remove TLS mount related code
Techassi d0941e6
Add error handling for cert generation
Techassi 1b4a78e
Adjust conditional imports
Techassi ac27db5
Merge branch 'main' into feat/tls-cert-generation
Techassi a0182d7
Apply suggestion
Techassi a5a00ef
Revert "Apply suggestion"
Techassi a372b7a
Add from_secret and from_secret_ref functions to struct directly
Techassi 3c6bf74
Remove unneeded newlines
Techassi 17a6aef
Add doc comment to SecretReference
Techassi 7a96031
Rename to KeySize, add bits method
Techassi 694e337
Slightly adjust doc comment for SecretReference
Techassi c96fa62
Rename Keypair trait to CertificateKeypair
Techassi c4a044e
Merge branch 'main' into feat/tls-cert-generation
Techassi 862d2bb
Remove KeySize enum
Techassi 9dc89ae
Move key size into constant
Techassi dd51591
Use with_context to avoid unnecessary allocation when Ok
Techassi b90dc1f
Adjust error message to reflect underlying error
Techassi 4eb2743
Add doc comment to clarify paramter usage
Techassi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,3 +6,7 @@ Cargo.lock | |
| .idea/ | ||
| *.iws | ||
| *.iml | ||
|
|
||
| # TLS certificates for testing | ||
| *.crt | ||
| *.key | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| use std::fmt::Display; | ||
|
|
||
| use k8s_openapi::api::core::v1::Secret; | ||
| use kube::runtime::reflector::ObjectRef; | ||
| use schemars::JsonSchema; | ||
| use serde::{Deserialize, Serialize}; | ||
|
|
||
| /// [`SecretReference`] represents a Kubernetes [`Secret`] reference. | ||
| /// | ||
| /// In order to use this struct, the following two requirements must be met: | ||
| /// | ||
| /// - Must only be used in cluster-scoped objects | ||
| /// - Namespaced objects must not be able to define cross-namespace secret | ||
| /// references | ||
| /// | ||
| /// This struct is a redefinition of the one provided by k8s-openapi to make | ||
| /// name and namespace mandatory. | ||
| #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] | ||
| #[serde(rename_all = "camelCase")] | ||
| pub struct SecretReference { | ||
| /// Namespace of the Secret being referred to. | ||
| pub namespace: String, | ||
|
|
||
| /// Name of the Secret being referred to. | ||
| pub name: String, | ||
| } | ||
|
|
||
| // Use ObjectRef for logging/errors | ||
| impl Display for SecretReference { | ||
| fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
| ObjectRef::<Secret>::from(self).fmt(f) | ||
| } | ||
| } | ||
|
|
||
| impl From<SecretReference> for ObjectRef<Secret> { | ||
| fn from(val: SecretReference) -> Self { | ||
| ObjectRef::<Secret>::from(&val) | ||
| } | ||
| } | ||
|
|
||
| impl From<&SecretReference> for ObjectRef<Secret> { | ||
| fn from(val: &SecretReference) -> Self { | ||
| ObjectRef::<Secret>::new(&val.name).within(&val.namespace) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| [package] | ||
| name = "stackable-certs" | ||
| version.workspace = true | ||
| authors.workspace = true | ||
| license.workspace = true | ||
| edition.workspace = true | ||
| repository.workspace = true | ||
|
|
||
| [features] | ||
| default = [] | ||
| rustls = ["dep:tokio-rustls", "dep:rustls-pemfile"] | ||
|
|
||
| [dependencies] | ||
| stackable-operator = { path = ".." } | ||
|
|
||
| const-oid = "0.9.6" | ||
| ecdsa = { version = "0.16.9", features = ["digest", "pem"] } | ||
| p256 = { version = "0.13.2", features = ["ecdsa"] } | ||
| k8s-openapi = { version = "0.21.0", default-features = false, features = [ | ||
| "v1_28", | ||
| ] } | ||
| kube = { version = "0.88.1", default-features = false, features = [ | ||
| "client", | ||
| "rustls-tls", | ||
| ] } | ||
| tracing = "0.1.40" | ||
| tokio = { version = "1.29.1", features = ["fs"] } | ||
| tokio-rustls = { version = "0.25.0", optional = true } | ||
| rand = "0.8.5" | ||
| rand_core = "0.6.4" | ||
| rsa = { version = "0.9.6", features = ["sha2"] } | ||
| rustls-pemfile = { version = "2.0.0", optional = true } | ||
| sha2 = { version = "0.10.8", features = ["oid"] } | ||
| signature = "2.2.0" | ||
| snafu = "0.8.0" | ||
| x509-cert = { version = "0.2.5", features = ["builder"] } | ||
| zeroize = "1.7.0" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| /// The default CA validity time span of one hour (3600 seconds). | ||
| pub const DEFAULT_CA_VALIDITY_SECONDS: u64 = 3600; | ||
|
|
||
| /// The root CA subject name containing only the common name. | ||
| pub const ROOT_CA_SUBJECT: &str = "CN=Stackable Data Platform Internal CA"; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.