Rework X.509 cert/csr/crl extension representation - #449
Merged
Merged
Conversation
djc
reviewed
Sep 12, 2026
djc
left a comment
Member
There was a problem hiding this comment.
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.
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.
Member
Author
Done. I lifted everything after the version bump to a stacked follow-up PR #454 |
djc
approved these changes
Sep 21, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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