Skip to content

Commit

Permalink
lib: write custom exts w/ helper
Browse files Browse the repository at this point in the history
  • Loading branch information
cpu committed Sep 10, 2023
1 parent 0604d2c commit 401e950
Showing 1 changed file with 8 additions and 21 deletions.
29 changes: 8 additions & 21 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -922,17 +922,12 @@ impl CertificateParams {

// Write custom extensions
for ext in custom_extensions {
writer.next().write_sequence(|writer| {
let oid = ObjectIdentifier::from_slice(&ext.oid);
writer.next().write_oid(&oid);
// If the extension is critical, we should signal this.
// It's false by default so we don't need to write anything
// if the extension is not critical.
if ext.critical {
writer.next().write_bool(true);
}
writer.next().write_bytes(&ext.content);
});
write_x509_extension(
writer.next(),
&ext.oid,
ext.critical,
|writer| writer.write_der(ext.content()),
);
}
});
});
Expand Down Expand Up @@ -1148,16 +1143,8 @@ impl CertificateParams {

// Write the custom extensions
for ext in &self.custom_extensions {
writer.next().write_sequence(|writer| {
let oid = ObjectIdentifier::from_slice(&ext.oid);
writer.next().write_oid(&oid);
// If the extension is critical, we should signal this.
// It's false by default so we don't need to write anything
// if the extension is not critical.
if ext.critical {
writer.next().write_bool(true);
}
writer.next().write_bytes(&ext.content);
write_x509_extension(writer.next(), &ext.oid, ext.critical, |writer| {
writer.write_der(ext.content())
});
}
});
Expand Down

0 comments on commit 401e950

Please sign in to comment.