summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2011-10-01 17:22:30 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2011-10-01 17:22:30 (GMT)
commita02a12c517e69e457f4425aa5af6f55c36a6a39a (patch)
treed509c4f1e8216f73da9c32b6a4f4c466a84481ca
parent07ac3ebd7ba6b42ba1adb07ec6075eb916d167b1 (diff)
parentd8c347a8de9d7b76d0980ac18511667ab1cb2a4f (diff)
downloadcpython-a02a12c517e69e457f4425aa5af6f55c36a6a39a.zip
cpython-a02a12c517e69e457f4425aa5af6f55c36a6a39a.tar.gz
cpython-a02a12c517e69e457f4425aa5af6f55c36a6a39a.tar.bz2
Issue #13034: When decoding some SSL certificates, the subjectAltName extension could be unreported.
-rw-r--r--Lib/test/nokia.pem31
-rw-r--r--Lib/test/test_ssl.py26
-rw-r--r--Misc/NEWS3
-rw-r--r--Modules/_ssl.c2
4 files changed, 61 insertions, 1 deletions
diff --git a/Lib/test/nokia.pem b/Lib/test/nokia.pem
new file mode 100644
index 0000000..0d044df
--- /dev/null
+++ b/Lib/test/nokia.pem
@@ -0,0 +1,31 @@
+# Certificate for projects.developer.nokia.com:443 (see issue 13034)
+-----BEGIN CERTIFICATE-----
+MIIFLDCCBBSgAwIBAgIQLubqdkCgdc7lAF9NfHlUmjANBgkqhkiG9w0BAQUFADCB
+vDELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQL
+ExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTswOQYDVQQLEzJUZXJtcyBvZiB1c2Ug
+YXQgaHR0cHM6Ly93d3cudmVyaXNpZ24uY29tL3JwYSAoYykxMDE2MDQGA1UEAxMt
+VmVyaVNpZ24gQ2xhc3MgMyBJbnRlcm5hdGlvbmFsIFNlcnZlciBDQSAtIEczMB4X
+DTExMDkyMTAwMDAwMFoXDTEyMDkyMDIzNTk1OVowcTELMAkGA1UEBh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DQYJ
+KoZIhvcNAQEFBQADggEBACQuPyIJqXwUyFRWw9x5yDXgMW4zYFopQYOw/ItRY522
+O5BsySTh56BWS6mQB07XVfxmYUGAvRQDA5QHpmY8jIlNwSmN3s8RKo+fAtiNRlcL
+x/mWSfuMs3D/S6ev3D6+dpEMZtjrhOdctsarMKp8n/hPbwhAbg5hVjpkW5n8vz2y
+0KxvvkA1AxpLwpVv7OlK17ttzIHw8bp9HTlHBU5s8bKz4a565V/a5HI0CSEv/+0y
+ko4/ghTnZc1CkmUngKKeFMSah/mT/xAh8XnE2l1AazFa8UKuYki1e+ArHaGZc4ix
+UYOtiRphwfuYQhRZ7qX9q2MMkCMI65XNK/SaFrAbbG0=
+-----END CERTIFICATE-----
diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py
index e386325..25f3e4f 100644
--- a/Lib/test/test_ssl.py
+++ b/Lib/test/test_ssl.py
@@ -54,6 +54,7 @@ EMPTYCERT = data_file("nullcert.pem")
BADCERT = data_file("badcert.pem")
WRONGCERT = data_file("XXXnonexisting.pem")
BADKEY = data_file("badkey.pem")
+NOKIACERT = data_file("nokia.pem")
def handle_error(prefix):
@@ -130,6 +131,31 @@ class BasicSocketTests(unittest.TestCase):
p = ssl._ssl._test_decode_cert(CERTFILE)
if support.verbose:
sys.stdout.write("\n" + pprint.pformat(p) + "\n")
+ self.assertEqual(p['issuer'],
+ ((('countryName', 'XY'),),
+ (('localityName', 'Castle Anthrax'),),
+ (('organizationName', 'Python Software Foundation'),),
+ (('commonName', 'localhost'),))
+ )
+ self.assertEqual(p['notAfter'], 'Oct 5 23:01:56 2020 GMT')
+ self.assertEqual(p['notBefore'], 'Oct 8 23:01:56 2010 GMT')
+ self.assertEqual(p['serialNumber'], 'D7C7381919AFC24E')
+ self.assertEqual(p['subject'],
+ ((('countryName', 'XY'),),
+ (('localityName', 'Castle Anthrax'),),
+ (('organizationName', 'Python Software Foundation'),),
+ (('commonName', 'localhost'),))
+ )
+ self.assertEqual(p['subjectAltName'], (('DNS', 'localhost'),))
+ # Issue #13034: the subjectAltName in some certificates
+ # (notably projects.developer.nokia.com:443) wasn't parsed
+ p = ssl._ssl._test_decode_cert(NOKIACERT)
+ if support.verbose:
+ sys.stdout.write("\n" + pprint.pformat(p) + "\n")
+ self.assertEqual(p['subjectAltName'],
+ (('DNS', 'projects.developer.nokia.com'),
+ ('DNS', 'projects.forum.nokia.com'))
+ )
def test_DER_to_PEM(self):
with open(SVN_PYTHON_ORG_ROOT_CERT, 'r') as f:
diff --git a/Misc/NEWS b/Misc/NEWS
index 3d6b317..e07e3a7 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -294,6 +294,9 @@ Core and Builtins
Library
-------
+- Issue #13034: When decoding some SSL certificates, the subjectAltName
+ extension could be unreported.
+
- Issue #9871: Prevent IDLE 3 crash when given byte stings
with invalid hex escape sequences, like b'\x0'.
(Original patch by Claudiu Popa.)
diff --git a/Modules/_ssl.c b/Modules/_ssl.c
index 3d44b61..7fee74c 100644
--- a/Modules/_ssl.c
+++ b/Modules/_ssl.c
@@ -595,7 +595,7 @@ _get_peer_alt_names (X509 *certificate) {
/* get a memory buffer */
biobuf = BIO_new(BIO_s_mem());
- i = 0;
+ i = -1;
while ((i = X509_get_ext_by_NID(
certificate, NID_subject_alt_name, i)) >= 0) {