Skip to content

Commit 2ddd989

Browse files
committed
When creating a Cert from a WOLFSSL_X509, account for custom extensions
Function 'CertFromX509' is used to convert a WOLFSSL_X509 to a Cert structure for writing out. It didn't copy custom extensions.
1 parent 6be8a37 commit 2ddd989

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

src/x509.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10737,6 +10737,25 @@ static int CertFromX509(Cert* cert, WOLFSSL_X509* x509)
1073710737
cert->altSigValLen = x509->altSigValLen;
1073810738
cert->altSigValCrit = x509->altSigValCrit;
1073910739
#endif /* WOLFSSL_DUAL_ALG_CERTS */
10740+
10741+
#ifdef WOLFSSL_CUSTOM_OID
10742+
10743+
if ((x509->customExtCount < 0) ||
10744+
(x509->customExtCount >= NUM_CUSTOM_EXT)) {
10745+
WOLFSSL_MSG("Bad value for customExtCount.");
10746+
return WOLFSSL_FAILURE;
10747+
}
10748+
10749+
for (i = 0; i < x509->customExtCount; i++) {
10750+
if (wc_SetCustomExtension(cert, x509->custom_exts[i].crit,
10751+
x509->custom_exts[i].oid, x509->custom_exts[i].val,
10752+
x509->custom_exts[i].valSz))
10753+
{
10754+
return WOLFSSL_FAILURE;
10755+
}
10756+
}
10757+
#endif /* WOLFSSL_CUSTOM_OID */
10758+
1074010759
#endif /* WOLFSSL_CERT_EXT */
1074110760

1074210761
#ifdef WOLFSSL_CERT_REQ

0 commit comments

Comments
 (0)