Skip to content

Commit 087adce

Browse files
committed
os_stub/cryptlib_openssl: x509: Don't copy some NIDs
Avoid copying the basic_constraints NID as we already set it ourselves and also avoid copying the authority_key_identifier as it won't be correct on the CSR. Signed-off-by: Alistair Francis <[email protected]>
1 parent 3bab714 commit 087adce

File tree

1 file changed

+15
-1
lines changed
  • os_stub/cryptlib_openssl/pk

1 file changed

+15
-1
lines changed

os_stub/cryptlib_openssl/pk/x509.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2635,10 +2635,24 @@ bool libspdm_gen_x509_csr(size_t hash_nid, size_t asym_nid,
26352635
sk_X509_EXTENSION_push(exts, basic_constraints_ext);
26362636

26372637
if (base_cert != NULL) {
2638+
const ASN1_OBJECT *basic_constraints_obj = OBJ_nid2obj(NID_basic_constraints);
2639+
const ASN1_OBJECT *authority_key_identifier_obj = OBJ_nid2obj(NID_authority_key_identifier);
2640+
26382641
num_exts = X509_get_ext_count(base_cert);
26392642

26402643
for (int i = 0; i < num_exts; i++) {
2641-
sk_X509_EXTENSION_push(exts, X509_get_ext(base_cert, i));
2644+
X509_EXTENSION *extension = X509_get_ext(base_cert, i);
2645+
ASN1_OBJECT *obj = X509_EXTENSION_get_object(extension);
2646+
2647+
if (OBJ_cmp(basic_constraints_obj, obj) == 0) {
2648+
continue;
2649+
}
2650+
2651+
if (OBJ_cmp(authority_key_identifier_obj, obj) == 0) {
2652+
continue;
2653+
}
2654+
2655+
sk_X509_EXTENSION_push(exts, extension);
26422656
}
26432657
}
26442658

0 commit comments

Comments
 (0)