-
Notifications
You must be signed in to change notification settings - Fork 113
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
basic Ia5String support for DistinguishedName values #182
Conversation
Codecov Report
@@ Coverage Diff @@
## main #182 +/- ##
==========================================
+ Coverage 72.13% 72.86% +0.72%
==========================================
Files 7 7
Lines 1888 1861 -27
==========================================
- Hits 1362 1356 -6
+ Misses 526 505 -21
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see comments.
Fixes the warning: ``` warning: profiles for the non root package will be ignored, specify profiles at the workspace root: package: /home/daniel/Code/Rust/rcgen/rcgen/Cargo.toml workspace: /home/daniel/Code/Rust/rcgen/Cargo.toml ```
Previously the `CertificateParams::write_request` fn duplicated code already present in `write_distinguished_name` for serializing a `DistinguishedName`. This commit replaces the duplicate code with usage of that helper.
This commit updates the `DnValue` enum to add a variant for `Ia5String` values in distinguished names, and adds support for serializing it. These are often used for email address attributes since the printable string type can't contain a `@` character. Note that like existing `DnValue` variants, we accept a `String` but the ASN.1 specification of the encoding constrains allowed values further. Writing a `DnValue::Ia5String` that contains non-ascii characters will panic, similar to how using a `DnValue::PrintableString` with the current code using a value with characters outside of the allowed set will panic. In the future we should consider rewriting the `DnValue` enum to better enforce the character set constraints of each variant at construction time.
This commit updates the logic for converting from the x509-parser distinguished name types into the rcgen equivalent in order to support `Ia5String` values. A small unit test is added that shows round-tripping a certificate with a subject containing an `Ia5String`, serializing it, parsing with x509-parser, and then recreating `CertificateParams` from the DER using `from_ca_cert_der`.
8891a8c
to
eb9bae7
Compare
@djc Did you want to give this branch a pass before merge? |
This branch adds basic support emitting and parsing distinguished name values that are Ia5Strings. For example, email address attributes in a certificate subject distinguished name.
Note that because of #181 this code will panic when emitting invalid Ia5String values. This problem is general to rcgen's handling of ASN.1 string types and so isn't addressed with additional care in this branch. A broader rework is required.
Along the way I also fixed a warning from #176 related to where we were defining the custom
profile.dev.package.num-bigint-dig
profile metadata.Resolves #180