mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-31 19:24:42 +02:00
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.
This commit is contained in:
19
src/x509.c
19
src/x509.c
@@ -10737,6 +10737,25 @@ static int CertFromX509(Cert* cert, WOLFSSL_X509* x509)
|
||||
cert->altSigValLen = x509->altSigValLen;
|
||||
cert->altSigValCrit = x509->altSigValCrit;
|
||||
#endif /* WOLFSSL_DUAL_ALG_CERTS */
|
||||
|
||||
#ifdef WOLFSSL_CUSTOM_OID
|
||||
|
||||
if ((x509->customExtCount < 0) ||
|
||||
(x509->customExtCount >= NUM_CUSTOM_EXT)) {
|
||||
WOLFSSL_MSG("Bad value for customExtCount.");
|
||||
return WOLFSSL_FAILURE;
|
||||
}
|
||||
|
||||
for (i = 0; i < x509->customExtCount; i++) {
|
||||
if (wc_SetCustomExtension(cert, x509->custom_exts[i].crit,
|
||||
x509->custom_exts[i].oid, x509->custom_exts[i].val,
|
||||
x509->custom_exts[i].valSz))
|
||||
{
|
||||
return WOLFSSL_FAILURE;
|
||||
}
|
||||
}
|
||||
#endif /* WOLFSSL_CUSTOM_OID */
|
||||
|
||||
#endif /* WOLFSSL_CERT_EXT */
|
||||
|
||||
#ifdef WOLFSSL_CERT_REQ
|
||||
|
Reference in New Issue
Block a user