Skip to content

Commit b92723f

Browse files
authored
Additional X.509 Behavior Compatability Tests (#2312)
* CRL Distribution Points extension per RFC 5280 should be marked non-critical, but OpenSSL 1.1.1 does allow for it to be marked critical by a CA issuing a certificate. Thus we modify to allow for this condition and add an associated test-case. * Adds a test for a Root CA missing the basic constraints extension and a corresponding end-entity certificate signed by such a root. * Adds a test for a certificate containing a negative serial number. While this does not conform to RFC 5280, it is supported by OpenSSL 1.1.1 and many other implementations. This adds a test-case for this behavior which was not previously covered. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.
1 parent fd8faa8 commit b92723f

File tree

4 files changed

+328
-16
lines changed

4 files changed

+328
-16
lines changed

crypto/test/x509_util.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ int Verify(X509 *leaf, const std::vector<X509 *> &roots,
4848
return X509_V_OK;
4949
}
5050

51-
// CRLsToStack converts a vector of |X509_CRL*| to an OpenSSL
52-
// STACK_OF(X509_CRL), bumping the reference counts for each CRL in question.
5351
bssl::UniquePtr<STACK_OF(X509_CRL)> CRLsToStack(
5452
const std::vector<X509_CRL *> &crls) {
5553
bssl::UniquePtr<STACK_OF(X509_CRL)> stack(sk_X509_CRL_new_null());

crypto/test/x509_util.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ int Verify(X509 *leaf, const std::vector<X509 *> &roots,
1414
const std::vector<X509_CRL *> &crls, unsigned long flags = 0,
1515
std::function<void(X509_STORE_CTX *)> configure_callback = nullptr);
1616

17+
// CRLsToStack converts a vector of |X509_CRL*| to an OpenSSL
18+
// STACK_OF(X509_CRL), bumping the reference counts for each CRL in question.
1719
bssl::UniquePtr<STACK_OF(X509_CRL)> CRLsToStack(
1820
const std::vector<X509_CRL *> &crls);
1921

crypto/x509/v3_purp.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -191,15 +191,16 @@ int X509_PURPOSE_get_trust(const X509_PURPOSE *xp) { return xp->trust; }
191191

192192
int X509_supported_extension(const X509_EXTENSION *ex) {
193193
int nid = OBJ_obj2nid(X509_EXTENSION_get_object(ex));
194-
return nid == NID_netscape_cert_type || //
195-
nid == NID_key_usage || //
196-
nid == NID_subject_alt_name || //
197-
nid == NID_basic_constraints || //
198-
nid == NID_certificate_policies || //
199-
nid == NID_ext_key_usage || //
200-
nid == NID_policy_constraints || //
201-
nid == NID_name_constraints || //
202-
nid == NID_policy_mappings || //
194+
return nid == NID_netscape_cert_type ||
195+
nid == NID_key_usage ||
196+
nid == NID_subject_alt_name ||
197+
nid == NID_basic_constraints ||
198+
nid == NID_certificate_policies ||
199+
nid == NID_crl_distribution_points ||
200+
nid == NID_ext_key_usage ||
201+
nid == NID_policy_constraints ||
202+
nid == NID_name_constraints ||
203+
nid == NID_policy_mappings ||
203204
nid == NID_inhibit_any_policy;
204205
}
205206

crypto/x509/x509_compat_test.cc

Lines changed: 316 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,10 @@ bqbf/QCFwAYCIQDuFSNQQBtnsOsTdW4pZrDmWM8fwl6hhQFFnE2r52GscA==
153153
)";
154154

155155
/*
156+
The is a valid root certificate that is expected to pass validation.
157+
It may be used as a trust-anchor for both good or bad intermediate or
158+
client certificates in testing.
159+
156160
Certificate:
157161
Data:
158162
Version: 3 (0x2)
@@ -206,7 +210,7 @@ PS8hFVZDyLgCIDa9A7zf9n3So9KlSKhkdQBOAc1nuRmHSSu9FZQ+9XXK
206210
)";
207211

208212
/*
209-
This is an EE certificate signed by |kValidRootCA1|, and is invalid as it
213+
This is an EE certificate signed by |kValidRootCA1|, and is invalid as it
210214
has an Authority Key Identifier (AKID) extension marked critical which
211215
is not valid per RFC 5280 4.2.1.1:
212216
"Conforming CAs MUST mark this extension as non-critical."
@@ -270,6 +274,270 @@ Dd9ONQ==
270274
-----END CERTIFICATE-----
271275
)";
272276

277+
/*
278+
This certificate has a CRL Distribution Points extension, that per RFC 5280:
279+
"The [CRL distribution points] extension SHOULD be non-critical, but this
280+
profile RECOMMENDS support for this extension by CAs and applications."
281+
282+
OpenSSL 1.1.1 supports this extension being marked as critical, and will not
283+
fail certificate verification because so.
284+
285+
Certificate:
286+
Data:
287+
Version: 3 (0x2)
288+
Serial Number:
289+
78:ea:d8:8b:b6:51:24:24:05:ed:24:af:8f:d5:1f:e2:43:bb:f6:1c
290+
Signature Algorithm: ecdsa-with-SHA256
291+
Issuer: C = US, ST = Washington, O = AWS Libcrypto, OU = Good CA, CN = Root CA 1
292+
Validity
293+
Not Before: Jan 1 00:00:00 2015 GMT
294+
Not After : Jan 1 00:00:00 2100 GMT
295+
Subject: C = US, ST = Washington, O = AWS Libcrypto, OU = Good Endpoint, CN = RFC 5280 4.2.1.13, SN = CRL distribution points ... extension SHOULD be non-critical
296+
Subject Public Key Info:
297+
Public Key Algorithm: id-ecPublicKey
298+
Public-Key: (256 bit)
299+
pub:
300+
04:b2:b7:bd:35:f2:eb:da:86:d5:dc:40:44:c7:23:
301+
14:f9:d0:a5:40:17:30:85:b6:c6:11:38:c2:db:2c:
302+
c5:bc:0c:19:11:d8:68:61:d6:a3:92:6b:8a:18:52:
303+
2c:dc:86:a7:ad:29:ad:91:ac:7e:df:87:24:3b:f3:
304+
b4:71:2b:4e:58
305+
ASN1 OID: prime256v1
306+
NIST CURVE: P-256
307+
X509v3 extensions:
308+
X509v3 Key Usage: critical
309+
Digital Signature, Key Encipherment
310+
X509v3 Basic Constraints: critical
311+
CA:FALSE
312+
X509v3 Extended Key Usage:
313+
TLS Web Server Authentication, TLS Web Client Authentication
314+
X509v3 CRL Distribution Points: critical
315+
Full Name:
316+
URI:http://example.com/crl
317+
X509v3 Subject Key Identifier:
318+
C8:78:64:E9:F7:9C:0F:56:E2:1D:CE:EE:ED:24:E0:9F:1D:4B:A3:BF
319+
X509v3 Authority Key Identifier:
320+
19:19:E1:8C:09:E2:5D:5C:16:04:E1:9C:74:66:19:FD:B8:52:5B:DF
321+
Signature Algorithm: ecdsa-with-SHA256
322+
Signature Value:
323+
30:46:02:21:00:cc:41:52:6e:40:01:46:d1:5e:4c:5b:23:27:
324+
55:ea:02:55:60:62:10:0c:9b:45:65:9a:a4:5b:9b:74:72:fa:
325+
c4:02:21:00:ba:2f:dc:ba:96:6d:ae:f3:19:3e:66:aa:18:9b:
326+
c5:ec:61:53:5a:d6:25:e5:66:bf:f3:9b:d6:d9:d2:e3:88:63
327+
*/
328+
static char kValidEECertWithCriticalCRLDistributionExt[] = R"(
329+
-----BEGIN CERTIFICATE-----
330+
MIICyDCCAm2gAwIBAgIUeOrYi7ZRJCQF7SSvj9Uf4kO79hwwCgYIKoZIzj0EAwIw
331+
YDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCldhc2hpbmd0b24xFjAUBgNVBAoMDUFX
332+
UyBMaWJjcnlwdG8xEDAOBgNVBAsMB0dvb2QgQ0ExEjAQBgNVBAMMCVJvb3QgQ0Eg
333+
MTAgFw0xNTAxMDEwMDAwMDBaGA8yMTAwMDEwMTAwMDAwMFowgbUxCzAJBgNVBAYT
334+
AlVTMRMwEQYDVQQIDApXYXNoaW5ndG9uMRYwFAYDVQQKDA1BV1MgTGliY3J5cHRv
335+
MRYwFAYDVQQLDA1Hb29kIEVuZHBvaW50MRowGAYDVQQDDBFSRkMgNTI4MCA0LjIu
336+
MS4xMzFFMEMGA1UEBAw8Q1JMIGRpc3RyaWJ1dGlvbiBwb2ludHMgLi4uIGV4dGVu
337+
c2lvbiBTSE9VTEQgYmUgbm9uLWNyaXRpY2FsMFkwEwYHKoZIzj0CAQYIKoZIzj0D
338+
AQcDQgAEsre9NfLr2obV3EBExyMU+dClQBcwhbbGETjC2yzFvAwZEdhoYdajkmuK
339+
GFIs3IanrSmtkax+34ckO/O0cStOWKOBrDCBqTAOBgNVHQ8BAf8EBAMCBaAwDAYD
340+
VR0TAQH/BAIwADAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwKgYDVR0f
341+
AQH/BCAwHjAcoBqgGIYWaHR0cDovL2V4YW1wbGUuY29tL2NybDAdBgNVHQ4EFgQU
342+
yHhk6fecD1biHc7u7STgnx1Lo78wHwYDVR0jBBgwFoAUGRnhjAniXVwWBOGcdGYZ
343+
/bhSW98wCgYIKoZIzj0EAwIDSQAwRgIhAMxBUm5AAUbRXkxbIydV6gJVYGIQDJtF
344+
ZZqkW5t0cvrEAiEAui/cupZtrvMZPmaqGJvF7GFTWtYl5Wa/85vW2dLjiGM=
345+
-----END CERTIFICATE-----
346+
)";
347+
348+
/*
349+
This is a v3 certificate that has the keyCertSign keyUsage bit set but is
350+
missing the Basic Constraints extension. Per RFC 5280 4.2.1.9: "If the basic
351+
constraints extension is not present in a version 3 certificate, or the
352+
extension is present but the cA boolean is not asserted, then the certified
353+
public key MUST NOT be used to verify certificate signatures."
354+
355+
Certificate:
356+
Data:
357+
Version: 3 (0x2)
358+
Serial Number:
359+
3e:d2:f9:bf:f8:43:a5:8a:69:cb:8f:6e:e6:29:43:a3:b8:be:2c:e1
360+
Signature Algorithm: ecdsa-with-SHA256
361+
Issuer: C = US, ST = Washington, O = AWS Libcrypto, OU = Bad CA, CN = RFC 528 4.2.1.9 not present, SN = MUST NOT be used to verify certificate signatures
362+
Validity
363+
Not Before: Jan 1 00:00:00 2015 GMT
364+
Not After : Jan 1 00:00:00 2100 GMT
365+
Subject: C = US, ST = Washington, O = AWS Libcrypto, OU = Bad CA, CN = RFC 528 4.2.1.9 not present, SN = MUST NOT be used to verify certificate signatures
366+
Subject Public Key Info:
367+
Public Key Algorithm: id-ecPublicKey
368+
Public-Key: (256 bit)
369+
pub:
370+
04:c2:a9:7a:df:6d:d4:e3:16:29:b3:74:11:f1:8f:
371+
bd:44:8d:c7:3f:b2:d7:9a:e7:10:14:ff:1c:4a:fa:
372+
ce:fb:c9:7c:c1:e6:57:f2:ff:31:1b:71:8c:6e:3a:
373+
b9:f0:1e:b5:ac:5f:db:2e:81:68:02:cb:be:19:44:
374+
d5:89:3d:30:d6
375+
ASN1 OID: prime256v1
376+
NIST CURVE: P-256
377+
X509v3 extensions:
378+
X509v3 Key Usage: critical
379+
Digital Signature, Certificate Sign, CRL Sign
380+
X509v3 Subject Key Identifier:
381+
19:19:E1:8C:09:E2:5D:5C:16:04:E1:9C:74:66:19:FD:B8:52:5B:DF
382+
Signature Algorithm: ecdsa-with-SHA256
383+
Signature Value:
384+
30:44:02:20:35:fb:3a:0f:95:a5:bf:2d:bc:74:91:f9:f5:0f:
385+
bb:79:34:dc:e7:b5:cb:c4:21:5a:be:4d:10:e1:3e:97:e0:b8:
386+
02:20:54:2e:9c:98:89:3a:11:ec:7a:34:40:64:84:3f:b1:72:
387+
b1:bb:33:a2:d2:29:aa:ab:c1:1d:38:44:fa:62:fb:20
388+
*/
389+
static char kInvalidRootCertificateWithMissingBasicConstraintsExt[] = R"(
390+
-----BEGIN CERTIFICATE-----
391+
MIICkDCCAjegAwIBAgIUPtL5v/hDpYppy49u5ilDo7i+LOEwCgYIKoZIzj0EAwIw
392+
ga0xCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApXYXNoaW5ndG9uMRYwFAYDVQQKDA1B
393+
V1MgTGliY3J5cHRvMQ8wDQYDVQQLDAZCYWQgQ0ExJDAiBgNVBAMMG1JGQyA1Mjgg
394+
NC4yLjEuOSBub3QgcHJlc2VudDE6MDgGA1UEBAwxTVVTVCBOT1QgYmUgdXNlZCB0
395+
byB2ZXJpZnkgY2VydGlmaWNhdGUgc2lnbmF0dXJlczAgFw0xNTAxMDEwMDAwMDBa
396+
GA8yMTAwMDEwMTAwMDAwMFowga0xCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApXYXNo
397+
aW5ndG9uMRYwFAYDVQQKDA1BV1MgTGliY3J5cHRvMQ8wDQYDVQQLDAZCYWQgQ0Ex
398+
JDAiBgNVBAMMG1JGQyA1MjggNC4yLjEuOSBub3QgcHJlc2VudDE6MDgGA1UEBAwx
399+
TVVTVCBOT1QgYmUgdXNlZCB0byB2ZXJpZnkgY2VydGlmaWNhdGUgc2lnbmF0dXJl
400+
czBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABMKpet9t1OMWKbN0EfGPvUSNxz+y
401+
15rnEBT/HEr6zvvJfMHmV/L/MRtxjG46ufAetaxf2y6BaALLvhlE1Yk9MNajMTAv
402+
MA4GA1UdDwEB/wQEAwIBhjAdBgNVHQ4EFgQUGRnhjAniXVwWBOGcdGYZ/bhSW98w
403+
CgYIKoZIzj0EAwIDRwAwRAIgNfs6D5Wlvy28dJH59Q+7eTTc57XLxCFavk0Q4T6X
404+
4LgCIFQunJiJOhHsejRAZIQ/sXKxuzOi0imqq8EdOET6Yvsg
405+
-----END CERTIFICATE-----
406+
)";
407+
408+
/*
409+
This is a bad endpoint certificate that has been signed by
410+
|kInvalidRootCertificateWithMissingBasicConstraintsExt| which is an invalid CA
411+
due to it missing the Basic Constraints extension per RFC 528 4.2.1.9.
412+
413+
Certificate:
414+
Data:
415+
Version: 3 (0x2)
416+
Serial Number:
417+
64:73:40:dd:b0:f3:e9:45:6f:12:bf:f8:76:46:ef:77:f0:8d:02:2a
418+
Signature Algorithm: ecdsa-with-SHA256
419+
Issuer: C = US, ST = Washington, O = AWS Libcrypto, OU = Bad CA, CN = RFC 528 4.2.1.9 not present, SN = MUST NOT be used to verify certificate signatures
420+
Validity
421+
Not Before: Jan 1 00:00:00 2015 GMT
422+
Not After : Jan 1 00:00:00 2100 GMT
423+
Subject: C = US, ST = Washington, O = AWS Libcrypto, OU = Bad Endpoint, CN = RFC 528 4.2.1.9 not present, SN = MUST NOT be used to verify certificate signatures
424+
Subject Public Key Info:
425+
Public Key Algorithm: id-ecPublicKey
426+
Public-Key: (256 bit)
427+
pub:
428+
04:b2:b7:bd:35:f2:eb:da:86:d5:dc:40:44:c7:23:
429+
14:f9:d0:a5:40:17:30:85:b6:c6:11:38:c2:db:2c:
430+
c5:bc:0c:19:11:d8:68:61:d6:a3:92:6b:8a:18:52:
431+
2c:dc:86:a7:ad:29:ad:91:ac:7e:df:87:24:3b:f3:
432+
b4:71:2b:4e:58
433+
ASN1 OID: prime256v1
434+
NIST CURVE: P-256
435+
X509v3 extensions:
436+
X509v3 Key Usage: critical
437+
Digital Signature, Key Encipherment
438+
X509v3 Basic Constraints: critical
439+
CA:FALSE
440+
X509v3 Extended Key Usage:
441+
TLS Web Server Authentication, TLS Web Client Authentication
442+
X509v3 Subject Key Identifier:
443+
C8:78:64:E9:F7:9C:0F:56:E2:1D:CE:EE:ED:24:E0:9F:1D:4B:A3:BF
444+
X509v3 Authority Key Identifier:
445+
19:19:E1:8C:09:E2:5D:5C:16:04:E1:9C:74:66:19:FD:B8:52:5B:DF
446+
Signature Algorithm: ecdsa-with-SHA256
447+
Signature Value:
448+
30:44:02:20:47:a2:ae:cc:22:a1:00:17:00:db:d6:f9:1d:73:
449+
09:c3:d4:cf:4f:f2:e0:2c:e9:3d:14:2f:46:c9:c7:73:c1:dd:
450+
02:20:3f:6a:d3:15:10:f6:38:fe:84:90:06:08:17:f7:cf:37:
451+
b7:9a:a2:6e:b1:ba:38:ba:ca:0f:c0:52:06:10:a5:4c
452+
*/
453+
static char kInvalidEECertificateSignedByRootMissingBasicConstraintsExt[] = R"(
454+
-----BEGIN CERTIFICATE-----
455+
MIIC5DCCAougAwIBAgIUZHNA3bDz6UVvEr/4dkbvd/CNAiowCgYIKoZIzj0EAwIw
456+
ga0xCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApXYXNoaW5ndG9uMRYwFAYDVQQKDA1B
457+
V1MgTGliY3J5cHRvMQ8wDQYDVQQLDAZCYWQgQ0ExJDAiBgNVBAMMG1JGQyA1Mjgg
458+
NC4yLjEuOSBub3QgcHJlc2VudDE6MDgGA1UEBAwxTVVTVCBOT1QgYmUgdXNlZCB0
459+
byB2ZXJpZnkgY2VydGlmaWNhdGUgc2lnbmF0dXJlczAgFw0xNTAxMDEwMDAwMDBa
460+
GA8yMTAwMDEwMTAwMDAwMFowgbMxCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApXYXNo
461+
aW5ndG9uMRYwFAYDVQQKDA1BV1MgTGliY3J5cHRvMRUwEwYDVQQLDAxCYWQgRW5k
462+
cG9pbnQxJDAiBgNVBAMMG1JGQyA1MjggNC4yLjEuOSBub3QgcHJlc2VudDE6MDgG
463+
A1UEBAwxTVVTVCBOT1QgYmUgdXNlZCB0byB2ZXJpZnkgY2VydGlmaWNhdGUgc2ln
464+
bmF0dXJlczBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABLK3vTXy69qG1dxARMcj
465+
FPnQpUAXMIW2xhE4wtssxbwMGRHYaGHWo5JrihhSLNyGp60prZGsft+HJDvztHEr
466+
TlijfzB9MA4GA1UdDwEB/wQEAwIFoDAMBgNVHRMBAf8EAjAAMB0GA1UdJQQWMBQG
467+
CCsGAQUFBwMBBggrBgEFBQcDAjAdBgNVHQ4EFgQUyHhk6fecD1biHc7u7STgnx1L
468+
o78wHwYDVR0jBBgwFoAUGRnhjAniXVwWBOGcdGYZ/bhSW98wCgYIKoZIzj0EAwID
469+
RwAwRAIgR6KuzCKhABcA29b5HXMJw9TPT/LgLOk9FC9Gycdzwd0CID9q0xUQ9jj+
470+
hJAGCBf3zze3mqJusbo4usoPwFIGEKVM
471+
-----END CERTIFICATE-----
472+
)";
473+
474+
/*
475+
This is technically an invalid certificate due to it having a negative serial
476+
number which is not valid per RFC 5280 4.1.2.2: "The serial number MUST be a
477+
positive integer assigned by the CA to each certificate".
478+
479+
Historically OpenSSL 1.1.1 supports negative serial numbers as had other
480+
implementations.
481+
482+
Certificate is signed by |kValidRootCA1|.
483+
484+
Certificate:
485+
Data:
486+
Version: 3 (0x2)
487+
Serial Number: -1337 (-0x539)
488+
Signature Algorithm: ecdsa-with-SHA256
489+
Issuer: C = US, ST = Washington, O = AWS Libcrypto, OU = Good CA, CN = Root CA 1
490+
Validity
491+
Not Before: Jan 1 00:00:00 2015 GMT
492+
Not After : Jan 1 00:00:00 2100 GMT
493+
Subject: C = US, ST = Washington, O = AWS Libcrypto, OU = Bad Endpoint, CN = RFC 5280 serial number MUST be a positive integer
494+
Subject Public Key Info:
495+
Public Key Algorithm: id-ecPublicKey
496+
Public-Key: (256 bit)
497+
pub:
498+
04:b2:b7:bd:35:f2:eb:da:86:d5:dc:40:44:c7:23:
499+
14:f9:d0:a5:40:17:30:85:b6:c6:11:38:c2:db:2c:
500+
c5:bc:0c:19:11:d8:68:61:d6:a3:92:6b:8a:18:52:
501+
2c:dc:86:a7:ad:29:ad:91:ac:7e:df:87:24:3b:f3:
502+
b4:71:2b:4e:58
503+
ASN1 OID: prime256v1
504+
NIST CURVE: P-256
505+
X509v3 extensions:
506+
X509v3 Key Usage: critical
507+
Digital Signature, Key Encipherment
508+
X509v3 Basic Constraints: critical
509+
CA:FALSE
510+
X509v3 Extended Key Usage:
511+
TLS Web Server Authentication, TLS Web Client Authentication
512+
X509v3 Subject Key Identifier:
513+
C8:78:64:E9:F7:9C:0F:56:E2:1D:CE:EE:ED:24:E0:9F:1D:4B:A3:BF
514+
X509v3 Authority Key Identifier:
515+
19:19:E1:8C:09:E2:5D:5C:16:04:E1:9C:74:66:19:FD:B8:52:5B:DF
516+
Signature Algorithm: ecdsa-with-SHA256
517+
Signature Value:
518+
30:45:02:21:00:a1:0d:15:19:11:bc:84:2f:9c:64:ae:c1:89:
519+
c6:37:90:df:c9:36:f0:bf:e5:4f:5b:53:54:48:55:dd:e0:f3:
520+
8c:02:20:21:22:ff:f5:9b:79:55:03:04:86:92:e1:c5:b2:11:
521+
6d:7f:f8:77:23:e4:c0:09:53:c0:01:07:3d:f5:00:77:ec
522+
*/
523+
static char kValidEECertificateWithNegativeSerialNumber[] = R"(
524+
-----BEGIN CERTIFICATE-----
525+
MIICXzCCAgWgAwIBAgIC+scwCgYIKoZIzj0EAwIwYDELMAkGA1UEBhMCVVMxEzAR
526+
BgNVBAgMCldhc2hpbmd0b24xFjAUBgNVBAoMDUFXUyBMaWJjcnlwdG8xEDAOBgNV
527+
BAsMB0dvb2QgQ0ExEjAQBgNVBAMMCVJvb3QgQ0EgMTAgFw0xNTAxMDEwMDAwMDBa
528+
GA8yMTAwMDEwMTAwMDAwMFowgY0xCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApXYXNo
529+
aW5ndG9uMRYwFAYDVQQKDA1BV1MgTGliY3J5cHRvMRUwEwYDVQQLDAxCYWQgRW5k
530+
cG9pbnQxOjA4BgNVBAMMMVJGQyA1MjgwIHNlcmlhbCBudW1iZXIgTVVTVCBiZSBh
531+
IHBvc2l0aXZlIGludGVnZXIwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAASyt701
532+
8uvahtXcQETHIxT50KVAFzCFtsYROMLbLMW8DBkR2Ghh1qOSa4oYUizchqetKa2R
533+
rH7fhyQ787RxK05Yo38wfTAOBgNVHQ8BAf8EBAMCBaAwDAYDVR0TAQH/BAIwADAd
534+
BgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwHQYDVR0OBBYEFMh4ZOn3nA9W
535+
4h3O7u0k4J8dS6O/MB8GA1UdIwQYMBaAFBkZ4YwJ4l1cFgThnHRmGf24UlvfMAoG
536+
CCqGSM49BAMCA0gAMEUCIQChDRUZEbyEL5xkrsGJxjeQ38k28L/lT1tTVEhV3eDz
537+
jAIgISL/9Zt5VQMEhpLhxbIRbX/4dyPkwAlTwAEHPfUAd+w=
538+
-----END CERTIFICATE-----
539+
)";
540+
273541
// EE certificate should not verify if signed by invalid root CA
274542
TEST(X509CompatTest, CertificatesFromTrustStoreValidated) {
275543
bssl::UniquePtr<X509> root = CertFromPEM(kRootBadBasicConstraints);
@@ -283,15 +551,58 @@ TEST(X509CompatTest, CertificatesFromTrustStoreValidated) {
283551
}
284552

285553
// Certificate should be rejected if it contains a critical AKID extension.
286-
// This reports a X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION due to it being an unhandled
287-
// critical exception.
288-
TEST(X509CompatTest, EndpointCertificateWithCriticalAKID) {
554+
// This reports a X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION due to it being an
555+
// unhandled critical exception.
556+
TEST(X509CompatTest, EECertificateWithCriticalAKID) {
289557
bssl::UniquePtr<X509> root = CertFromPEM(kValidRootCA1);
290558
ASSERT_TRUE(root);
291-
bssl::UniquePtr<X509> leaf = CertFromPEM(kInvalidEECertificateWithCriticalAKID);
559+
bssl::UniquePtr<X509> leaf =
560+
CertFromPEM(kInvalidEECertificateWithCriticalAKID);
292561
ASSERT_TRUE(leaf);
293562

294563
EXPECT_EQ(X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION,
295564
Verify(leaf.get(), /*roots=*/{root.get()}, /*intermediates=*/{},
296565
/*crls=*/{}, /*flags=*/0));
297566
}
567+
568+
// Certificate should not be rejected if it contains a critical CRL Distribution
569+
// Points extension.
570+
TEST(X509CompatTest, EECertificateWithCriticalCRLDistributionPointsExt) {
571+
bssl::UniquePtr<X509> root = CertFromPEM(kValidRootCA1);
572+
ASSERT_TRUE(root);
573+
bssl::UniquePtr<X509> leaf =
574+
CertFromPEM(kValidEECertWithCriticalCRLDistributionExt);
575+
ASSERT_TRUE(leaf);
576+
577+
EXPECT_EQ(X509_V_OK,
578+
Verify(leaf.get(), /*roots=*/{root.get()}, /*intermediates=*/{},
579+
/*crls=*/{}, /*flags=*/0));
580+
}
581+
582+
// EE certificate's trust root is missing the basic constraints extension.
583+
TEST(X509CompatTest, EECertificateSignedByInvalidRootMissingBasicConstraints) {
584+
bssl::UniquePtr<X509> root =
585+
CertFromPEM(kInvalidRootCertificateWithMissingBasicConstraintsExt);
586+
ASSERT_TRUE(root);
587+
bssl::UniquePtr<X509> leaf =
588+
CertFromPEM(kInvalidEECertificateSignedByRootMissingBasicConstraintsExt);
589+
ASSERT_TRUE(leaf);
590+
591+
EXPECT_EQ(X509_V_ERR_INVALID_CA,
592+
Verify(leaf.get(), /*roots=*/{root.get()}, /*intermediates=*/{},
593+
/*crls=*/{}, /*flags=*/0));
594+
}
595+
596+
// EE certificate with negative serial number, while technically invalid per RFC
597+
// 5280, should pass.
598+
TEST(X509CompatTest, EECertificateWithNegativeSerialNumber) {
599+
bssl::UniquePtr<X509> root = CertFromPEM(kValidRootCA1);
600+
ASSERT_TRUE(root);
601+
bssl::UniquePtr<X509> leaf =
602+
CertFromPEM(kValidEECertificateWithNegativeSerialNumber);
603+
ASSERT_TRUE(leaf);
604+
605+
EXPECT_EQ(X509_V_OK,
606+
Verify(leaf.get(), /*roots=*/{root.get()}, /*intermediates=*/{},
607+
/*crls=*/{}, /*flags=*/0));
608+
}

0 commit comments

Comments
 (0)