Add a TLS test for name constraints with an EE cert without a SAN

It is valid for name constraints to be in force but for there to be no
SAN extension in a certificate. Previous versions of OpenSSL mishandled
this.

Test for CVE-2021-4044

Reviewed-by: Tomas Mraz <tomas@openssl.org>
This commit is contained in:
Matt Caswell 2021-12-03 15:18:27 +00:00
parent 3269c8bd94
commit 752aa4a6f0
3 changed files with 77 additions and 1 deletions

View File

@ -0,0 +1,40 @@
-----BEGIN CERTIFICATE-----
MIIDHTCCAgWgAwIBAgIBAjANBgkqhkiG9w0BAQsFADAXMRUwEwYDVQQDDAxUZXN0
IE5DIENBIDEwIBcNMjExMjAyMTcyNTAyWhgPMjEyMTEyMDMxNzI1MDJaMDwxIzAh
BgNVBAoMGkdvb2QgTkMgVGVzdCBDZXJ0aWZpY2F0ZSAxMRUwEwYDVQQDDAx3d3cu
Z29vZC5vcmcwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDqx1t7HiPe
kRAWdiGUt4pklKGZ7338An6R7/y0e/8Grx2jeUfyc19BAB7MW1p8L+zdMjbclNE0
UZ6RZZNexfgMksNI/nW+4Lzu8qu2wFx1MjbTpMT8w/vnsGBMthxLu6+2wdnpdD1B
0led8xu7PSBgVULqyHcUvoLeRGEsB14yGx7dbIsokYxno1nr4u3BK5ic9KTTSxJR
Ig93qwo2pAZR7mfnOo33B9alhzvSwmEKJ9v7pERDnIP5ED0HaWFAeXl7GFgoH2y9
QDyJVuwWsoSWIx4Mr8UIr0IbVJU6KsqEiqqc5P5rX/y4tYMkpHZd9U1EONd2uwmX
dwSp0LEmQb/DAgMBAAGjTTBLMB0GA1UdDgQWBBSfJPZqs1tk+xjjDrovr13ORDWn
ojAfBgNVHSMEGDAWgBQI0Zv55tVkcKDxaxqe7VLa3fVQQzAJBgNVHRMEAjAAMA0G
CSqGSIb3DQEBCwUAA4IBAQAEKXs56hB4DOO1vJe7pByfCHU33ij/ux7u68BdkDQ8
S9SNaoD7h1XNSmC8kKULvpoKctJzJxh1IH4wtvGG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TAK
hwh/AAAB/////zAKhwjAqAAA//8AADANBgkqhkiG9w0BAQsFAAOCAQEAVyRsB6B8
iCYZxBTOO10Bor+Q4xxgs0udVR90/tM57P8GHd10e8suaW2Dtg9stxZJ3cmsn3zd
+QNxNIQuwHTNtVU0OSqKv6puj6ZQETSya4jDAmRqY47R866MHkSwLUYDMFtuM1Wy
gnoD5m1/Uy1K/Wvbnp1Zq4jtTB6su8TmIdJgtpEmte7tIQu5kPXsuJrz/x5a1TfR
hu7h4LJYwKlQtd/LRINnHKd241YSE7PVdG8SPxyrX11hJSC+1Z5Epxc6BCVDVN1E
fyVDdLXvKf30Nlbg2hZfO/cGTmwOt7RImygzhV/s41v4wtMW0EPuVanGQusRgHFm
3JC//UMgfkkwAA==
-----END CERTIFICATE-----

View File

@ -1,10 +1,11 @@
# Generated with generate_ssl_tests.pl
num_tests = 3
num_tests = 4
test-0 = 0-default
test-1 = 1-Server signature algorithms bug
test-2 = 2-verify-cert
test-3 = 3-name-constraints-no-san-in-ee
# ===========================================================
[0-default]
@ -76,3 +77,26 @@ ExpectedClientAlert = UnknownCA
ExpectedResult = ClientFail
# ===========================================================
[3-name-constraints-no-san-in-ee]
ssl_conf = 3-name-constraints-no-san-in-ee-ssl
[3-name-constraints-no-san-in-ee-ssl]
server = 3-name-constraints-no-san-in-ee-server
client = 3-name-constraints-no-san-in-ee-client
[3-name-constraints-no-san-in-ee-server]
Certificate = ${ENV::TEST_CERTS_DIR}/goodcn2-chain.pem
CipherString = DEFAULT
PrivateKey = ${ENV::TEST_CERTS_DIR}/goodcn2-key.pem
[3-name-constraints-no-san-in-ee-client]
CipherString = DEFAULT
VerifyCAFile = ${ENV::TEST_CERTS_DIR}/root-cert.pem
VerifyMode = Peer
[test-3]
ExpectedResult = Success

View File

@ -39,4 +39,16 @@ our @tests = (
"ExpectedClientAlert" => "UnknownCA",
},
},
{
name => "name-constraints-no-san-in-ee",
server => {
"Certificate" => test_pem("goodcn2-chain.pem"),
"PrivateKey" => test_pem("goodcn2-key.pem"),
},
client => {
"VerifyCAFile" => test_pem("root-cert.pem"),
},
test => { "ExpectedResult" => "Success" },
},
);