diff options
author | Christian Heimes <christian@python.org> | 2016-09-06 21:27:06 (GMT) |
---|---|---|
committer | Christian Heimes <christian@python.org> | 2016-09-06 21:27:06 (GMT) |
commit | fe3c9c1ee9d59f0b1d174210132e71037fd7f2e8 (patch) | |
tree | 850214f33ff477feeac47de3990ae6c11dd7f37b /Lib/test/test_ssl.py | |
parent | 87bf0febcb59a389eb62bcb467b7ec9c4974be49 (diff) | |
parent | 1c03abd0262f658fc420d3bef6118e49044b9d8b (diff) | |
download | cpython-fe3c9c1ee9d59f0b1d174210132e71037fd7f2e8.zip cpython-fe3c9c1ee9d59f0b1d174210132e71037fd7f2e8.tar.gz cpython-fe3c9c1ee9d59f0b1d174210132e71037fd7f2e8.tar.bz2 |
Issue #27691: Fix ssl module's parsing of GEN_RID subject alternative name fields in X.509 certs.
Diffstat (limited to 'Lib/test/test_ssl.py')
-rw-r--r-- | Lib/test/test_ssl.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py index 4e0e4a2..d8d53af 100644 --- a/Lib/test/test_ssl.py +++ b/Lib/test/test_ssl.py @@ -65,6 +65,8 @@ SIGNED_CERTFILE = data_file("keycert3.pem") SIGNED_CERTFILE2 = data_file("keycert4.pem") # Same certificate as pycacert.pem, but without extra text in file SIGNING_CA = data_file("capath", "ceff1710.0") +# cert with all kinds of subject alt names +ALLSANFILE = data_file("allsans.pem") REMOTE_HOST = "self-signed.pythontest.net" @@ -286,6 +288,27 @@ class BasicSocketTests(unittest.TestCase): self.assertEqual(p['subjectAltName'], san) + def test_parse_all_sans(self): + p = ssl._ssl._test_decode_cert(ALLSANFILE) + self.assertEqual(p['subjectAltName'], + ( + ('DNS', 'allsans'), + ('othername', '<unsupported>'), + ('othername', '<unsupported>'), + ('email', 'user@example.org'), + ('DNS', 'www.example.org'), + ('DirName', + ((('countryName', 'XY'),), + (('localityName', 'Castle Anthrax'),), + (('organizationName', 'Python Software Foundation'),), + (('commonName', 'dirname example'),))), + ('URI', 'https://www.python.org/'), + ('IP Address', '127.0.0.1'), + ('IP Address', '0:0:0:0:0:0:0:1\n'), + ('Registered ID', '1.2.3.4.5') + ) + ) + def test_DER_to_PEM(self): with open(CAFILE_CACERT, 'r') as f: pem = f.read() |