Skip to content

Rework X.509 cert/csr/crl extension representation - #449

Merged
djc merged 7 commits into
mainfrom
ci/rework-exts
Sep 21, 2026
Merged

djc merged 7 commits into
mainfrom
ci/rework-exts

Conversation

@cpu

@cpu cpu commented Aug 29, 2026

Copy link
Copy Markdown
Member

This starts the extension rework from #446. Each extension is now its own type in a new ext module, with the presence decision living next to the encoding. Breaking changes are lifted to the follow-up #454

@cpu cpu self-assigned this Aug 29, 2026

@djc djc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

28 commits is a bit much. 😄

Suggest we split off a separate PR for the first bunch of commits, prior to the version bump? I have reviewed those and will be able to approve that quickly.

Comment thread rcgen/src/ext.rs Outdated
Comment thread rcgen/src/ext.rs Outdated
Comment thread rcgen/src/ext.rs Outdated
Comment thread rcgen/src/ext.rs
Comment thread rcgen/src/ext.rs
cpu added 7 commits September 18, 2026 14:01
Add an `Extension` trait (OID, criticality, DER value) and a single
`write_extension()` serializer so each extension's encoding lives beside
its presence logic as types are migrated. Extensions whose OID and
criticality are fixed by the profile defining them implement the
`StaticExtension` trait instead, receiving `Extension` through a
blanket impl.

Move authority key identifier writing into the module as the first
static extension, replacing `write_x509_authority_key_identifier()` in
the certificate and CRL paths.
Port the SAN extension into an `ext::SubjectAlternativeName` type whose
`from_params` constructor owns the presence decision, replacing
`write_subject_alt_names()` in the certificate and CSR paths. The
RFC 5280 §4.1.2.6 criticality rule (critical if the subject DN is
empty) is now unit tested.
Port the KeyUsage extension into an `ext::KeyUsage` static extension
whose `from_params` constructor owns the presence decision, replacing
`write_key_usage()` in the certificate and CSR paths. The
minimal-length BIT STRING encoding (including the 9-bit `decipherOnly`
case) remains covered by the existing certificate tests.
Port the EKU extension into an `ext::ExtendedKeyUsage` static extension
whose `from_params` constructor owns the presence decision, replacing
`write_extended_key_usage()` in the certificate and CSR paths.
Port the NameConstraints extension into an `ext::NameConstraints`
static extension whose `from_params` constructor owns the presence
decision (including omitting the extension when both subtrees are
empty), replacing the inline writer and `write_general_subtrees()` in
the certificate path.
Port the certificate CRLDistributionPoints extension into an
`ext::CrlDistributionPoints` static extension whose `from_params`
constructor owns the presence decision, replacing the inline writer in
the certificate path. The empty-URIs rejection in
`serialize_der_with_signer` is unchanged.
Port the SKI extension into an `ext::SubjectKeyIdentifier` static
extension constructed from a `KeyIdMethod` and the subject public key
info. The current behavior of only emitting SKI for
`IsCa::Ca`/`ExplicitNoCa` certificates (and never for CSRs) is
preserved.
@cpu
cpu added this pull request to stack #455 September 18, 2026 18:04
@cpu

cpu commented Sep 18, 2026

Copy link
Copy Markdown
Member Author

Suggest we split off a separate PR for the first bunch of commits, prior to the version bump? I have reviewed those and will be able to approve that quickly.

Done. I lifted everything after the version bump to a stacked follow-up PR #454

@djc
djc added this pull request to the merge queue Sep 21, 2026
Merged via the queue into main with commit 42cc86f Sep 21, 2026
32 checks passed
@djc
djc deleted the ci/rework-exts branch September 21, 2026 09:42
@djc djc mentioned this pull request Sep 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants