Skip to content

Commit 3ef8915

Browse files
committed
asn: drop redundant serial-0 check in DecodeCertInternal to avoid fail-open on forged isC
1 parent d79691e commit 3ef8915

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
@@ -20983,25 +20983,6 @@ static int DecodeCertInternal(DecodedCert* cert, int verify, int* criticalExt,
2098320983
}
2098420984
}
2098520985

20986-
#if !defined(WOLFSSL_NO_ASN_STRICT) && !defined(WOLFSSL_PYTHON) && \
20987-
!defined(WOLFSSL_ASN_ALLOW_0_SERIAL)
20988-
/* Check for serial number of 0. RFC 5280 section 4.1.2.2 requires
20989-
* positive serial numbers. However, allow zero for self-signed CA
20990-
* certificates (root CAs) being loaded as trust anchors since they
20991-
* are explicitly trusted and some legacy root CAs in real-world
20992-
* trust stores have serial number 0. */
20993-
if ((ret == 0) && (cert->serialSz == 1) && (cert->serial[0] == 0)) {
20994-
if (!(cert->isCA && cert->selfSigned)
20995-
#ifdef WOLFSSL_CERT_REQ
20996-
&& !cert->isCSR
20997-
#endif
20998-
) {
20999-
WOLFSSL_MSG("Error serial number of 0 for non-root certificate");
21000-
ret = ASN_PARSE_E;
21001-
}
21002-
}
21003-
#endif
21004-
2100520986
if ((ret == 0) && (!done) && (badDate != 0)) {
2100620987
/* Parsed whole certificate fine but return any date errors. */
2100720988
ret = badDate;

0 commit comments

Comments
 (0)