Skip to content

Commit

Permalink
Fix: mark SAN as critical when subject is empty
Browse files Browse the repository at this point in the history
Fixes #310
  • Loading branch information
howardjohn committed Jan 17, 2025
1 parent cd88a39 commit be6da1f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion rcgen/src/certificate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,10 @@ impl CertificateParams {
return;
}

write_x509_extension(writer, oid::SUBJECT_ALT_NAME, false, |writer| {
// Per https://tools.ietf.org/html/rfc5280#section-4.1.2.6, SAN must be marked
// as critical if subject is empty.
let critical = self.distinguished_name.entries.is_empty();
write_x509_extension(writer, oid::SUBJECT_ALT_NAME, critical, |writer| {
writer.write_sequence(|writer| {
for san in self.subject_alt_names.iter() {
writer.next().write_tagged_implicit(
Expand Down

0 comments on commit be6da1f

Please sign in to comment.