Skip to content
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

wip: refactoring extension handling #1

Closed
wants to merge 23 commits into from
Closed

wip: refactoring extension handling #1

wants to merge 23 commits into from

Commits on Sep 29, 2023

  1. error: alpha-sort Error variants

    cpu committed Sep 29, 2023
    Configuration menu
    Copy the full SHA
    ce2d261 View commit details
    Browse the repository at this point in the history
  2. ext: introduce module for X.509 extension handling

    This commit creates a new crate-internal module, `ext`, for managing
    X.509 extensions. In this commit we wire up emitting extensions managed
    by this module, but do not yet convert any existing extensions to the
    new arrangement. This will begin in subsequent commits.
    
    Notably the new representation for a collection of extensions uses
    a `BTreeMap` keyed by OID. We use this to reject additions of extensions
    that are already present in the map, since RFC 5280 forbids duplicate
    extensions. Using a `BTreeMap` instead of another map type allows
    preserving order.
    cpu committed Sep 29, 2023
    Configuration menu
    Copy the full SHA
    09af96f View commit details
    Browse the repository at this point in the history
  3. ext: implement authority key identifier.

    This commit lifts the authority key identifier extension into the `ext`
    module.
    cpu committed Sep 29, 2023
    Configuration menu
    Copy the full SHA
    205dc82 View commit details
    Browse the repository at this point in the history
  4. ext: implement subject alternative name.

    This commit lifts the subject alternative name extension into the `ext`
    module.
    cpu committed Sep 29, 2023
    Configuration menu
    Copy the full SHA
    247b9cf View commit details
    Browse the repository at this point in the history
  5. ext: implement key usage

    This commit lifts the key usage extension into the `ext` module.
    cpu committed Sep 29, 2023
    Configuration menu
    Copy the full SHA
    b252bf4 View commit details
    Browse the repository at this point in the history
  6. ext: implement extended key usage

    This commit lifts the extended key usage extension into the `ext`
    module.
    cpu committed Sep 29, 2023
    Configuration menu
    Copy the full SHA
    5c2ce4e View commit details
    Browse the repository at this point in the history
  7. ext: implement name constraints

    This commit lifts the name constraints extension into the `ext` module.
    cpu committed Sep 29, 2023
    Configuration menu
    Copy the full SHA
    55f9c76 View commit details
    Browse the repository at this point in the history
  8. ext: implement CRL distribution points

    This commit lifts the CRL distribution points extension into the `ext` module.
    cpu committed Sep 29, 2023
    Configuration menu
    Copy the full SHA
    4803c80 View commit details
    Browse the repository at this point in the history
  9. ext: implement subject key ID, specifying SKI

    This commit lifts the subject key identifier extension into the `ext`
    module.
    
    It additionally adds support for specifying a custom SKI value in
    `CertificateParams`, and reading it from a CSR's SKI ext.
    
    Diverging from the existing code we now adhere to the RFC 5280 advice
    and always emit the SKI extension when generating a certificate.
    Previously this was only done if the basic constraints specified
    `IsCa::Ca` or `IsCa::ExplicitNoCa`, but not when using `IsCa::NoCa`.
    cpu committed Sep 29, 2023
    Configuration menu
    Copy the full SHA
    b544af4 View commit details
    Browse the repository at this point in the history
  10. ext: implement basic constraints

    This commit lifts the basic constraints extension into the `ext` module.
    cpu committed Sep 29, 2023
    Configuration menu
    Copy the full SHA
    b206a7a View commit details
    Browse the repository at this point in the history
  11. ext: implement custom extensions

    This commit lifts the custom extension handling into the `ext`
    module.
    cpu committed Sep 29, 2023
    Configuration menu
    Copy the full SHA
    13bc40a View commit details
    Browse the repository at this point in the history
  12. ext: have Extensions write outer SEQUENCE

    Now that all extensions in certs and CSRs are managed through
    `Extensions` we can have that type manage writing the outer `SEQUENCE`
    and each `Extension`.
    cpu committed Sep 29, 2023
    Configuration menu
    Copy the full SHA
    151bc18 View commit details
    Browse the repository at this point in the history
  13. lib: use Extensions to decide when to emit exts

    Previously the params were interrogated for parameters that would
    indicate needing an extension to be emitted. Keeping this logic up to
    date was error prone. This commit reworks the code to emit extensions
    whenever the `Extensions` generated from the params isn't empty. This
    has the advantage of not needing to be updated when new parameter ->
    extension instances are added.
    cpu committed Sep 29, 2023
    Configuration menu
    Copy the full SHA
    1e3fbdc View commit details
    Browse the repository at this point in the history
  14. ext: implement crl number extension

    This commit lifts the CRL number extension handling into the `ext`
    module.
    cpu committed Sep 29, 2023
    Configuration menu
    Copy the full SHA
    7df23e4 View commit details
    Browse the repository at this point in the history
  15. ext: implement issuing distribution point extension

    This commit lifts the CRL issuing distribution point extension handling
    into the `ext` module.
    cpu committed Sep 29, 2023
    Configuration menu
    Copy the full SHA
    b4d8ead View commit details
    Browse the repository at this point in the history
  16. crl: unconditionally emit AKI ext

    We always have an issuer `Certificate` when invoking `extensions` on
    a `CertificateRevocationListParams`, and RFC 5280 says issuers are
    REQUIRED to include the AKI ext.
    cpu committed Sep 29, 2023
    Configuration menu
    Copy the full SHA
    cf96c6c View commit details
    Browse the repository at this point in the history
  17. crl: use Extensions to write DER encoding

    Now that all of the base CRL extensions are handled by `Extensions` we
    can use that type to emit the `SEQUENCE` directly.
    
    Similarly, since the only call-site always provides an issuer, simplify
    some logic.
    cpu committed Sep 29, 2023
    Configuration menu
    Copy the full SHA
    6f02b3a View commit details
    Browse the repository at this point in the history
  18. ext: implement reason code extension

    This commit lifts the CRL entry reason code extension handling
    into the `ext` module.
    cpu committed Sep 29, 2023
    Configuration menu
    Copy the full SHA
    124c49d View commit details
    Browse the repository at this point in the history
  19. ext: implement invalidity date extension

    This commit lifts the CRL entry invalidity date extension into the `ext` module.
    
    There are no longer any references to the lib.rs `write_x509_extension`
    helper, so it is also removed.
    cpu committed Sep 29, 2023
    Configuration menu
    Copy the full SHA
    202b895 View commit details
    Browse the repository at this point in the history
  20. crl: use Extensions to write DER

    Now that all of the CRL entry extensions have been migrated to
    `Extensions` we can let that type write the `SEQUENCE` and extension
    values.
    
    There are no longer any callers to `Extensions.iter()` so we remove that
    fn.
    cpu committed Sep 29, 2023
    Configuration menu
    Copy the full SHA
    7e9a7c7 View commit details
    Browse the repository at this point in the history
  21. lib: relax unsupported CSR exts

    In preparation for broader CSR extension support this commit updates the
    logic for detecting unsupported CSR exts to only forbid serial number.
    cpu committed Sep 29, 2023
    Configuration menu
    Copy the full SHA
    cf368ce View commit details
    Browse the repository at this point in the history
  22. tests: add test for CSR extensions

    This commit adds a unit test that ensures when an
    `rcgen::CertificateParams` specifies parameters that result in X.509
    extensions, we find each expected extension in a generated certificate
    *and* certificate signing request when parsing both with `x509-parser`.
    cpu committed Sep 29, 2023
    Configuration menu
    Copy the full SHA
    b32736b View commit details
    Browse the repository at this point in the history
  23. csr: support populating custom extensions from CSR.

    This commit updates the CSR parsing to populate unknown requested
    extensions as custom extensions in the built CSR
    `CertificateParams.custom_extensions`.
    cpu committed Sep 29, 2023
    Configuration menu
    Copy the full SHA
    e8348ab View commit details
    Browse the repository at this point in the history