Skip to content

feat!(stackable-certs): Support adding SAN entries #1057

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

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

Conversation

sbernauer
Copy link
Member

Description

As #1044 didn't move along, splitting the relevant change out to unblock CRD versioning.

Definition of Done Checklist

  • Not all of these items are applicable to all PRs, the author should update this template to only leave the boxes in that are relevant
  • Please make sure all these things are done and tick the boxes

Author

  • Changes are OpenShift compatible
  • CRD changes approved
  • CRD documentation for all fields, following the style guide.
  • Integration tests passed (for non trivial changes)
  • Changes need to be "offline" compatible

Reviewer

  • Code contains useful comments
  • Code contains useful logging statements
  • (Integration-)Test cases added
  • Documentation added or updated. Follows the style guide.
  • Changelog updated
  • Cargo.toml only contains references to git tags (not specific commits or branches)

Acceptance

  • Feature Tracker has been updated
  • Proper release label has been added

@sbernauer sbernauer moved this to Development: Waiting for Review in Stackable Engineering Jun 23, 2025
Copy link
Member

@NickLarsenNZ NickLarsenNZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some changes to the changelog, and the rest (I think) are only suggestions.

sbernauer and others added 3 commits June 24, 2025 09:20
Co-authored-by: Nick <10092581+NickLarsenNZ@users.noreply.github.com>
Co-authored-by: Nick <10092581+NickLarsenNZ@users.noreply.github.com>
Co-authored-by: Nick <10092581+NickLarsenNZ@users.noreply.github.com>
@sbernauer sbernauer requested a review from NickLarsenNZ June 24, 2025 07:26
NickLarsenNZ
NickLarsenNZ previously approved these changes Jun 25, 2025
Copy link
Member

@NickLarsenNZ NickLarsenNZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@sbernauer
Copy link
Member Author

Thanks for the review!

@sbernauer sbernauer enabled auto-merge June 25, 2025 07:01
@sbernauer sbernauer disabled auto-merge June 25, 2025 07:01
Copy link
Member

@Techassi Techassi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't take a close look at this, but I will soon.

Blocking it for now.

Comment on lines +9 to +12
- BREAKING: `CertificateAuthority::generate_leaf_certificate` (and `generate_rsa_leaf_certificate` and `generate_ecdsa_leaf_certificate`)
now take an additional parameter `subject_alterative_dns_names`. The passed SANs are added to the generated certificate,
this is needed when the HTTPS server is accessible on multiple DNS names and/or IPs.
Pass an empty list (`[]`) to keep the existing behavior ([#1057]).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: This is a change, not an addition. As such, this should live in the "Changed" section.

suggestion: Slight reword.

Suggested change
- BREAKING: `CertificateAuthority::generate_leaf_certificate` (and `generate_rsa_leaf_certificate` and `generate_ecdsa_leaf_certificate`)
now take an additional parameter `subject_alterative_dns_names`. The passed SANs are added to the generated certificate,
this is needed when the HTTPS server is accessible on multiple DNS names and/or IPs.
Pass an empty list (`[]`) to keep the existing behavior ([#1057]).
- BREAKING: The functions `generate_leaf_certificate`, `generate_rsa_leaf_certificate` and
`generate_ecdsa_leaf_certificate` of `CertificateAuthority` accept an additional parameter
`subject_alterative_dns_names` ([#1057]).
- The passed SANs are added to the generated certificate, this is needed when the HTTPS server is
accessible on multiple DNS names and/or IPs.
- Pass an empty list (`[]`) to keep the existing behavior.

Comment on lines +13 to +15
- BREAKING: Constants have been renamed/retyped ([#1057]):
- `DEFAULT_CA_VALIDITY_SECONDS` has been renamed to `DEFAULT_CA_VALIDITY` and now is of type `stackable_operator::time::Duration`.
- `ROOT_CA_SUBJECT` has been renamed to `SDP_ROOT_CA_SUBJECT`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: This also a change and should be moved.

- BREAKING: Constants have been renamed/retyped ([#1057]):
- `DEFAULT_CA_VALIDITY_SECONDS` has been renamed to `DEFAULT_CA_VALIDITY` and now is of type `stackable_operator::time::Duration`.
- `ROOT_CA_SUBJECT` has been renamed to `SDP_ROOT_CA_SUBJECT`.
- Added the function `CertificateAuthority::ca_cert` to easily get the CA `Certificate` ([#1057]).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Slight reword.

Suggested change
- Added the function `CertificateAuthority::ca_cert` to easily get the CA `Certificate` ([#1057]).
- Add the function `CertificateAuthority::ca_cert` to easily get the CA `Certificate` ([#1057]).

## [0.3.1] - 2024-07-10

### Changed

- Bump rust-toolchain to 1.79.0 ([#822]).

[#822]: https://github.com/stackabletech/operator-rs/pull/822
[#1057]: https://github.com/stackabletech/operator-rs/pull/1057
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: This link reference is in the wrong place.

Comment on lines +71 to +73
#[snafu(display(
"failed to parse subject alternative DNS name \"{subject_alternative_dns_name}\" as a Ia5 string"
))]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: Get rid of the escaped quotes.

Suggested change
#[snafu(display(
"failed to parse subject alternative DNS name \"{subject_alternative_dns_name}\" as a Ia5 string"
))]
#[snafu(display(
"failed to parse subject alternative DNS name {subject_alternative_dns_name:?} as a Ia5 string"
))]

use super::*;

const TEST_CERT_LIFETIME: Duration = Duration::from_hours_unchecked(1);
const TEST_SAN: &str = "airflow-0.airflow.default.svc.cluster.local";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: Can we use a non-product specific test value here? This comes to mind:

Suggested change
const TEST_SAN: &str = "airflow-0.airflow.default.svc.cluster.local";
const TEST_SAN: &str = "example-0.example.default.svc.cluster.local";

ca.generate_rsa_leaf_certificate("Airflow", "pod", Duration::from_secs(3600))
.unwrap();
let cert = ca
.generate_rsa_leaf_certificate("Airflow", "pod", [TEST_SAN], TEST_CERT_LIFETIME)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: In a similar fashion, we should replace "Airflow" with "Example" here as well.

.unwrap();
let cert = ca
.generate_rsa_leaf_certificate("Airflow", "pod", [TEST_SAN], TEST_CERT_LIFETIME)
.expect("RSA certificate generation failed");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

praise: Nicely done!

note: The message should instead read why this will never fail.

);

// Test SAN extension is present
let extensions = cert.extensions.as_ref().expect("cert had no extension");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: This should state why it should never fail. Something like this comes to mind:

Suggested change
let extensions = cert.extensions.as_ref().expect("cert had no extension");
let extensions = cert.extensions.as_ref().expect("cert must have extensions");

assert_eq!(
not_after
.duration_since(not_before)
.expect("Failed to calculate duration between notBefore and notAfter"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: This should state why it should never fail.

@Techassi Techassi moved this from Development: Waiting for Review to Development: In Review in Stackable Engineering Jun 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Development: In Review
Development

Successfully merging this pull request may close these issues.

3 participants