Skip to content

Commit 4a47e30

Browse files
committed
lib: write custom exts w/ helper
1 parent 918605c commit 4a47e30

File tree

1 file changed

+8
-21
lines changed

1 file changed

+8
-21
lines changed

src/lib.rs

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -922,17 +922,12 @@ impl CertificateParams {
922922

923923
// Write custom extensions
924924
for ext in custom_extensions {
925-
writer.next().write_sequence(|writer| {
926-
let oid = ObjectIdentifier::from_slice(&ext.oid);
927-
writer.next().write_oid(&oid);
928-
// If the extension is critical, we should signal this.
929-
// It's false by default so we don't need to write anything
930-
// if the extension is not critical.
931-
if ext.critical {
932-
writer.next().write_bool(true);
933-
}
934-
writer.next().write_bytes(&ext.content);
935-
});
925+
write_x509_extension(
926+
writer.next(),
927+
&ext.oid,
928+
ext.critical,
929+
|writer| writer.write_der(ext.content()),
930+
);
936931
}
937932
});
938933
});
@@ -1148,16 +1143,8 @@ impl CertificateParams {
11481143

11491144
// Write the custom extensions
11501145
for ext in &self.custom_extensions {
1151-
writer.next().write_sequence(|writer| {
1152-
let oid = ObjectIdentifier::from_slice(&ext.oid);
1153-
writer.next().write_oid(&oid);
1154-
// If the extension is critical, we should signal this.
1155-
// It's false by default so we don't need to write anything
1156-
// if the extension is not critical.
1157-
if ext.critical {
1158-
writer.next().write_bool(true);
1159-
}
1160-
writer.next().write_bytes(&ext.content);
1146+
write_x509_extension(writer.next(), &ext.oid, ext.critical, |writer| {
1147+
writer.write_der(ext.content())
11611148
});
11621149
}
11631150
});

0 commit comments

Comments
 (0)