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

lib: use ext helper in more places, test custom exts. #154

Merged
merged 4 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,7 @@ impl CertificateParams {
// Write extensions
// According to the spec in RFC 2986, even if attributes are empty we need the empty attribute tag
writer.next().write_tagged(Tag::context(0), |writer| {
if !subject_alt_names.is_empty() {
if !subject_alt_names.is_empty() || !custom_extensions.is_empty() {
cpu marked this conversation as resolved.
Show resolved Hide resolved
writer.write_sequence(|writer| {
let oid = ObjectIdentifier::from_slice(OID_PKCS_9_AT_EXTENSION_REQUEST);
writer.next().write_oid(&oid);
Expand Down
3 changes: 3 additions & 0 deletions tests/generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ mod test_x509_custom_ext {
// Generate a certificate with the custom extension, parse it with x509-parser.
let mut params = util::default_params();
params.custom_extensions = vec![custom_ext];
// Ensure the custom exts. being omitted into a CSR doesn't require SAN ext being present.
// See https://github.com/rustls/rcgen/issues/122
params.subject_alt_names = Vec::default();
let test_cert = Certificate::from_params(params).unwrap();
let test_cert_der = test_cert.serialize_der().unwrap();
let (_, x509_test_cert) = X509Certificate::from_der(&test_cert_der).unwrap();
Expand Down