Skip to content

Commit 3f83ed2

Browse files
authored
Merge pull request #8960 from ribes96/certwrite-custext
When creating a Cert from a WOLFSSL_X509, account for custom extensions
2 parents 3c00e26 + 5615993 commit 3f83ed2

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

src/x509.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10737,6 +10737,26 @@ 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+
#if defined(WOLFSSL_ASN_TEMPLATE) && defined(WOLFSSL_CUSTOM_OID) && \
10742+
defined(HAVE_OID_ENCODING)
10743+
10744+
if ((x509->customExtCount < 0) ||
10745+
(x509->customExtCount >= NUM_CUSTOM_EXT)) {
10746+
WOLFSSL_MSG("Bad value for customExtCount.");
10747+
return WOLFSSL_FAILURE;
10748+
}
10749+
10750+
for (i = 0; i < x509->customExtCount; i++) {
10751+
if (wc_SetCustomExtension(cert, x509->custom_exts[i].crit,
10752+
x509->custom_exts[i].oid, x509->custom_exts[i].val,
10753+
x509->custom_exts[i].valSz))
10754+
{
10755+
return WOLFSSL_FAILURE;
10756+
}
10757+
}
10758+
#endif /* WOLFSSL_ASN_TEMPLATE && WOLFSSL_CUSTOM_OID && HAVE_OID_ENCODING */
10759+
1074010760
#endif /* WOLFSSL_CERT_EXT */
1074110761

1074210762
#ifdef WOLFSSL_CERT_REQ

0 commit comments

Comments
 (0)