Skip to content

Commit 84a7000

Browse files
committed
asn: drop redundant serial-0 check in DecodeCertInternal to avoid fail-open on forged isC
1 parent e9a6e5e commit 84a7000

1 file changed

Lines changed: 0 additions & 19 deletions

File tree

wolfcrypt/src/asn.c

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20628,25 +20628,6 @@ static int DecodeCertInternal(DecodedCert* cert, int verify, int* criticalExt,
2062820628
}
2062920629
}
2063020630

20631-
#if !defined(WOLFSSL_NO_ASN_STRICT) && !defined(WOLFSSL_PYTHON) && \
20632-
!defined(WOLFSSL_ASN_ALLOW_0_SERIAL)
20633-
/* Check for serial number of 0. RFC 5280 section 4.1.2.2 requires
20634-
* positive serial numbers. However, allow zero for self-signed CA
20635-
* certificates (root CAs) being loaded as trust anchors since they
20636-
* are explicitly trusted and some legacy root CAs in real-world
20637-
* trust stores have serial number 0. */
20638-
if ((ret == 0) && (cert->serialSz == 1) && (cert->serial[0] == 0)) {
20639-
if (!(cert->isCA && cert->selfSigned)
20640-
#ifdef WOLFSSL_CERT_REQ
20641-
&& !cert->isCSR
20642-
#endif
20643-
) {
20644-
WOLFSSL_MSG("Error serial number of 0 for non-root certificate");
20645-
ret = ASN_PARSE_E;
20646-
}
20647-
}
20648-
#endif
20649-
2065020631
if ((ret == 0) && (!done) && (badDate != 0)) {
2065120632
/* Parsed whole certificate fine but return any date errors. */
2065220633
ret = badDate;

0 commit comments

Comments
 (0)