|
54 | 54 | BADCERT = data_file("badcert.pem") |
55 | 55 | WRONGCERT = data_file("XXXnonexisting.pem") |
56 | 56 | BADKEY = data_file("badkey.pem") |
| 57 | +NOKIACERT = data_file("nokia.pem") |
57 | 58 |
|
58 | 59 |
|
59 | 60 | def handle_error(prefix): |
@@ -130,6 +131,31 @@ def test_parse_cert(self): |
130 | 131 | p = ssl._ssl._test_decode_cert(CERTFILE) |
131 | 132 | if support.verbose: |
132 | 133 | sys.stdout.write("\n" + pprint.pformat(p) + "\n") |
| 134 | + self.assertEqual(p['issuer'], |
| 135 | + ((('countryName', 'XY'),), |
| 136 | + (('localityName', 'Castle Anthrax'),), |
| 137 | + (('organizationName', 'Python Software Foundation'),), |
| 138 | + (('commonName', 'localhost'),)) |
| 139 | + ) |
| 140 | + self.assertEqual(p['notAfter'], 'Oct 5 23:01:56 2020 GMT') |
| 141 | + self.assertEqual(p['notBefore'], 'Oct 8 23:01:56 2010 GMT') |
| 142 | + self.assertEqual(p['serialNumber'], 'D7C7381919AFC24E') |
| 143 | + self.assertEqual(p['subject'], |
| 144 | + ((('countryName', 'XY'),), |
| 145 | + (('localityName', 'Castle Anthrax'),), |
| 146 | + (('organizationName', 'Python Software Foundation'),), |
| 147 | + (('commonName', 'localhost'),)) |
| 148 | + ) |
| 149 | + self.assertEqual(p['subjectAltName'], (('DNS', 'localhost'),)) |
| 150 | + # Issue #13034: the subjectAltName in some certificates |
| 151 | + # (notably projects.developer.nokia.com:443) wasn't parsed |
| 152 | + p = ssl._ssl._test_decode_cert(NOKIACERT) |
| 153 | + if support.verbose: |
| 154 | + sys.stdout.write("\n" + pprint.pformat(p) + "\n") |
| 155 | + self.assertEqual(p['subjectAltName'], |
| 156 | + (('DNS', 'projects.developer.nokia.com'), |
| 157 | + ('DNS', 'projects.forum.nokia.com')) |
| 158 | + ) |
133 | 159 |
|
134 | 160 | def test_DER_to_PEM(self): |
135 | 161 | with open(SVN_PYTHON_ORG_ROOT_CERT, 'r') as f: |
|
0 commit comments