Skip to content

Commit d3e7643

Browse files
committed
misc cleanup
1 parent 3fd41d7 commit d3e7643

File tree

7 files changed

+20
-16
lines changed

7 files changed

+20
-16
lines changed

crates/stackable-certs/src/ca/ca_builder.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,11 @@ where
157157
)
158158
.context(CreateCertificateBuilderSnafu)?;
159159

160-
// Add extension constructed above
161160
builder
162161
.add_extension(&aki)
163162
.context(AddCertificateExtensionSnafu)?;
164163

165-
debug!("create and sign CA certificate");
164+
debug!("creating and signing CA certificate");
166165
let certificate = builder.build().context(BuildCertificateSnafu)?;
167166

168167
Ok(CertificateAuthority {

crates/stackable-certs/src/ca/consts.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ pub const DEFAULT_CERTIFICATE_VALIDITY: Duration = Duration::from_hours_unchecke
1010
/// The root CA subject name containing only the common name.
1111
pub const SDP_ROOT_CA_SUBJECT: &str = "CN=Stackable Data Platform Internal CA";
1212

13+
/// As we are mostly on Unix systems, we are using `\ņ`.
1314
pub const PEM_LINE_ENDING: LineEnding = LineEnding::LF;

crates/stackable-certs/src/ca/k8s.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ use crate::{CertificatePair, keys::CertificateKeypair};
1010

1111
pub const TLS_SECRET_TYPE: &str = "kubernetes.io/tls";
1212

13-
/// Defines all error variants which can occur when loading a CA from a
14-
/// Kubernetes [`Secret`].
13+
/// Defines all error variants which can occur when loading a CA from a Kubernetes [`Secret`].
1514
#[derive(Debug, Snafu)]
1615
pub enum SecretError<E>
1716
where
@@ -50,7 +49,7 @@ where
5049

5150
/// Create a [`CertificateAuthority`] from a Kubernetes [`Secret`].
5251
///
53-
/// Both the `certificate_key` and `private_key_key` parameters describe
52+
/// Both the `certificate_key` and `private_key_key` parameters describe
5453
/// the _key_ used to lookup the certificate and private key value in the
5554
/// Kubernetes [`Secret`]. Common keys are `ca.crt` and `ca.key`.
5655
#[instrument(skip(secret))]
@@ -71,7 +70,7 @@ where
7170
secret: ObjectRef::from_obj(&secret),
7271
})?;
7372

74-
debug!("retrieving certificate data from secret via key {certificate_key:?}");
73+
debug!("retrieving certificate data from secret via key \"{certificate_key}\"");
7574
let certificate_data = data
7675
.get(certificate_key)
7776
.with_context(|| NoCertificateDataSnafu {
@@ -84,7 +83,7 @@ where
8483
})?
8584
.remove(0);
8685

87-
debug!("retrieving private key data from secret via key {private_key_key:?}");
86+
debug!("retrieving private key data from secret via key \"{private_key_key}\"");
8887
let private_key_data = data
8988
.get(private_key_key)
9089
.with_context(|| NoPrivateKeyDataSnafu {
@@ -107,8 +106,8 @@ where
107106
#[instrument(skip(secret_ref, client))]
108107
pub async fn ca_from_k8s_secret_ref<SK>(
109108
secret_ref: &SecretReference,
110-
key_certificate: &str,
111-
key_private_key: &str,
109+
certificate_key: &str,
110+
private_key_key: &str,
112111
client: &Client,
113112
) -> Result<CertificateAuthority<SK>, SecretError<SK::Error>>
114113
where
@@ -123,5 +122,5 @@ where
123122
secret_ref: secret_ref.to_owned(),
124123
})?;
125124

126-
ca_from_k8s_secret(secret, key_certificate, key_private_key)
125+
ca_from_k8s_secret(secret, certificate_key, private_key_key)
127126
}

crates/stackable-certs/src/cert_builder.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use crate::{
2222
keys::CertificateKeypair,
2323
};
2424

25-
/// Defines all error variants which can occur when creating a CertificateRequest
25+
/// Defines all error variants which can occur when creating a certificate
2626
#[derive(Debug, Snafu)]
2727
pub enum CreateCertificateError<E>
2828
where
@@ -37,8 +37,6 @@ where
3737
subject: String,
3838
},
3939

40-
// #[snafu(display("failed to create key pair"))]
41-
// CreateKeyPair { source: Box<dyn std::error::Error> },
4240
#[snafu(display("failed to create key pair"))]
4341
CreateKeyPair { source: E },
4442

@@ -275,9 +273,9 @@ mod tests {
275273
.find(|ext| ext.extn_id == ID_CE_SUBJECT_ALT_NAME)
276274
.expect("cert had no SAN extension");
277275

278-
let actual_sans = SubjectAltName::from_der(san_extension.extn_value.as_bytes())
276+
let san_extension = SubjectAltName::from_der(san_extension.extn_value.as_bytes())
279277
.expect("failed to parse SAN");
280-
let actual_sans = actual_sans
278+
let actual_sans = san_extension
281279
.0
282280
.iter()
283281
.filter_map(|san| match san {

crates/stackable-certs/src/keys/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
//!
2121
//! ```no_run
2222
//! use stackable_certs::keys::{rsa::SigningKey, CertificateKeypair};
23-
//! let key = SigningKey::new().unwrap();;
23+
//! let key = SigningKey::new().unwrap();
2424
//! ```
2525
//!
2626
//! It should be noted, that the crate is currently vulnerable to the recently

crates/stackable-webhook/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,17 @@ All notable changes to this project will be documented in this file.
44

55
## [Unreleased]
66

7+
### Changed
8+
9+
- Use `ecdsa` keys instead of `rsa`. This is because generating 4096 bit `rsa` keys takes forever,
10+
thus making webhook development nearly impossible ([#1044]).
11+
712
### Fixed
813

914
- Don't pull in the `aws-lc-rs` crate, as this currently fails to build in `make run-dev` ([#1043]).
1015

1116
[#1043]: https://github.com/stackabletech/operator-rs/pull/1043
17+
[#1044]: https://github.com/stackabletech/operator-rs/pull/1044
1218

1319
## [0.3.1] - 2024-07-10
1420

crates/stackable-webhook/src/tls.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ impl TlsServer {
114114
.build()
115115
.build_ca()
116116
.context(CreateCertificateAuthoritySnafu)?;
117+
117118
let certificate = CertificateBuilder::builder()
118119
.subject("CN=webhook")
119120
.signed_by(&ca)

0 commit comments

Comments
 (0)