Skip to content

Commit 5d5bcba

Browse files
committed
tests: update SAN NUL fixtures and add parse-time rejection coverage
The dNSName NUL-rejection fix changes two test fixtures whose intent was to verify runtime hostname matching against a NUL-containing SAN. Those certs now fail to parse. Swap the NUL byte in the fixture for a printable byte to keep the underflow and wildcard-matching tests meaningful, add an explicit parse-time-rejection assertion, and retire the test-fails.conf entries that used server-badaltnull.pem (cert load is now catastrophic for the server so the cipher-suite harness path is no longer reachable).
1 parent f80e188 commit 5d5bcba

3 files changed

Lines changed: 13 additions & 19 deletions

File tree

tests/api/test_asn.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,7 @@ int test_DecodeAltNames_length_underflow(void)
969969
0x06, 0x03, 0x55, 0x1d, 0x13, 0x01, 0x01, 0xff, 0x04, 0x02, 0x30, 0x00,
970970
/* SAN extension: correct SEQUENCE length 0x06 */
971971
0x30, 0x0f, 0x06, 0x03, 0x55, 0x1d, 0x11, 0x04, 0x08, 0x30, 0x06, 0x82,
972-
0x04, 0x61, 0x2a, 0x00, 0x2a, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e,
972+
0x04, 0x61, 0x2a, 0x62, 0x2a, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e,
973973
0x04, 0x16, 0x04, 0x14, 0x92, 0x6a, 0x1e, 0x52, 0x3a, 0x1a, 0x57, 0x9f,
974974
0xc9, 0x82, 0x9a, 0xce, 0xc8, 0xc0, 0xa9, 0x51, 0x9d, 0x2f, 0xc7, 0x72,
975975
0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80,
@@ -1025,6 +1025,16 @@ int test_DecodeAltNames_length_underflow(void)
10251025
WC_NO_ERR_TRACE(ASN_PARSE_E));
10261026
wc_FreeDecodedCert(&cert);
10271027

1028+
/* NUL in dNSName SAN must be rejected per RFC 5280 4.2.1.6. */
1029+
XMEMCPY(bad_san_cert, good_san_cert, sizeof(good_san_cert));
1030+
bad_san_cert[SAN_SEQ_LEN_OFFSET + 5] = 0x00;
1031+
1032+
wc_InitDecodedCert(&cert, bad_san_cert, (word32)sizeof(bad_san_cert),
1033+
NULL);
1034+
ExpectIntEQ(wc_ParseCert(&cert, CERT_TYPE, NO_VERIFY, NULL),
1035+
WC_NO_ERR_TRACE(ASN_PARSE_E));
1036+
wc_FreeDecodedCert(&cert);
1037+
10281038
#endif /* !NO_CERTS && !NO_RSA && !NO_ASN */
10291039
return EXPECT_RESULT();
10301040
}

tests/api/test_ossl_x509.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,7 +1136,7 @@ int test_wolfSSL_X509_bad_altname(void)
11361136
0xf5, 0xe5, 0x09, 0x02, 0x01, 0x03, 0xa3, 0x61, 0x30, 0x5f, 0x30, 0x0c,
11371137
0x06, 0x03, 0x55, 0x1d, 0x13, 0x01, 0x01, 0xff, 0x04, 0x02, 0x30, 0x00,
11381138
0x30, 0x0f, 0x06, 0x03, 0x55, 0x1d, 0x11, 0x04, 0x08, 0x30, 0x06, 0x82,
1139-
0x04, 0x61, 0x2a, 0x00, 0x2a, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e,
1139+
0x04, 0x61, 0x2a, 0x62, 0x2a, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e,
11401140
0x04, 0x16, 0x04, 0x14, 0x92, 0x6a, 0x1e, 0x52, 0x3a, 0x1a, 0x57, 0x9f,
11411141
0xc9, 0x82, 0x9a, 0xce, 0xc8, 0xc0, 0xa9, 0x51, 0x9d, 0x2f, 0xc7, 0x72,
11421142
0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80,
@@ -1175,8 +1175,7 @@ int test_wolfSSL_X509_bad_altname(void)
11751175
ExpectNotNull(x509 = wolfSSL_X509_load_certificate_buffer(
11761176
malformed_alt_name_cert, certSize, SSL_FILETYPE_ASN1));
11771177

1178-
/* malformed_alt_name_cert has a malformed alternative
1179-
* name of "a*\0*". Ensure that it does not match "aaaaa" */
1178+
/* SAN "a*b*" must not match "aaaaa" under any wildcard flag. */
11801179
ExpectIntNE(wolfSSL_X509_check_host(x509, name, nameLen,
11811180
WOLFSSL_ALWAYS_CHECK_SUBJECT, NULL), 1);
11821181

tests/test-fails.conf

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,6 @@
1414
-m
1515
-x
1616

17-
# server bad certificate alternate name has null
18-
-v 3
19-
-l ECDHE-RSA-AES128-GCM-SHA256
20-
-k ./certs/server-key.pem
21-
-c ./certs/test/server-badaltnull.pem
22-
-d
23-
24-
# client bad certificate alternate name has null
25-
-v 3
26-
-l ECDHE-RSA-AES128-GCM-SHA256
27-
-h localhost
28-
-A ./certs/test/server-badaltnull.pem
29-
-m
30-
-x
31-
3217
# server nomatch common name
3318
-v 3
3419
-l ECDHE-RSA-AES128-GCM-SHA256

0 commit comments

Comments
 (0)