|
51 | 51 | BADCERT = data_file("badcert.pem") |
52 | 52 | WRONGCERT = data_file("XXXnonexisting.pem") |
53 | 53 | BADKEY = data_file("badkey.pem") |
| 54 | +NOKIACERT = data_file("nokia.pem") |
54 | 55 |
|
55 | 56 |
|
56 | 57 | def handle_error(prefix): |
@@ -117,6 +118,31 @@ def test_parse_cert(self): |
117 | 118 | p = ssl._ssl._test_decode_cert(CERTFILE) |
118 | 119 | if support.verbose: |
119 | 120 | sys.stdout.write("\n" + pprint.pformat(p) + "\n") |
| 121 | + self.assertEqual(p['issuer'], |
| 122 | + ((('countryName', 'XY'),), |
| 123 | + (('localityName', 'Castle Anthrax'),), |
| 124 | + (('organizationName', 'Python Software Foundation'),), |
| 125 | + (('commonName', 'localhost'),)) |
| 126 | + ) |
| 127 | + self.assertEqual(p['notAfter'], 'Oct 5 23:01:56 2020 GMT') |
| 128 | + self.assertEqual(p['notBefore'], 'Oct 8 23:01:56 2010 GMT') |
| 129 | + self.assertEqual(p['serialNumber'], 'D7C7381919AFC24E') |
| 130 | + self.assertEqual(p['subject'], |
| 131 | + ((('countryName', 'XY'),), |
| 132 | + (('localityName', 'Castle Anthrax'),), |
| 133 | + (('organizationName', 'Python Software Foundation'),), |
| 134 | + (('commonName', 'localhost'),)) |
| 135 | + ) |
| 136 | + self.assertEqual(p['subjectAltName'], (('DNS', 'localhost'),)) |
| 137 | + # Issue #13034: the subjectAltName in some certificates |
| 138 | + # (notably projects.developer.nokia.com:443) wasn't parsed |
| 139 | + p = ssl._ssl._test_decode_cert(NOKIACERT) |
| 140 | + if support.verbose: |
| 141 | + sys.stdout.write("\n" + pprint.pformat(p) + "\n") |
| 142 | + self.assertEqual(p['subjectAltName'], |
| 143 | + (('DNS', 'projects.developer.nokia.com'), |
| 144 | + ('DNS', 'projects.forum.nokia.com')) |
| 145 | + ) |
120 | 146 |
|
121 | 147 | def test_DER_to_PEM(self): |
122 | 148 | with open(SVN_PYTHON_ORG_ROOT_CERT, 'r') as f: |
|
0 commit comments