wbond | e91513e | 2015-06-03 14:52:18 -0400 | [diff] [blame] | 1 | # coding: utf-8 |
| 2 | from __future__ import unicode_literals |
| 3 | |
| 4 | import unittest |
| 5 | import sys |
| 6 | import os |
| 7 | from collections import OrderedDict |
| 8 | from datetime import datetime |
| 9 | |
wbond | af1f5a8 | 2015-07-17 12:13:15 -0400 | [diff] [blame] | 10 | from asn1crypto import x509, core, pem |
| 11 | |
| 12 | from .unittest_data import DataDecorator, data |
wbond | e91513e | 2015-06-03 14:52:18 -0400 | [diff] [blame] | 13 | |
| 14 | if sys.version_info < (3,): |
| 15 | byte_cls = str |
| 16 | else: |
| 17 | byte_cls = bytes |
| 18 | |
| 19 | |
| 20 | tests_root = os.path.dirname(__file__) |
| 21 | fixtures_dir = os.path.join(tests_root, 'fixtures') |
| 22 | |
| 23 | |
wbond | af1f5a8 | 2015-07-17 12:13:15 -0400 | [diff] [blame] | 24 | @DataDecorator |
wbond | e91513e | 2015-06-03 14:52:18 -0400 | [diff] [blame] | 25 | class X509Tests(unittest.TestCase): |
| 26 | |
wbond | af1f5a8 | 2015-07-17 12:13:15 -0400 | [diff] [blame] | 27 | def _load_cert(self, relative_path): |
| 28 | with open(os.path.join(fixtures_dir, relative_path), 'rb') as f: |
| 29 | cert_bytes = f.read() |
| 30 | if pem.detect(cert_bytes): |
| 31 | _, _, cert_bytes = pem.unarmor(cert_bytes) |
| 32 | return x509.Certificate.load(cert_bytes) |
wbond | 8bb77d0 | 2015-07-13 17:44:29 -0400 | [diff] [blame] | 33 | |
wbond | af1f5a8 | 2015-07-17 12:13:15 -0400 | [diff] [blame] | 34 | #pylint: disable=C0326 |
| 35 | @staticmethod |
wbond | f464572 | 2015-07-22 12:36:37 -0400 | [diff] [blame^] | 36 | def ip_address_info(): |
| 37 | return ( |
| 38 | ('127.0.0.1', b'\x04\x04\x7F\x00\x00\x01'), |
| 39 | ('255.255.255.255', b'\x04\x04\xFF\xFF\xFF\xFF'), |
| 40 | ('127.0.0.1/28', b'\x04\x08\x7F\x00\x00\x01\xFF\xFF\xFF\xF0'), |
| 41 | ('255.255.255.255/0', b'\x04\x08\xFF\xFF\xFF\xFF\x00\x00\x00\x00'), |
| 42 | ('af::ed', b'\x04\x10\x00\xAF\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xED'), |
| 43 | ('af::ed/128', b'\x04\x20\x00\xAF\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xED\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF'), |
| 44 | ('af::ed/0', b'\x04\x20\x00\xAF\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xED\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'), |
| 45 | ) |
| 46 | |
| 47 | @data('ip_address_info') |
| 48 | def ip_address(self, unicode_string, der_bytes): |
| 49 | self.assertEqual(der_bytes, x509.IPAddress(unicode_string).dump()) |
| 50 | self.assertEqual(unicode_string, x509.IPAddress.load(der_bytes).native) |
| 51 | |
| 52 | #pylint: disable=C0326 |
| 53 | @staticmethod |
wbond | 1cfca23 | 2015-07-20 08:51:58 -0400 | [diff] [blame] | 54 | def signature_algo_info(): |
| 55 | return ( |
| 56 | ('keys/test-der.crt', 'rsassa_pkcs1v15', 'sha256'), |
| 57 | ('keys/test-inter-der.crt', 'rsassa_pkcs1v15', 'sha256'), |
| 58 | ('keys/test-dsa-der.crt', 'dsa', 'sha256'), |
| 59 | ('keys/test-third-der.crt', 'rsassa_pkcs1v15', 'sha256'), |
| 60 | ('keys/test-ec-der.crt', 'ecdsa', 'sha256'), |
| 61 | ) |
| 62 | |
| 63 | @data('signature_algo_info') |
| 64 | def signature_algo(self, relative_path, signature_algo, hash_algo): |
| 65 | cert = self._load_cert(relative_path) |
| 66 | self.assertEqual(signature_algo, cert['signature_algorithm'].signature_algo) |
| 67 | self.assertEqual(hash_algo, cert['signature_algorithm'].hash_algo) |
| 68 | |
| 69 | #pylint: disable=C0326 |
| 70 | @staticmethod |
wbond | af1f5a8 | 2015-07-17 12:13:15 -0400 | [diff] [blame] | 71 | def critical_extensions_info(): |
| 72 | return ( |
| 73 | ('keys/test-der.crt', []), |
| 74 | ('keys/test-inter-der.crt', []), |
| 75 | ('keys/test-third-der.crt', []), |
| 76 | ('geotrust_certs/GeoTrust_Universal_CA.crt', ['basic_constraints', 'key_usage']), |
| 77 | ('geotrust_certs/GeoTrust_Primary_CA.crt', ['basic_constraints', 'key_usage']), |
| 78 | ('geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt', ['basic_constraints', 'key_usage']), |
| 79 | ('geotrust_certs/codex.crt', ['key_usage']), |
| 80 | ('lets_encrypt/isrgrootx1.pem', ['key_usage', 'basic_constraints']), |
| 81 | ('lets_encrypt/letsencryptauthorityx1.pem', ['key_usage', 'basic_constraints']), |
| 82 | ('lets_encrypt/letsencryptauthorityx2.pem', ['key_usage', 'basic_constraints']), |
| 83 | ('globalsign_example_keys/IssuingCA-der.cer', ['basic_constraints', 'key_usage']), |
| 84 | ('globalsign_example_keys/rootCA.cer', ['basic_constraints', 'key_usage']), |
| 85 | ('globalsign_example_keys/SSL1.cer', ['key_usage', 'extended_key_usage', 'basic_constraints']), |
| 86 | ('globalsign_example_keys/SSL2.cer', ['key_usage', 'extended_key_usage', 'basic_constraints']), |
| 87 | ('globalsign_example_keys/SSL3.cer', ['key_usage', 'extended_key_usage', 'basic_constraints']), |
wbond | 8bb77d0 | 2015-07-13 17:44:29 -0400 | [diff] [blame] | 88 | ) |
wbond | af1f5a8 | 2015-07-17 12:13:15 -0400 | [diff] [blame] | 89 | |
| 90 | @data('critical_extensions_info') |
| 91 | def critical_extensions(self, relative_path, critical_extensions): |
| 92 | cert = self._load_cert(relative_path) |
| 93 | self.assertEqual(critical_extensions, cert.critical_extensions) |
| 94 | |
| 95 | #pylint: disable=C0326 |
| 96 | @staticmethod |
| 97 | def key_identifier_value_info(): |
| 98 | return ( |
| 99 | ('keys/test-der.crt', b'\xbeB\x85=\xcc\xff\xe3\xf9(\x02\x8f~XV\xb4\xfd\x03\\\xeaK'), |
| 100 | ('keys/test-inter-der.crt', b'\xd2\n\xfd.%\xd1\xb7!\xd7P~\xbb\xa4}\xbf4\xefR^\x02'), |
| 101 | ('keys/test-third-der.crt', b'D8\xe0\xe0&\x85\xbf\x98\x86\xdc\x1b\xe1\x1d\xf520\xbe\xab\xac\r'), |
| 102 | ('geotrust_certs/GeoTrust_Universal_CA.crt', b'\xda\xbb.\xaa\xb0\x0c\xb8\x88&Qt\\m\x03\xd3\xc0\xd8\x8fz\xd6'), |
| 103 | ('geotrust_certs/GeoTrust_Primary_CA.crt', b',\xd5PA\x97\x15\x8b\xf0\x8f6a[J\xfbk\xd9\x99\xc93\x92'), |
| 104 | ('geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt', b'\xde\xcf\\P\xb7\xae\x02\x1f\x15\x17\xaa\x16\xe8\r\xb5(\x9djZ\xf3'), |
| 105 | ('geotrust_certs/codex.crt', None), |
| 106 | ('lets_encrypt/isrgrootx1.pem', b'y\xb4Y\xe6{\xb6\xe5\xe4\x01s\x80\x08\x88\xc8\x1aX\xf6\xe9\x9bn'), |
| 107 | ('lets_encrypt/letsencryptauthorityx1.pem', b'\xa8Jjc\x04}\xdd\xba\xe6\xd19\xb7\xa6Ee\xef\xf3\xa8\xec\xa1'), |
| 108 | ('lets_encrypt/letsencryptauthorityx2.pem', b'\xc5\xb1\xabNL\xb1\xcdd0\x93~\xc1\x84\x99\x05\xab\xe6\x03\xe2%'), |
| 109 | ('globalsign_example_keys/IssuingCA-der.cer', b"'\xf8/\xe9]\xd7\r\xf4\xa8\xea\x87\x99=\xfd\x8e\xb3\x9e@\xd0\x91"), |
| 110 | ('globalsign_example_keys/rootCA.cer', b'd|\\\xe1\xe0`8NH\x9f\x05\xbcUc~?\xaeM\xf7\x1e'), |
| 111 | ('globalsign_example_keys/SSL1.cer', b'\x94a\x04\x92\x04L\xe6\xffh\xa8\x96\xafy\xd2\xf32\x84\xae[\xcf'), |
| 112 | ('globalsign_example_keys/SSL2.cer', b'\xd2\xb7\x15\x7fd0\x07(p\x83\xca(\xfa\x88\x96\xde\x9e\xfc\x8a='), |
| 113 | ('globalsign_example_keys/SSL3.cer', b'G\xde\xa4\xe7\xea`\xe7\xee6\xc8\xf1\xd5\xb0F\x07\x07\x9eBh\xce'), |
wbond | 8bb77d0 | 2015-07-13 17:44:29 -0400 | [diff] [blame] | 114 | ) |
wbond | 8bb77d0 | 2015-07-13 17:44:29 -0400 | [diff] [blame] | 115 | |
wbond | af1f5a8 | 2015-07-17 12:13:15 -0400 | [diff] [blame] | 116 | @data('key_identifier_value_info') |
| 117 | def key_identifier_value(self, relative_path, key_identifier_value): |
| 118 | cert = self._load_cert(relative_path) |
| 119 | value = cert.key_identifier_value |
| 120 | self.assertEqual(key_identifier_value, value.native if value else None) |
wbond | 8bb77d0 | 2015-07-13 17:44:29 -0400 | [diff] [blame] | 121 | |
wbond | af1f5a8 | 2015-07-17 12:13:15 -0400 | [diff] [blame] | 122 | #pylint: disable=C0326 |
| 123 | @staticmethod |
| 124 | def key_usage_value_info(): |
| 125 | return ( |
| 126 | ('keys/test-der.crt', None), |
| 127 | ('keys/test-inter-der.crt', None), |
| 128 | ('keys/test-third-der.crt', None), |
| 129 | ( |
| 130 | 'geotrust_certs/GeoTrust_Universal_CA.crt', |
wbond | 8bb77d0 | 2015-07-13 17:44:29 -0400 | [diff] [blame] | 131 | OrderedDict([ |
wbond | af1f5a8 | 2015-07-17 12:13:15 -0400 | [diff] [blame] | 132 | ('digital_signature', True), |
| 133 | ('non_repudiation', False), |
| 134 | ('key_encipherment', False), |
| 135 | ('data_encipherment', False), |
| 136 | ('key_agreement', False), |
| 137 | ('key_cert_sign', True), |
| 138 | ('crl_sign', True), |
| 139 | ('encipher_only', False), |
| 140 | ('decipher_only', False), |
wbond | 8bb77d0 | 2015-07-13 17:44:29 -0400 | [diff] [blame] | 141 | ]) |
wbond | af1f5a8 | 2015-07-17 12:13:15 -0400 | [diff] [blame] | 142 | ), |
| 143 | ( |
| 144 | 'geotrust_certs/GeoTrust_Primary_CA.crt', |
wbond | 8bb77d0 | 2015-07-13 17:44:29 -0400 | [diff] [blame] | 145 | OrderedDict([ |
wbond | af1f5a8 | 2015-07-17 12:13:15 -0400 | [diff] [blame] | 146 | ('digital_signature', True), |
| 147 | ('non_repudiation', True), |
| 148 | ('key_encipherment', False), |
| 149 | ('data_encipherment', False), |
| 150 | ('key_agreement', False), |
| 151 | ('key_cert_sign', False), |
| 152 | ('crl_sign', False), |
| 153 | ('encipher_only', False), |
| 154 | ('decipher_only', False), |
wbond | 8bb77d0 | 2015-07-13 17:44:29 -0400 | [diff] [blame] | 155 | ]) |
wbond | af1f5a8 | 2015-07-17 12:13:15 -0400 | [diff] [blame] | 156 | ), |
| 157 | ( |
| 158 | 'geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt', |
wbond | 8bb77d0 | 2015-07-13 17:44:29 -0400 | [diff] [blame] | 159 | OrderedDict([ |
wbond | af1f5a8 | 2015-07-17 12:13:15 -0400 | [diff] [blame] | 160 | ('digital_signature', True), |
| 161 | ('non_repudiation', True), |
| 162 | ('key_encipherment', False), |
| 163 | ('data_encipherment', False), |
| 164 | ('key_agreement', False), |
| 165 | ('key_cert_sign', False), |
| 166 | ('crl_sign', False), |
| 167 | ('encipher_only', False), |
| 168 | ('decipher_only', False), |
| 169 | ]) |
| 170 | ), |
| 171 | ( |
| 172 | 'geotrust_certs/codex.crt', |
| 173 | OrderedDict([ |
| 174 | ('digital_signature', True), |
| 175 | ('non_repudiation', False), |
| 176 | ('key_encipherment', True), |
| 177 | ('data_encipherment', False), |
| 178 | ('key_agreement', False), |
| 179 | ('key_cert_sign', False), |
| 180 | ('crl_sign', False), |
| 181 | ('encipher_only', False), |
| 182 | ('decipher_only', False), |
| 183 | ]) |
| 184 | ), |
| 185 | ( |
| 186 | 'lets_encrypt/isrgrootx1.pem', |
| 187 | OrderedDict([ |
| 188 | ('digital_signature', True), |
| 189 | ('non_repudiation', True), |
| 190 | ('key_encipherment', False), |
| 191 | ('data_encipherment', False), |
| 192 | ('key_agreement', False), |
| 193 | ('key_cert_sign', False), |
| 194 | ('crl_sign', False), |
| 195 | ('encipher_only', False), |
| 196 | ('decipher_only', False), |
| 197 | ]) |
| 198 | ), |
| 199 | ( |
| 200 | 'lets_encrypt/letsencryptauthorityx1.pem', |
| 201 | OrderedDict([ |
| 202 | ('digital_signature', True), |
| 203 | ('non_repudiation', False), |
| 204 | ('key_encipherment', False), |
| 205 | ('data_encipherment', False), |
| 206 | ('key_agreement', False), |
| 207 | ('key_cert_sign', True), |
| 208 | ('crl_sign', True), |
| 209 | ('encipher_only', False), |
| 210 | ('decipher_only', False), |
| 211 | ]) |
| 212 | ), |
| 213 | ( |
| 214 | 'lets_encrypt/letsencryptauthorityx2.pem', |
| 215 | OrderedDict([ |
| 216 | ('digital_signature', True), |
| 217 | ('non_repudiation', False), |
| 218 | ('key_encipherment', False), |
| 219 | ('data_encipherment', False), |
| 220 | ('key_agreement', False), |
| 221 | ('key_cert_sign', True), |
| 222 | ('crl_sign', True), |
| 223 | ('encipher_only', False), |
| 224 | ('decipher_only', False), |
| 225 | ]) |
| 226 | ), |
| 227 | ( |
| 228 | 'globalsign_example_keys/IssuingCA-der.cer', |
| 229 | OrderedDict([ |
| 230 | ('digital_signature', True), |
| 231 | ('non_repudiation', True), |
| 232 | ('key_encipherment', False), |
| 233 | ('data_encipherment', False), |
| 234 | ('key_agreement', False), |
| 235 | ('key_cert_sign', False), |
| 236 | ('crl_sign', False), |
| 237 | ('encipher_only', False), |
| 238 | ('decipher_only', False), |
| 239 | ]) |
| 240 | ), |
| 241 | ( |
| 242 | 'globalsign_example_keys/rootCA.cer', |
| 243 | OrderedDict([ |
| 244 | ('digital_signature', True), |
| 245 | ('non_repudiation', True), |
| 246 | ('key_encipherment', False), |
| 247 | ('data_encipherment', False), |
| 248 | ('key_agreement', False), |
| 249 | ('key_cert_sign', False), |
| 250 | ('crl_sign', False), |
| 251 | ('encipher_only', False), |
| 252 | ('decipher_only', False), |
| 253 | ]) |
| 254 | ), |
| 255 | ( |
| 256 | 'globalsign_example_keys/SSL1.cer', |
| 257 | OrderedDict([ |
| 258 | ('digital_signature', True), |
| 259 | ('non_repudiation', False), |
| 260 | ('key_encipherment', True), |
| 261 | ('data_encipherment', False), |
| 262 | ('key_agreement', False), |
| 263 | ('key_cert_sign', False), |
| 264 | ('crl_sign', False), |
| 265 | ('encipher_only', False), |
| 266 | ('decipher_only', False), |
| 267 | ]) |
| 268 | ), |
| 269 | ( |
| 270 | 'globalsign_example_keys/SSL2.cer', |
| 271 | OrderedDict([ |
| 272 | ('digital_signature', True), |
| 273 | ('non_repudiation', False), |
| 274 | ('key_encipherment', True), |
| 275 | ('data_encipherment', False), |
| 276 | ('key_agreement', False), |
| 277 | ('key_cert_sign', False), |
| 278 | ('crl_sign', False), |
| 279 | ('encipher_only', False), |
| 280 | ('decipher_only', False), |
| 281 | ]) |
| 282 | ), |
| 283 | ( |
| 284 | 'globalsign_example_keys/SSL3.cer', |
| 285 | OrderedDict([ |
| 286 | ('digital_signature', True), |
| 287 | ('non_repudiation', False), |
| 288 | ('key_encipherment', True), |
| 289 | ('data_encipherment', False), |
| 290 | ('key_agreement', False), |
| 291 | ('key_cert_sign', False), |
| 292 | ('crl_sign', False), |
| 293 | ('encipher_only', False), |
| 294 | ('decipher_only', False), |
| 295 | ]) |
| 296 | ), |
| 297 | ) |
| 298 | |
| 299 | @data('key_usage_value_info') |
| 300 | def key_usage_value(self, relative_path, key_usage_value): |
| 301 | cert = self._load_cert(relative_path) |
| 302 | value = cert.key_usage_value |
| 303 | self.assertEqual(key_usage_value, value.native if value else None) |
| 304 | |
| 305 | #pylint: disable=C0326 |
| 306 | @staticmethod |
| 307 | def subject_alt_name_value_info(): |
| 308 | return ( |
| 309 | ('keys/test-der.crt', None), |
| 310 | ('keys/test-inter-der.crt', None), |
| 311 | ('keys/test-third-der.crt', None), |
| 312 | ('geotrust_certs/GeoTrust_Universal_CA.crt', None), |
| 313 | ('geotrust_certs/GeoTrust_Primary_CA.crt', None), |
| 314 | ('geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt', [OrderedDict([('common_name', 'SymantecPKI-1-538')])]), |
| 315 | ('geotrust_certs/codex.crt', ['dev.codexns.io', 'rc.codexns.io', 'packagecontrol.io', 'wbond.net', 'codexns.io']), |
| 316 | ('lets_encrypt/isrgrootx1.pem', None), |
| 317 | ('lets_encrypt/letsencryptauthorityx1.pem', None), |
| 318 | ('lets_encrypt/letsencryptauthorityx2.pem', None), |
| 319 | ('globalsign_example_keys/IssuingCA-der.cer', None), |
| 320 | ('globalsign_example_keys/rootCA.cer', None), |
| 321 | ('globalsign_example_keys/SSL1.cer', ['anything.example.com']), |
| 322 | ('globalsign_example_keys/SSL2.cer', ['anything.example.com']), |
| 323 | ('globalsign_example_keys/SSL3.cer', None), |
| 324 | ) |
| 325 | |
| 326 | @data('subject_alt_name_value_info') |
| 327 | def subject_alt_name_value(self, relative_path, subject_alt_name_value): |
| 328 | cert = self._load_cert(relative_path) |
| 329 | value = cert.subject_alt_name_value |
| 330 | self.assertEqual(subject_alt_name_value, value.native if value else None) |
| 331 | |
| 332 | #pylint: disable=C0326 |
| 333 | @staticmethod |
| 334 | def basic_constraints_value_info(): |
| 335 | return ( |
| 336 | ('keys/test-der.crt', {'ca': True, 'path_len_constraint': None}), |
| 337 | ('keys/test-inter-der.crt', {'ca': True, 'path_len_constraint': None}), |
| 338 | ('keys/test-third-der.crt', None), |
| 339 | ('geotrust_certs/GeoTrust_Universal_CA.crt', {'ca': True, 'path_len_constraint': None}), |
| 340 | ('geotrust_certs/GeoTrust_Primary_CA.crt', {'ca': True, 'path_len_constraint': None}), |
| 341 | ('geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt', {'ca': True, 'path_len_constraint': 0}), |
| 342 | ('geotrust_certs/codex.crt', {'ca': False, 'path_len_constraint': None}), |
| 343 | ('lets_encrypt/isrgrootx1.pem', {'ca': True, 'path_len_constraint': None}), |
| 344 | ('lets_encrypt/letsencryptauthorityx1.pem', {'ca': True, 'path_len_constraint': 0}), |
| 345 | ('lets_encrypt/letsencryptauthorityx2.pem', {'ca': True, 'path_len_constraint': 0}), |
| 346 | ('globalsign_example_keys/IssuingCA-der.cer', {'ca': True, 'path_len_constraint': None}), |
| 347 | ('globalsign_example_keys/rootCA.cer', {'ca': True, 'path_len_constraint': None}), |
| 348 | ('globalsign_example_keys/SSL1.cer', {'ca': False, 'path_len_constraint': None}), |
| 349 | ('globalsign_example_keys/SSL2.cer', {'ca': False, 'path_len_constraint': None}), |
| 350 | ('globalsign_example_keys/SSL3.cer', {'ca': False, 'path_len_constraint': None}), |
| 351 | ) |
| 352 | |
| 353 | @data('basic_constraints_value_info') |
| 354 | def basic_constraints_value(self, relative_path, basic_constraints_value): |
| 355 | cert = self._load_cert(relative_path) |
| 356 | value = cert.basic_constraints_value |
| 357 | self.assertEqual(basic_constraints_value, value.native if value else None) |
| 358 | |
| 359 | #pylint: disable=C0326 |
| 360 | @staticmethod |
| 361 | def name_constraints_value_info(): |
| 362 | return ( |
| 363 | ('keys/test-der.crt', None), |
| 364 | ('keys/test-inter-der.crt', None), |
| 365 | ('keys/test-third-der.crt', None), |
| 366 | ('geotrust_certs/GeoTrust_Universal_CA.crt', None), |
| 367 | ('geotrust_certs/GeoTrust_Primary_CA.crt', None), |
| 368 | ('geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt', None), |
| 369 | ('geotrust_certs/codex.crt', None), |
| 370 | ('lets_encrypt/isrgrootx1.pem', None), |
| 371 | ('lets_encrypt/letsencryptauthorityx1.pem', None), |
| 372 | ('lets_encrypt/letsencryptauthorityx2.pem', None), |
| 373 | ( |
| 374 | 'globalsign_example_keys/IssuingCA-der.cer', |
| 375 | OrderedDict([ |
wbond | 8bb77d0 | 2015-07-13 17:44:29 -0400 | [diff] [blame] | 376 | ( |
wbond | af1f5a8 | 2015-07-17 12:13:15 -0400 | [diff] [blame] | 377 | 'permitted_subtrees', |
wbond | 8bb77d0 | 2015-07-13 17:44:29 -0400 | [diff] [blame] | 378 | [ |
| 379 | OrderedDict([ |
wbond | af1f5a8 | 2015-07-17 12:13:15 -0400 | [diff] [blame] | 380 | ('base', 'onlythis.com'), |
| 381 | ('minimum', 0), |
| 382 | ('maximum', None) |
| 383 | ]), |
| 384 | OrderedDict([ |
| 385 | ( |
| 386 | 'base', |
| 387 | OrderedDict([ |
| 388 | ('country_name', 'US'), |
| 389 | ('state_or_province_name', 'MA'), |
| 390 | ('locality_name', 'Boston'), |
| 391 | ('organization_name', 'Example LLC') |
| 392 | ]) |
| 393 | ), |
| 394 | ('minimum', 0), |
| 395 | ('maximum', None) |
wbond | 8bb77d0 | 2015-07-13 17:44:29 -0400 | [diff] [blame] | 396 | ]) |
| 397 | ] |
wbond | af1f5a8 | 2015-07-17 12:13:15 -0400 | [diff] [blame] | 398 | ), |
| 399 | ( |
| 400 | 'excluded_subtrees', |
| 401 | [ |
| 402 | OrderedDict([ |
wbond | f464572 | 2015-07-22 12:36:37 -0400 | [diff] [blame^] | 403 | ('base', '0.0.0.0/0'), |
wbond | af1f5a8 | 2015-07-17 12:13:15 -0400 | [diff] [blame] | 404 | ('minimum', 0), |
| 405 | ('maximum', None) |
| 406 | ]), |
| 407 | OrderedDict([ |
wbond | f464572 | 2015-07-22 12:36:37 -0400 | [diff] [blame^] | 408 | ('base', '::/0'), |
wbond | af1f5a8 | 2015-07-17 12:13:15 -0400 | [diff] [blame] | 409 | ('minimum', 0), |
| 410 | ('maximum', None) |
| 411 | ]) |
| 412 | ] |
| 413 | ), |
wbond | 8bb77d0 | 2015-07-13 17:44:29 -0400 | [diff] [blame] | 414 | ]) |
wbond | af1f5a8 | 2015-07-17 12:13:15 -0400 | [diff] [blame] | 415 | ), |
| 416 | ('globalsign_example_keys/rootCA.cer', None), |
| 417 | ('globalsign_example_keys/SSL1.cer', None), |
| 418 | ('globalsign_example_keys/SSL2.cer', None), |
| 419 | ('globalsign_example_keys/SSL3.cer', None), |
wbond | 8bb77d0 | 2015-07-13 17:44:29 -0400 | [diff] [blame] | 420 | ) |
wbond | af1f5a8 | 2015-07-17 12:13:15 -0400 | [diff] [blame] | 421 | |
| 422 | @data('name_constraints_value_info') |
| 423 | def name_constraints_value(self, relative_path, name_constraints_value): |
| 424 | cert = self._load_cert(relative_path) |
| 425 | value = cert.name_constraints_value |
| 426 | self.assertEqual(name_constraints_value, value.native if value else None) |
| 427 | |
| 428 | #pylint: disable=C0326 |
| 429 | @staticmethod |
| 430 | def crl_distribution_points_value_info(): |
| 431 | return ( |
| 432 | ('keys/test-der.crt', None), |
| 433 | ('keys/test-inter-der.crt', None), |
| 434 | ('keys/test-third-der.crt', None), |
| 435 | ('geotrust_certs/GeoTrust_Universal_CA.crt', None), |
| 436 | ('geotrust_certs/GeoTrust_Primary_CA.crt', None), |
| 437 | ( |
| 438 | 'geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt', |
| 439 | [ |
| 440 | OrderedDict([ |
| 441 | ('distribution_point', ['http://g1.symcb.com/GeoTrustPCA.crl']), |
| 442 | ('reasons', None), |
| 443 | ('crl_issuer', None) |
| 444 | ]) |
| 445 | ] |
| 446 | ), |
| 447 | ( |
| 448 | 'geotrust_certs/codex.crt', |
| 449 | [ |
| 450 | OrderedDict([ |
| 451 | ('distribution_point', ['http://gm.symcb.com/gm.crl']), |
| 452 | ('reasons', None), |
| 453 | ('crl_issuer', None) |
| 454 | ]) |
| 455 | ] |
| 456 | ), |
| 457 | ('lets_encrypt/isrgrootx1.pem', None), |
| 458 | ( |
| 459 | 'lets_encrypt/letsencryptauthorityx1.pem', |
| 460 | [ |
| 461 | OrderedDict([ |
| 462 | ('distribution_point', ['http://crl.root-x1.letsencrypt.org']), |
| 463 | ('reasons', None), |
| 464 | ('crl_issuer', None) |
| 465 | ]) |
| 466 | ] |
| 467 | ), |
| 468 | ( |
| 469 | 'lets_encrypt/letsencryptauthorityx2.pem', |
| 470 | [ |
| 471 | OrderedDict([ |
| 472 | ('distribution_point', ['http://crl.root-x1.letsencrypt.org']), |
| 473 | ('reasons', None), |
| 474 | ('crl_issuer', None) |
| 475 | ]) |
| 476 | ] |
| 477 | ), |
| 478 | ( |
| 479 | 'globalsign_example_keys/IssuingCA-der.cer', |
| 480 | [ |
| 481 | OrderedDict([ |
| 482 | ('distribution_point', ['http://crl.globalsign.com/gs/trustrootcatg2.crl']), |
| 483 | ('reasons', None), |
| 484 | ('crl_issuer', None) |
| 485 | ]) |
| 486 | ]), |
| 487 | ( |
| 488 | 'globalsign_example_keys/rootCA.cer', |
| 489 | [ |
| 490 | OrderedDict([ |
| 491 | ('distribution_point', ['http://crl.globalsign.com/gs/trustrootcatg2.crl']), |
| 492 | ('reasons', None), |
| 493 | ('crl_issuer', None) |
| 494 | ]) |
| 495 | ]), |
| 496 | ('globalsign_example_keys/SSL1.cer', None), |
| 497 | ('globalsign_example_keys/SSL2.cer', None), |
| 498 | ('globalsign_example_keys/SSL3.cer', None), |
| 499 | ) |
| 500 | |
| 501 | @data('crl_distribution_points_value_info') |
| 502 | def crl_distribution_points_value(self, relative_path, crl_distribution_points_value): |
| 503 | cert = self._load_cert(relative_path) |
| 504 | value = cert.crl_distribution_points_value |
| 505 | self.assertEqual(crl_distribution_points_value, value.native if value else None) |
| 506 | |
| 507 | #pylint: disable=C0326 |
| 508 | @staticmethod |
| 509 | def certificate_policies_value_info(): |
| 510 | return ( |
| 511 | ('keys/test-der.crt', None), |
| 512 | ('keys/test-inter-der.crt', None), |
| 513 | ('keys/test-third-der.crt', None), |
| 514 | ('geotrust_certs/GeoTrust_Universal_CA.crt', None), |
| 515 | ('geotrust_certs/GeoTrust_Primary_CA.crt', None), |
| 516 | ( |
| 517 | 'geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt', |
| 518 | [ |
| 519 | OrderedDict([ |
| 520 | ('policy_identifier', 'any_policy'), |
| 521 | ( |
| 522 | 'policy_qualifiers', |
| 523 | [ |
| 524 | OrderedDict([ |
| 525 | ('policy_qualifier_id', 'certification_practice_statement'), |
| 526 | ('qualifier', 'https://www.geotrust.com/resources/cps') |
| 527 | ]) |
| 528 | ] |
| 529 | ) |
| 530 | ]) |
| 531 | ] |
| 532 | ), |
| 533 | ( |
| 534 | 'geotrust_certs/codex.crt', |
| 535 | [ |
| 536 | OrderedDict([ |
| 537 | ('policy_identifier', '1.3.6.1.4.1.14370.1.6'), |
| 538 | ( |
| 539 | 'policy_qualifiers', |
| 540 | [ |
| 541 | OrderedDict([ |
| 542 | ('policy_qualifier_id', 'certification_practice_statement'), |
| 543 | ('qualifier', 'https://www.geotrust.com/resources/repository/legal') |
| 544 | ]), |
| 545 | OrderedDict([ |
| 546 | ('policy_qualifier_id', 'user_notice'), |
| 547 | ( |
| 548 | 'qualifier', |
| 549 | OrderedDict([ |
| 550 | ('notice_ref', None), |
| 551 | ('explicit_text', 'https://www.geotrust.com/resources/repository/legal') |
| 552 | ]) |
| 553 | ) |
| 554 | ]) |
| 555 | ] |
| 556 | ) |
| 557 | ]) |
| 558 | ] |
| 559 | ), |
| 560 | ('lets_encrypt/isrgrootx1.pem', None), |
| 561 | ( |
| 562 | 'lets_encrypt/letsencryptauthorityx1.pem', |
| 563 | [ |
| 564 | OrderedDict([ |
| 565 | ('policy_identifier', '2.23.140.1.2.1'), |
| 566 | ('policy_qualifiers', None) |
| 567 | ]), |
| 568 | OrderedDict([ |
| 569 | ('policy_identifier', '1.3.6.1.4.1.44947.1.1.1'), |
| 570 | ( |
| 571 | 'policy_qualifiers', |
| 572 | [ |
| 573 | OrderedDict([ |
| 574 | ('policy_qualifier_id', 'certification_practice_statement'), |
| 575 | ('qualifier', 'http://cps.root-x1.letsencrypt.org') |
| 576 | ]) |
| 577 | ] |
| 578 | ) |
| 579 | ]) |
| 580 | ] |
| 581 | ), |
| 582 | ( |
| 583 | 'lets_encrypt/letsencryptauthorityx2.pem', |
| 584 | [ |
| 585 | OrderedDict([ |
| 586 | ('policy_identifier', '2.23.140.1.2.1'), |
| 587 | ('policy_qualifiers', None) |
| 588 | ]), |
| 589 | OrderedDict([ |
| 590 | ('policy_identifier', '1.3.6.1.4.1.44947.1.1.1'), |
| 591 | ( |
| 592 | 'policy_qualifiers', |
| 593 | [ |
| 594 | OrderedDict([ |
| 595 | ('policy_qualifier_id', 'certification_practice_statement'), |
| 596 | ('qualifier', 'http://cps.root-x1.letsencrypt.org') |
| 597 | ]) |
| 598 | ] |
| 599 | ) |
| 600 | ]) |
| 601 | ] |
| 602 | ), |
| 603 | ( |
| 604 | 'globalsign_example_keys/IssuingCA-der.cer', |
| 605 | [ |
| 606 | OrderedDict([ |
| 607 | ('policy_identifier', '1.3.6.1.4.1.4146.1.60'), |
| 608 | ( |
| 609 | 'policy_qualifiers', |
| 610 | [ |
| 611 | OrderedDict([ |
| 612 | ('policy_qualifier_id', 'certification_practice_statement'), |
| 613 | ('qualifier', 'https://www.globalsign.com/repository/') |
| 614 | ]) |
| 615 | ] |
| 616 | ) |
| 617 | ]) |
| 618 | ] |
| 619 | ), |
| 620 | ('globalsign_example_keys/rootCA.cer', None), |
| 621 | ( |
| 622 | 'globalsign_example_keys/SSL1.cer', |
| 623 | [ |
| 624 | OrderedDict([ |
| 625 | ('policy_identifier', '1.3.6.1.4.1.4146.1.60'), |
| 626 | ( |
| 627 | 'policy_qualifiers', |
| 628 | [ |
| 629 | OrderedDict([ |
| 630 | ('policy_qualifier_id', 'certification_practice_statement'), |
| 631 | ('qualifier', 'https://www.globalsign.com/repository/') |
| 632 | ]) |
| 633 | ] |
| 634 | ) |
| 635 | ]) |
| 636 | ] |
| 637 | ), |
| 638 | ( |
| 639 | 'globalsign_example_keys/SSL2.cer', |
| 640 | [ |
| 641 | OrderedDict([ |
| 642 | ('policy_identifier', '1.3.6.1.4.1.4146.1.60'), |
| 643 | ( |
| 644 | 'policy_qualifiers', |
| 645 | [ |
| 646 | OrderedDict([ |
| 647 | ('policy_qualifier_id', 'certification_practice_statement'), |
| 648 | ('qualifier', 'https://www.globalsign.com/repository/') |
| 649 | ]) |
| 650 | ] |
| 651 | ) |
| 652 | ]) |
| 653 | ] |
| 654 | ), |
| 655 | ( |
| 656 | 'globalsign_example_keys/SSL3.cer', |
| 657 | [ |
| 658 | OrderedDict([ |
| 659 | ('policy_identifier', '1.3.6.1.4.1.4146.1.60'), |
| 660 | ( |
| 661 | 'policy_qualifiers', |
| 662 | [ |
| 663 | OrderedDict([ |
| 664 | ('policy_qualifier_id', 'certification_practice_statement'), |
| 665 | ('qualifier', 'https://www.globalsign.com/repository/') |
| 666 | ]) |
| 667 | ] |
| 668 | ) |
| 669 | ]) |
| 670 | ] |
| 671 | ), |
| 672 | ) |
| 673 | |
| 674 | @data('certificate_policies_value_info') |
| 675 | def certificate_policies_value(self, relative_path, certificate_policies_value): |
| 676 | cert = self._load_cert(relative_path) |
| 677 | value = cert.certificate_policies_value |
| 678 | self.assertEqual(certificate_policies_value, value.native if value else None) |
| 679 | |
| 680 | #pylint: disable=C0326 |
| 681 | @staticmethod |
| 682 | def policy_mappings_value_info(): |
| 683 | return ( |
| 684 | ('keys/test-der.crt', None), |
| 685 | ('keys/test-inter-der.crt', None), |
| 686 | ('keys/test-third-der.crt', None), |
| 687 | ('geotrust_certs/GeoTrust_Universal_CA.crt', None), |
| 688 | ('geotrust_certs/GeoTrust_Primary_CA.crt', None), |
| 689 | ('geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt', None), |
| 690 | ('geotrust_certs/codex.crt', None), |
| 691 | ('lets_encrypt/isrgrootx1.pem', None), |
| 692 | ('lets_encrypt/letsencryptauthorityx1.pem', None), |
| 693 | ('lets_encrypt/letsencryptauthorityx2.pem', None), |
| 694 | ('globalsign_example_keys/IssuingCA-der.cer', None), |
| 695 | ('globalsign_example_keys/rootCA.cer', None), |
| 696 | ('globalsign_example_keys/SSL1.cer', None), |
| 697 | ('globalsign_example_keys/SSL2.cer', None), |
| 698 | ('globalsign_example_keys/SSL3.cer', None), |
| 699 | ) |
| 700 | |
| 701 | @data('policy_mappings_value_info') |
| 702 | def policy_mappings_value(self, relative_path, policy_mappings_value): |
| 703 | cert = self._load_cert(relative_path) |
| 704 | value = cert.policy_mappings_value |
| 705 | self.assertEqual(policy_mappings_value, value.native if value else None) |
| 706 | |
| 707 | #pylint: disable=C0326 |
| 708 | @staticmethod |
| 709 | def authority_key_identifier_value_info(): |
| 710 | return ( |
| 711 | ( |
| 712 | 'keys/test-der.crt', |
wbond | 08c60fa | 2015-07-13 23:02:13 -0400 | [diff] [blame] | 713 | OrderedDict([ |
wbond | af1f5a8 | 2015-07-17 12:13:15 -0400 | [diff] [blame] | 714 | ('key_identifier', b'\xbeB\x85=\xcc\xff\xe3\xf9(\x02\x8f~XV\xb4\xfd\x03\\\xeaK'), |
| 715 | ( |
| 716 | 'authority_cert_issuer', |
| 717 | [ |
| 718 | OrderedDict([ |
| 719 | ('country_name', 'US'), |
| 720 | ('state_or_province_name', 'Massachusetts'), |
| 721 | ('locality_name', 'Newbury'), |
| 722 | ('organization_name', 'Codex Non Sufficit LC'), |
| 723 | ('organizational_unit_name', 'Testing'), |
| 724 | ('common_name', 'Will Bond'), |
| 725 | ('email_address', 'will@codexns.io') |
| 726 | ]) |
| 727 | ] |
| 728 | ), |
| 729 | ('authority_cert_serial_number', 13683582341504654466) |
wbond | 08c60fa | 2015-07-13 23:02:13 -0400 | [diff] [blame] | 730 | ]) |
wbond | af1f5a8 | 2015-07-17 12:13:15 -0400 | [diff] [blame] | 731 | ), |
| 732 | ( |
| 733 | 'keys/test-inter-der.crt', |
| 734 | OrderedDict([ |
| 735 | ('key_identifier', b'\xbeB\x85=\xcc\xff\xe3\xf9(\x02\x8f~XV\xb4\xfd\x03\\\xeaK'), |
| 736 | ('authority_cert_issuer', None), |
| 737 | ('authority_cert_serial_number', None) |
| 738 | ]) |
| 739 | ), |
| 740 | ( |
| 741 | 'keys/test-third-der.crt', |
| 742 | OrderedDict([ |
| 743 | ('key_identifier', b'\xd2\n\xfd.%\xd1\xb7!\xd7P~\xbb\xa4}\xbf4\xefR^\x02'), |
| 744 | ('authority_cert_issuer', None), |
| 745 | ('authority_cert_serial_number', None) |
| 746 | ]) |
| 747 | ), |
| 748 | ( |
| 749 | 'geotrust_certs/GeoTrust_Universal_CA.crt', |
| 750 | OrderedDict([ |
| 751 | ('key_identifier', b'\xda\xbb.\xaa\xb0\x0c\xb8\x88&Qt\\m\x03\xd3\xc0\xd8\x8fz\xd6'), |
| 752 | ('authority_cert_issuer', None), |
| 753 | ('authority_cert_serial_number', None) |
| 754 | ]) |
| 755 | ), |
| 756 | ( |
| 757 | 'geotrust_certs/GeoTrust_Primary_CA.crt', |
| 758 | None |
| 759 | ), |
| 760 | ( |
| 761 | 'geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt', |
| 762 | OrderedDict([ |
| 763 | ('key_identifier', b',\xd5PA\x97\x15\x8b\xf0\x8f6a[J\xfbk\xd9\x99\xc93\x92'), |
| 764 | ('authority_cert_issuer', None), |
| 765 | ('authority_cert_serial_number', None) |
| 766 | ]) |
| 767 | ), |
| 768 | ( |
| 769 | 'geotrust_certs/codex.crt', |
| 770 | OrderedDict([ |
| 771 | ('key_identifier', b'\xde\xcf\\P\xb7\xae\x02\x1f\x15\x17\xaa\x16\xe8\r\xb5(\x9djZ\xf3'), |
| 772 | ('authority_cert_issuer', None), |
| 773 | ('authority_cert_serial_number', None) |
| 774 | ]) |
| 775 | ), |
| 776 | ( |
| 777 | 'lets_encrypt/isrgrootx1.pem', |
| 778 | None |
| 779 | ), |
| 780 | ( |
| 781 | 'lets_encrypt/letsencryptauthorityx1.pem', |
| 782 | OrderedDict([ |
| 783 | ('key_identifier', b'y\xb4Y\xe6{\xb6\xe5\xe4\x01s\x80\x08\x88\xc8\x1aX\xf6\xe9\x9bn'), |
| 784 | ('authority_cert_issuer', None), |
| 785 | ('authority_cert_serial_number', None) |
| 786 | ]) |
| 787 | ), |
| 788 | ( |
| 789 | 'lets_encrypt/letsencryptauthorityx2.pem', |
| 790 | OrderedDict([ |
| 791 | ('key_identifier', b'y\xb4Y\xe6{\xb6\xe5\xe4\x01s\x80\x08\x88\xc8\x1aX\xf6\xe9\x9bn'), |
| 792 | ('authority_cert_issuer', None), |
| 793 | ('authority_cert_serial_number', None) |
| 794 | ]) |
| 795 | ), |
| 796 | ( |
| 797 | 'globalsign_example_keys/IssuingCA-der.cer', |
| 798 | OrderedDict([ |
| 799 | ('key_identifier', b'd|\\\xe1\xe0`8NH\x9f\x05\xbcUc~?\xaeM\xf7\x1e'), |
| 800 | ('authority_cert_issuer', None), |
| 801 | ('authority_cert_serial_number', None) |
| 802 | ]) |
| 803 | ), |
| 804 | ( |
| 805 | 'globalsign_example_keys/rootCA.cer', |
| 806 | None |
| 807 | ), |
| 808 | ( |
| 809 | 'globalsign_example_keys/SSL1.cer', |
| 810 | OrderedDict([ |
| 811 | ('key_identifier', b"'\xf8/\xe9]\xd7\r\xf4\xa8\xea\x87\x99=\xfd\x8e\xb3\x9e@\xd0\x91"), |
| 812 | ('authority_cert_issuer', None), |
| 813 | ('authority_cert_serial_number', None) |
| 814 | ]) |
| 815 | ), |
| 816 | ( |
| 817 | 'globalsign_example_keys/SSL2.cer', |
| 818 | OrderedDict([ |
| 819 | ('key_identifier', b"'\xf8/\xe9]\xd7\r\xf4\xa8\xea\x87\x99=\xfd\x8e\xb3\x9e@\xd0\x91"), |
| 820 | ('authority_cert_issuer', None), |
| 821 | ('authority_cert_serial_number', None) |
| 822 | ]) |
| 823 | ), |
| 824 | ( |
| 825 | 'globalsign_example_keys/SSL3.cer', |
| 826 | OrderedDict([ |
| 827 | ('key_identifier', b"'\xf8/\xe9]\xd7\r\xf4\xa8\xea\x87\x99=\xfd\x8e\xb3\x9e@\xd0\x91"), |
| 828 | ('authority_cert_issuer', None), |
| 829 | ('authority_cert_serial_number', None) |
| 830 | ]) |
| 831 | ), |
wbond | 08c60fa | 2015-07-13 23:02:13 -0400 | [diff] [blame] | 832 | ) |
wbond | af1f5a8 | 2015-07-17 12:13:15 -0400 | [diff] [blame] | 833 | |
| 834 | @data('authority_key_identifier_value_info') |
| 835 | def authority_key_identifier_value(self, relative_path, authority_key_identifier_value): |
| 836 | cert = self._load_cert(relative_path) |
| 837 | value = cert.authority_key_identifier_value |
| 838 | self.assertEqual(authority_key_identifier_value, value.native if value else None) |
| 839 | |
| 840 | #pylint: disable=C0326 |
| 841 | @staticmethod |
| 842 | def policy_constraints_value_info(): |
| 843 | return ( |
| 844 | ('keys/test-der.crt', None), |
| 845 | ('keys/test-inter-der.crt', None), |
| 846 | ('keys/test-third-der.crt', None), |
| 847 | ('geotrust_certs/GeoTrust_Universal_CA.crt', None), |
| 848 | ('geotrust_certs/GeoTrust_Primary_CA.crt', None), |
| 849 | ('geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt', None), |
| 850 | ('geotrust_certs/codex.crt', None), |
| 851 | ('lets_encrypt/isrgrootx1.pem', None), |
| 852 | ('lets_encrypt/letsencryptauthorityx1.pem', None), |
| 853 | ('lets_encrypt/letsencryptauthorityx2.pem', None), |
| 854 | ('globalsign_example_keys/IssuingCA-der.cer', None), |
| 855 | ('globalsign_example_keys/rootCA.cer', None), |
| 856 | ('globalsign_example_keys/SSL1.cer', None), |
| 857 | ('globalsign_example_keys/SSL2.cer', None), |
| 858 | ('globalsign_example_keys/SSL3.cer', None), |
| 859 | ) |
| 860 | |
| 861 | @data('policy_constraints_value_info') |
| 862 | def policy_constraints_value(self, relative_path, policy_constraints_value): |
| 863 | cert = self._load_cert(relative_path) |
| 864 | value = cert.policy_constraints_value |
| 865 | self.assertEqual(policy_constraints_value, value.native if value else None) |
| 866 | |
| 867 | #pylint: disable=C0326 |
| 868 | @staticmethod |
| 869 | def extended_key_usage_value_info(): |
| 870 | return ( |
| 871 | ('keys/test-der.crt', None), |
| 872 | ('keys/test-inter-der.crt', None), |
| 873 | ('keys/test-third-der.crt', None), |
| 874 | ('geotrust_certs/GeoTrust_Universal_CA.crt', None), |
| 875 | ('geotrust_certs/GeoTrust_Primary_CA.crt', None), |
| 876 | ('geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt', None), |
| 877 | ('geotrust_certs/codex.crt', ['server_auth', 'client_auth']), |
| 878 | ('lets_encrypt/isrgrootx1.pem', None), |
| 879 | ('lets_encrypt/letsencryptauthorityx1.pem', None), |
| 880 | ('lets_encrypt/letsencryptauthorityx2.pem', None), |
| 881 | ('globalsign_example_keys/IssuingCA-der.cer', None), |
| 882 | ('globalsign_example_keys/rootCA.cer', None), |
| 883 | ('globalsign_example_keys/SSL1.cer', ['server_auth', 'client_auth']), |
| 884 | ('globalsign_example_keys/SSL2.cer', ['server_auth', 'client_auth']), |
| 885 | ('globalsign_example_keys/SSL3.cer', ['server_auth', 'client_auth']), |
| 886 | ) |
| 887 | |
| 888 | @data('extended_key_usage_value_info') |
| 889 | def extended_key_usage_value(self, relative_path, extended_key_usage_value): |
| 890 | cert = self._load_cert(relative_path) |
| 891 | value = cert.extended_key_usage_value |
| 892 | self.assertEqual(extended_key_usage_value, value.native if value else None) |
| 893 | |
| 894 | #pylint: disable=C0326 |
| 895 | @staticmethod |
| 896 | def authority_information_access_value_info(): |
| 897 | return ( |
| 898 | ('keys/test-der.crt', None), |
| 899 | ('keys/test-inter-der.crt', None), |
| 900 | ('keys/test-third-der.crt', None), |
| 901 | ('geotrust_certs/GeoTrust_Universal_CA.crt', None), |
| 902 | ('geotrust_certs/GeoTrust_Primary_CA.crt', None), |
| 903 | ( |
| 904 | 'geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt', |
| 905 | [ |
| 906 | OrderedDict([ |
| 907 | ('access_method', 'ocsp'), |
| 908 | ('access_location', 'http://g2.symcb.com') |
| 909 | ]) |
| 910 | ] |
| 911 | ), |
| 912 | ( |
| 913 | 'geotrust_certs/codex.crt', |
| 914 | [ |
| 915 | OrderedDict([ |
| 916 | ('access_method', 'ocsp'), |
| 917 | ('access_location', 'http://gm.symcd.com') |
| 918 | ]), |
| 919 | OrderedDict([ |
| 920 | ('access_method', 'ca_issuers'), |
| 921 | ('access_location', 'http://gm.symcb.com/gm.crt') |
| 922 | ]), |
| 923 | ] |
| 924 | ), |
| 925 | ('lets_encrypt/isrgrootx1.pem', None), |
| 926 | ( |
| 927 | 'lets_encrypt/letsencryptauthorityx1.pem', |
| 928 | [ |
| 929 | OrderedDict([ |
| 930 | ('access_method', 'ocsp'), |
| 931 | ('access_location', 'http://ocsp.root-x1.letsencrypt.org/') |
| 932 | ]), |
| 933 | OrderedDict([ |
| 934 | ('access_method', 'ca_issuers'), |
| 935 | ('access_location', 'http://cert.root-x1.letsencrypt.org/') |
| 936 | ]) |
| 937 | ] |
| 938 | ), |
| 939 | ( |
| 940 | 'lets_encrypt/letsencryptauthorityx2.pem', |
| 941 | [ |
| 942 | OrderedDict([ |
| 943 | ('access_method', 'ocsp'), |
| 944 | ('access_location', 'http://ocsp.root-x1.letsencrypt.org/') |
| 945 | ]), |
| 946 | OrderedDict([ |
| 947 | ('access_method', 'ca_issuers'), |
| 948 | ('access_location', 'http://cert.root-x1.letsencrypt.org/') |
| 949 | ]) |
| 950 | ] |
| 951 | ), |
| 952 | ('globalsign_example_keys/IssuingCA-der.cer', None), |
| 953 | ('globalsign_example_keys/rootCA.cer', None), |
| 954 | ( |
| 955 | 'globalsign_example_keys/SSL1.cer', |
| 956 | [ |
| 957 | OrderedDict([ |
| 958 | ('access_method', 'ocsp'), |
| 959 | ('access_location', 'http://ocsp.exampleovca.com/') |
| 960 | ]), |
| 961 | OrderedDict([ |
| 962 | ('access_method', 'ca_issuers'), |
| 963 | ('access_location', 'http://secure.globalsign.com/cacert/trustrootcatg2.crt') |
| 964 | ]) |
| 965 | ] |
| 966 | ), |
| 967 | ( |
| 968 | 'globalsign_example_keys/SSL2.cer', |
| 969 | [ |
| 970 | OrderedDict([ |
| 971 | ('access_method', 'ocsp'), |
| 972 | ('access_location', 'http://ocsp.exampleovca.com/') |
| 973 | ]), |
| 974 | OrderedDict([ |
| 975 | ('access_method', 'ca_issuers'), |
| 976 | ('access_location', 'http://secure.globalsign.com/cacert/trustrootcatg2.crt') |
| 977 | ]) |
| 978 | ] |
| 979 | ), |
| 980 | ( |
| 981 | 'globalsign_example_keys/SSL3.cer', |
| 982 | [ |
| 983 | OrderedDict([ |
| 984 | ('access_method', 'ocsp'), |
| 985 | ('access_location', 'http://ocsp.exampleovca.com/') |
| 986 | ]), |
| 987 | OrderedDict([ |
| 988 | ('access_method', 'ca_issuers'), |
| 989 | ('access_location', 'http://secure.globalsign.com/cacert/trustrootcatg2.crt') |
| 990 | ]) |
| 991 | ] |
| 992 | ), |
| 993 | ) |
| 994 | |
| 995 | @data('authority_information_access_value_info') |
| 996 | def authority_information_access_value(self, relative_path, authority_information_access_value): |
| 997 | cert = self._load_cert(relative_path) |
| 998 | value = cert.authority_information_access_value |
| 999 | self.assertEqual(authority_information_access_value, value.native if value else None) |
| 1000 | |
| 1001 | #pylint: disable=C0326 |
| 1002 | @staticmethod |
| 1003 | def ocsp_no_check_value_info(): |
| 1004 | return ( |
| 1005 | ('keys/test-der.crt', None), |
| 1006 | ('keys/test-inter-der.crt', None), |
| 1007 | ('keys/test-third-der.crt', None), |
| 1008 | ('geotrust_certs/GeoTrust_Universal_CA.crt', None), |
| 1009 | ('geotrust_certs/GeoTrust_Primary_CA.crt', None), |
| 1010 | ('geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt', None), |
| 1011 | ('geotrust_certs/codex.crt', None), |
| 1012 | ('lets_encrypt/isrgrootx1.pem', None), |
| 1013 | ('lets_encrypt/letsencryptauthorityx1.pem', None), |
| 1014 | ('lets_encrypt/letsencryptauthorityx2.pem', None), |
| 1015 | ('globalsign_example_keys/IssuingCA-der.cer', None), |
| 1016 | ('globalsign_example_keys/rootCA.cer', None), |
| 1017 | ('globalsign_example_keys/SSL1.cer', None), |
| 1018 | ('globalsign_example_keys/SSL2.cer', None), |
| 1019 | ('globalsign_example_keys/SSL3.cer', None), |
| 1020 | ) |
| 1021 | |
| 1022 | @data('ocsp_no_check_value_info') |
| 1023 | def ocsp_no_check_value(self, relative_path, ocsp_no_check_value): |
| 1024 | cert = self._load_cert(relative_path) |
| 1025 | value = cert.ocsp_no_check_value |
| 1026 | self.assertEqual(ocsp_no_check_value, value.native if value else None) |
| 1027 | |
| 1028 | #pylint: disable=C0326 |
| 1029 | @staticmethod |
| 1030 | def serial_number_info(): |
| 1031 | return ( |
| 1032 | ('keys/test-der.crt', 13683582341504654466), |
| 1033 | ('keys/test-inter-der.crt', 1590137), |
| 1034 | ('keys/test-third-der.crt', 2474902313), |
| 1035 | ('geotrust_certs/GeoTrust_Universal_CA.crt', 1), |
| 1036 | ('geotrust_certs/GeoTrust_Primary_CA.crt', 32798226551256963324313806436981982369), |
| 1037 | ('geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt', 146934555852773531829332059263122711876), |
| 1038 | ('geotrust_certs/codex.crt', 130338219198307073574879940486642352162), |
| 1039 | ('lets_encrypt/isrgrootx1.pem', 172886928669790476064670243504169061120), |
| 1040 | ('lets_encrypt/letsencryptauthorityx1.pem', 307817870430047279283060309415759825539), |
| 1041 | ('lets_encrypt/letsencryptauthorityx2.pem', 199666138109676817050168330923544141416), |
| 1042 | ('globalsign_example_keys/IssuingCA-der.cer', 43543335419752), |
| 1043 | ('globalsign_example_keys/rootCA.cer', 342514332211132), |
| 1044 | ('globalsign_example_keys/SSL1.cer', 425155524522), |
| 1045 | ('globalsign_example_keys/SSL2.cer', 425155524522), |
| 1046 | ('globalsign_example_keys/SSL3.cer', 425155524522), |
| 1047 | ) |
| 1048 | |
| 1049 | @data('serial_number_info') |
| 1050 | def serial_number(self, relative_path, serial_number): |
| 1051 | cert = self._load_cert(relative_path) |
| 1052 | self.assertEqual(serial_number, cert.serial_number) |
| 1053 | |
| 1054 | #pylint: disable=C0326 |
| 1055 | @staticmethod |
| 1056 | def key_identifier_info(): |
| 1057 | return ( |
| 1058 | ('keys/test-der.crt', b'\xbeB\x85=\xcc\xff\xe3\xf9(\x02\x8f~XV\xb4\xfd\x03\\\xeaK'), |
| 1059 | ('keys/test-inter-der.crt', b'\xd2\n\xfd.%\xd1\xb7!\xd7P~\xbb\xa4}\xbf4\xefR^\x02'), |
| 1060 | ('keys/test-third-der.crt', b'D8\xe0\xe0&\x85\xbf\x98\x86\xdc\x1b\xe1\x1d\xf520\xbe\xab\xac\r'), |
| 1061 | ('geotrust_certs/GeoTrust_Universal_CA.crt', b'\xda\xbb.\xaa\xb0\x0c\xb8\x88&Qt\\m\x03\xd3\xc0\xd8\x8fz\xd6'), |
| 1062 | ('geotrust_certs/GeoTrust_Primary_CA.crt', b',\xd5PA\x97\x15\x8b\xf0\x8f6a[J\xfbk\xd9\x99\xc93\x92'), |
| 1063 | ('geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt', b'\xde\xcf\\P\xb7\xae\x02\x1f\x15\x17\xaa\x16\xe8\r\xb5(\x9djZ\xf3'), |
| 1064 | ('geotrust_certs/codex.crt', None), |
| 1065 | ('lets_encrypt/isrgrootx1.pem', b'y\xb4Y\xe6{\xb6\xe5\xe4\x01s\x80\x08\x88\xc8\x1aX\xf6\xe9\x9bn'), |
| 1066 | ('lets_encrypt/letsencryptauthorityx1.pem', b'\xa8Jjc\x04}\xdd\xba\xe6\xd19\xb7\xa6Ee\xef\xf3\xa8\xec\xa1'), |
| 1067 | ('lets_encrypt/letsencryptauthorityx2.pem', b'\xc5\xb1\xabNL\xb1\xcdd0\x93~\xc1\x84\x99\x05\xab\xe6\x03\xe2%'), |
| 1068 | ('globalsign_example_keys/IssuingCA-der.cer', b"'\xf8/\xe9]\xd7\r\xf4\xa8\xea\x87\x99=\xfd\x8e\xb3\x9e@\xd0\x91"), |
| 1069 | ('globalsign_example_keys/rootCA.cer', b'd|\\\xe1\xe0`8NH\x9f\x05\xbcUc~?\xaeM\xf7\x1e'), |
| 1070 | ('globalsign_example_keys/SSL1.cer', b'\x94a\x04\x92\x04L\xe6\xffh\xa8\x96\xafy\xd2\xf32\x84\xae[\xcf'), |
| 1071 | ('globalsign_example_keys/SSL2.cer', b'\xd2\xb7\x15\x7fd0\x07(p\x83\xca(\xfa\x88\x96\xde\x9e\xfc\x8a='), |
| 1072 | ('globalsign_example_keys/SSL3.cer', b'G\xde\xa4\xe7\xea`\xe7\xee6\xc8\xf1\xd5\xb0F\x07\x07\x9eBh\xce'), |
| 1073 | ) |
| 1074 | |
| 1075 | @data('key_identifier_info') |
| 1076 | def key_identifier(self, relative_path, key_identifier): |
| 1077 | cert = self._load_cert(relative_path) |
| 1078 | self.assertEqual(key_identifier, cert.key_identifier) |
| 1079 | |
| 1080 | #pylint: disable=C0326 |
| 1081 | @staticmethod |
| 1082 | def issuer_serial_info(): |
| 1083 | return ( |
| 1084 | ('keys/test-der.crt', b'\xdd\x8a\x19x\xae`\x19=\xa7\xf8\x00\xb9\xfbx\xf8\xedu\xb8!\xf8\x8c\xdb\x1f\x99\'7w\x93\xb4\xa4\'\xa0:13683582341504654466'), |
| 1085 | ('keys/test-inter-der.crt', b'\xdd\x8a\x19x\xae`\x19=\xa7\xf8\x00\xb9\xfbx\xf8\xedu\xb8!\xf8\x8c\xdb\x1f\x99\'7w\x93\xb4\xa4\'\xa0:1590137'), |
| 1086 | ('keys/test-third-der.crt', b'\xed{\x9b\xbf\x9b\xdbd\xa4\xea\xf2#+H\x96\xcd\x80\x99\xf6\xecCM\x94\x07\x02\xe2\x18\xf3\x83\x8c8%\x01:2474902313'), |
| 1087 | ('geotrust_certs/GeoTrust_Universal_CA.crt', b'\xa1\x848\xf2\xe5w\xee\xec\xce\xfefJC+\xdf\x97\x7f\xd2Y\xe3\xdc\xa0D7~\x07\xd9\x9dzL@g:1'), |
| 1088 | ('geotrust_certs/GeoTrust_Primary_CA.crt', b'\xdcg\x0c\x80\x03\xb3D\xa0v\xe2\xee\xec\x8b\xd6\x82\x01\xf0\x13\x0cwT\xb4\x8f\x80\x0eT\x9d\xbf\xbf\xa4\x11\x80:32798226551256963324313806436981982369'), |
| 1089 | ('geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt', b'\xdcg\x0c\x80\x03\xb3D\xa0v\xe2\xee\xec\x8b\xd6\x82\x01\xf0\x13\x0cwT\xb4\x8f\x80\x0eT\x9d\xbf\xbf\xa4\x11\x80:146934555852773531829332059263122711876'), |
| 1090 | ('geotrust_certs/codex.crt', b'x\x12\xe0\x15\x00d;\xc3\xb9/\xf6\x13\n\xd8\xe2\xddY\xf7\xaf*=C\x01<\x86\xf5\x9f_\xab;e\xd1:130338219198307073574879940486642352162'), |
| 1091 | ('lets_encrypt/isrgrootx1.pem', b'\xf6\xdb/\xbd\x9d\xd8]\x92Y\xdd\xb3\xc6\xde}{/\xec?>\x0c\xef\x17a\xbc\xbf3 W\x1e-0\xf8:172886928669790476064670243504169061120'), |
| 1092 | ('lets_encrypt/letsencryptauthorityx1.pem', b'\xf6\xdb/\xbd\x9d\xd8]\x92Y\xdd\xb3\xc6\xde}{/\xec?>\x0c\xef\x17a\xbc\xbf3 W\x1e-0\xf8:307817870430047279283060309415759825539'), |
| 1093 | ('lets_encrypt/letsencryptauthorityx2.pem', b'\xf6\xdb/\xbd\x9d\xd8]\x92Y\xdd\xb3\xc6\xde}{/\xec?>\x0c\xef\x17a\xbc\xbf3 W\x1e-0\xf8:199666138109676817050168330923544141416'), |
| 1094 | ('globalsign_example_keys/IssuingCA-der.cer', b'\xd2\xe7\xca\x10\xc1\x91\x92Y^A\x11\xd3Rz\xd5\x93\x19wk\x11\xef\xaa\x9c\xad\x10\x8ak\x8a\x08-\x0c\xff:43543335419752'), |
| 1095 | ('globalsign_example_keys/rootCA.cer', b'\xd2\xe7\xca\x10\xc1\x91\x92Y^A\x11\xd3Rz\xd5\x93\x19wk\x11\xef\xaa\x9c\xad\x10\x8ak\x8a\x08-\x0c\xff:342514332211132'), |
| 1096 | ('globalsign_example_keys/SSL1.cer', b'_\xc0S\xb1\xeb}\xe3\x8e\xe4{\xdb\xd7\xe2\xd9}=3\x97|\x0c\x1e\xecz\xcc\x92u\x1f\xf0\x1d\xbc\x9f\xe4:425155524522'), |
| 1097 | ('globalsign_example_keys/SSL2.cer', b'_\xc0S\xb1\xeb}\xe3\x8e\xe4{\xdb\xd7\xe2\xd9}=3\x97|\x0c\x1e\xecz\xcc\x92u\x1f\xf0\x1d\xbc\x9f\xe4:425155524522'), |
| 1098 | ('globalsign_example_keys/SSL3.cer', b'_\xc0S\xb1\xeb}\xe3\x8e\xe4{\xdb\xd7\xe2\xd9}=3\x97|\x0c\x1e\xecz\xcc\x92u\x1f\xf0\x1d\xbc\x9f\xe4:425155524522'), |
| 1099 | ) |
| 1100 | |
| 1101 | @data('issuer_serial_info') |
| 1102 | def issuer_serial(self, relative_path, issuer_serial): |
| 1103 | cert = self._load_cert(relative_path) |
| 1104 | self.assertEqual(issuer_serial, cert.issuer_serial) |
| 1105 | |
| 1106 | #pylint: disable=C0326 |
| 1107 | @staticmethod |
| 1108 | def authority_key_identifier_info(): |
| 1109 | return ( |
| 1110 | ('keys/test-der.crt', b'\xbeB\x85=\xcc\xff\xe3\xf9(\x02\x8f~XV\xb4\xfd\x03\\\xeaK'), |
| 1111 | ('keys/test-inter-der.crt', b'\xbeB\x85=\xcc\xff\xe3\xf9(\x02\x8f~XV\xb4\xfd\x03\\\xeaK'), |
| 1112 | ('keys/test-third-der.crt', b'\xd2\n\xfd.%\xd1\xb7!\xd7P~\xbb\xa4}\xbf4\xefR^\x02'), |
| 1113 | ('geotrust_certs/GeoTrust_Universal_CA.crt', b'\xda\xbb.\xaa\xb0\x0c\xb8\x88&Qt\\m\x03\xd3\xc0\xd8\x8fz\xd6'), |
| 1114 | ('geotrust_certs/GeoTrust_Primary_CA.crt', None), |
| 1115 | ('geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt', b',\xd5PA\x97\x15\x8b\xf0\x8f6a[J\xfbk\xd9\x99\xc93\x92'), |
| 1116 | ('geotrust_certs/codex.crt', b'\xde\xcf\\P\xb7\xae\x02\x1f\x15\x17\xaa\x16\xe8\r\xb5(\x9djZ\xf3'), |
| 1117 | ('lets_encrypt/isrgrootx1.pem', None), |
| 1118 | ('lets_encrypt/letsencryptauthorityx1.pem', b'y\xb4Y\xe6{\xb6\xe5\xe4\x01s\x80\x08\x88\xc8\x1aX\xf6\xe9\x9bn'), |
| 1119 | ('lets_encrypt/letsencryptauthorityx2.pem', b'y\xb4Y\xe6{\xb6\xe5\xe4\x01s\x80\x08\x88\xc8\x1aX\xf6\xe9\x9bn'), |
| 1120 | ('globalsign_example_keys/IssuingCA-der.cer', b'd|\\\xe1\xe0`8NH\x9f\x05\xbcUc~?\xaeM\xf7\x1e'), |
| 1121 | ('globalsign_example_keys/rootCA.cer', None), |
| 1122 | ('globalsign_example_keys/SSL1.cer', b"'\xf8/\xe9]\xd7\r\xf4\xa8\xea\x87\x99=\xfd\x8e\xb3\x9e@\xd0\x91"), |
| 1123 | ('globalsign_example_keys/SSL2.cer', b"'\xf8/\xe9]\xd7\r\xf4\xa8\xea\x87\x99=\xfd\x8e\xb3\x9e@\xd0\x91"), |
| 1124 | ('globalsign_example_keys/SSL3.cer', b"'\xf8/\xe9]\xd7\r\xf4\xa8\xea\x87\x99=\xfd\x8e\xb3\x9e@\xd0\x91"), |
| 1125 | ) |
| 1126 | |
| 1127 | @data('authority_key_identifier_info') |
| 1128 | def authority_key_identifier(self, relative_path, authority_key_identifier): |
| 1129 | cert = self._load_cert(relative_path) |
| 1130 | self.assertEqual(authority_key_identifier, cert.authority_key_identifier) |
| 1131 | |
| 1132 | #pylint: disable=C0326 |
| 1133 | @staticmethod |
| 1134 | def authority_issuer_serial_info(): |
| 1135 | return ( |
| 1136 | ('keys/test-der.crt', b'\xdd\x8a\x19x\xae`\x19=\xa7\xf8\x00\xb9\xfbx\xf8\xedu\xb8!\xf8\x8c\xdb\x1f\x99\'7w\x93\xb4\xa4\'\xa0:13683582341504654466'), |
| 1137 | ('keys/test-inter-der.crt', None), |
| 1138 | ('keys/test-third-der.crt', None), |
| 1139 | ('geotrust_certs/GeoTrust_Universal_CA.crt', None), |
| 1140 | ('geotrust_certs/GeoTrust_Primary_CA.crt', None), |
| 1141 | ('geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt', None), |
| 1142 | ('geotrust_certs/codex.crt', None), |
| 1143 | ('lets_encrypt/isrgrootx1.pem', None), |
| 1144 | ('lets_encrypt/letsencryptauthorityx1.pem', None), |
| 1145 | ('lets_encrypt/letsencryptauthorityx2.pem', None), |
| 1146 | ('globalsign_example_keys/IssuingCA-der.cer', None), |
| 1147 | ('globalsign_example_keys/rootCA.cer', None), |
| 1148 | ('globalsign_example_keys/SSL1.cer', None), |
| 1149 | ('globalsign_example_keys/SSL2.cer', None), |
| 1150 | ('globalsign_example_keys/SSL3.cer', None), |
| 1151 | ) |
| 1152 | |
| 1153 | @data('authority_issuer_serial_info') |
| 1154 | def authority_issuer_serial(self, relative_path, authority_issuer_serial): |
| 1155 | cert = self._load_cert(relative_path) |
| 1156 | self.assertEqual(authority_issuer_serial, cert.authority_issuer_serial) |
| 1157 | |
| 1158 | #pylint: disable=C0326 |
| 1159 | @staticmethod |
| 1160 | def ocsp_urls_info(): |
| 1161 | return ( |
| 1162 | ('keys/test-der.crt', []), |
| 1163 | ('keys/test-inter-der.crt', []), |
| 1164 | ('keys/test-third-der.crt', []), |
| 1165 | ('geotrust_certs/GeoTrust_Universal_CA.crt', []), |
| 1166 | ('geotrust_certs/GeoTrust_Primary_CA.crt', []), |
| 1167 | ('geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt', ['http://g2.symcb.com']), |
| 1168 | ('geotrust_certs/codex.crt', ['http://gm.symcd.com']), |
| 1169 | ('lets_encrypt/isrgrootx1.pem', []), |
| 1170 | ('lets_encrypt/letsencryptauthorityx1.pem', ['http://ocsp.root-x1.letsencrypt.org/']), |
| 1171 | ('lets_encrypt/letsencryptauthorityx2.pem', ['http://ocsp.root-x1.letsencrypt.org/']), |
| 1172 | ('globalsign_example_keys/IssuingCA-der.cer', []), |
| 1173 | ('globalsign_example_keys/rootCA.cer', []), |
| 1174 | ('globalsign_example_keys/SSL1.cer', ['http://ocsp.exampleovca.com/']), |
| 1175 | ('globalsign_example_keys/SSL2.cer', ['http://ocsp.exampleovca.com/']), |
| 1176 | ('globalsign_example_keys/SSL3.cer', ['http://ocsp.exampleovca.com/']), |
| 1177 | ) |
| 1178 | |
| 1179 | @data('ocsp_urls_info') |
| 1180 | def ocsp_urls(self, relative_path, ocsp_url): |
| 1181 | cert = self._load_cert(relative_path) |
| 1182 | self.assertEqual(ocsp_url, cert.ocsp_urls) |
| 1183 | |
| 1184 | #pylint: disable=C0326 |
| 1185 | @staticmethod |
wbond | 6888bc6 | 2015-07-21 15:05:59 -0400 | [diff] [blame] | 1186 | def crl_distribution_points_info(): |
wbond | af1f5a8 | 2015-07-17 12:13:15 -0400 | [diff] [blame] | 1187 | return ( |
| 1188 | ('keys/test-der.crt', []), |
| 1189 | ('keys/test-inter-der.crt', []), |
| 1190 | ('keys/test-third-der.crt', []), |
| 1191 | ('geotrust_certs/GeoTrust_Universal_CA.crt', []), |
| 1192 | ('geotrust_certs/GeoTrust_Primary_CA.crt', []), |
wbond | 6888bc6 | 2015-07-21 15:05:59 -0400 | [diff] [blame] | 1193 | ( |
| 1194 | 'geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt', |
| 1195 | [ |
| 1196 | OrderedDict([ |
| 1197 | ('distribution_point', ['http://g1.symcb.com/GeoTrustPCA.crl']), |
| 1198 | ('reasons', None), |
| 1199 | ('crl_issuer', None) |
| 1200 | ]) |
| 1201 | ] |
| 1202 | ), |
| 1203 | ( |
| 1204 | 'geotrust_certs/codex.crt', |
| 1205 | [ |
| 1206 | OrderedDict([ |
| 1207 | ('distribution_point', ['http://gm.symcb.com/gm.crl']), |
| 1208 | ('reasons', None), |
| 1209 | ('crl_issuer', None) |
| 1210 | ]) |
| 1211 | ] |
| 1212 | ), |
wbond | af1f5a8 | 2015-07-17 12:13:15 -0400 | [diff] [blame] | 1213 | ('lets_encrypt/isrgrootx1.pem', []), |
wbond | 6888bc6 | 2015-07-21 15:05:59 -0400 | [diff] [blame] | 1214 | ( |
| 1215 | 'lets_encrypt/letsencryptauthorityx1.pem', |
| 1216 | [ |
| 1217 | OrderedDict([ |
| 1218 | ('distribution_point', ['http://crl.root-x1.letsencrypt.org']), |
| 1219 | ('reasons', None), |
| 1220 | ('crl_issuer', None) |
| 1221 | ]) |
| 1222 | ] |
| 1223 | ), |
| 1224 | ( |
| 1225 | 'lets_encrypt/letsencryptauthorityx2.pem', |
| 1226 | [ |
| 1227 | OrderedDict([ |
| 1228 | ('distribution_point', ['http://crl.root-x1.letsencrypt.org']), |
| 1229 | ('reasons', None), |
| 1230 | ('crl_issuer', None) |
| 1231 | ]) |
| 1232 | ] |
| 1233 | ), |
| 1234 | ( |
| 1235 | 'globalsign_example_keys/IssuingCA-der.cer', |
| 1236 | [ |
| 1237 | OrderedDict([ |
| 1238 | ('distribution_point', ['http://crl.globalsign.com/gs/trustrootcatg2.crl']), |
| 1239 | ('reasons', None), |
| 1240 | ('crl_issuer', None) |
| 1241 | ]) |
| 1242 | ] |
| 1243 | ), |
| 1244 | ( |
| 1245 | 'globalsign_example_keys/rootCA.cer', |
| 1246 | [ |
| 1247 | OrderedDict([ |
| 1248 | ('distribution_point', ['http://crl.globalsign.com/gs/trustrootcatg2.crl']), |
| 1249 | ('reasons', None), |
| 1250 | ('crl_issuer', None) |
| 1251 | ]) |
| 1252 | ] |
| 1253 | ), |
wbond | af1f5a8 | 2015-07-17 12:13:15 -0400 | [diff] [blame] | 1254 | ('globalsign_example_keys/SSL1.cer', []), |
| 1255 | ('globalsign_example_keys/SSL2.cer', []), |
| 1256 | ('globalsign_example_keys/SSL3.cer', []), |
| 1257 | ) |
| 1258 | |
wbond | 6888bc6 | 2015-07-21 15:05:59 -0400 | [diff] [blame] | 1259 | @data('crl_distribution_points_info') |
| 1260 | def crl_distribution_points(self, relative_path, crl_distribution_point): |
wbond | af1f5a8 | 2015-07-17 12:13:15 -0400 | [diff] [blame] | 1261 | cert = self._load_cert(relative_path) |
wbond | 6888bc6 | 2015-07-21 15:05:59 -0400 | [diff] [blame] | 1262 | points = [point.native for point in cert.crl_distribution_points] |
| 1263 | self.assertEqual(crl_distribution_point, points) |
wbond | af1f5a8 | 2015-07-17 12:13:15 -0400 | [diff] [blame] | 1264 | |
| 1265 | #pylint: disable=C0326 |
| 1266 | @staticmethod |
| 1267 | def valid_domains_info(): |
| 1268 | return ( |
| 1269 | ('keys/test-der.crt', []), |
| 1270 | ('keys/test-inter-der.crt', []), |
| 1271 | ('keys/test-third-der.crt', []), |
| 1272 | ('geotrust_certs/GeoTrust_Universal_CA.crt', []), |
| 1273 | ('geotrust_certs/GeoTrust_Primary_CA.crt', []), |
| 1274 | ('geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt', []), |
| 1275 | ('geotrust_certs/codex.crt', ['codexns.io', 'dev.codexns.io', 'rc.codexns.io', 'packagecontrol.io', 'wbond.net']), |
| 1276 | ('lets_encrypt/isrgrootx1.pem', []), |
| 1277 | ('lets_encrypt/letsencryptauthorityx1.pem', []), |
| 1278 | ('lets_encrypt/letsencryptauthorityx2.pem', []), |
| 1279 | ('globalsign_example_keys/IssuingCA-der.cer', []), |
| 1280 | ('globalsign_example_keys/rootCA.cer', []), |
| 1281 | ('globalsign_example_keys/SSL1.cer', ['anything.example.com']), |
| 1282 | ('globalsign_example_keys/SSL2.cer', ['*.google.com', 'anything.example.com']), |
| 1283 | ('globalsign_example_keys/SSL3.cer', ['*.google.com']), |
| 1284 | ) |
| 1285 | |
| 1286 | @data('valid_domains_info') |
| 1287 | def valid_domains(self, relative_path, valid_domains): |
| 1288 | cert = self._load_cert(relative_path) |
| 1289 | self.assertEqual(valid_domains, cert.valid_domains) |
| 1290 | |
| 1291 | #pylint: disable=C0326 |
| 1292 | @staticmethod |
| 1293 | def valid_ips_info(): |
| 1294 | return ( |
| 1295 | ('keys/test-der.crt', []), |
| 1296 | ('keys/test-inter-der.crt', []), |
| 1297 | ('keys/test-third-der.crt', []), |
| 1298 | ('geotrust_certs/GeoTrust_Universal_CA.crt', []), |
| 1299 | ('geotrust_certs/GeoTrust_Primary_CA.crt', []), |
| 1300 | ('geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt', []), |
| 1301 | ('geotrust_certs/codex.crt', []), |
| 1302 | ('lets_encrypt/isrgrootx1.pem', []), |
| 1303 | ('lets_encrypt/letsencryptauthorityx1.pem', []), |
| 1304 | ('lets_encrypt/letsencryptauthorityx2.pem', []), |
| 1305 | ('globalsign_example_keys/IssuingCA-der.cer', []), |
| 1306 | ('globalsign_example_keys/rootCA.cer', []), |
| 1307 | ('globalsign_example_keys/SSL1.cer', []), |
| 1308 | ('globalsign_example_keys/SSL2.cer', []), |
| 1309 | ('globalsign_example_keys/SSL3.cer', []), |
| 1310 | ) |
| 1311 | |
| 1312 | @data('valid_ips_info') |
| 1313 | def valid_ips(self, relative_path, crl_url): |
| 1314 | cert = self._load_cert(relative_path) |
| 1315 | self.assertEqual(crl_url, cert.valid_ips) |
wbond | 8bb77d0 | 2015-07-13 17:44:29 -0400 | [diff] [blame] | 1316 | |
wbond | e91513e | 2015-06-03 14:52:18 -0400 | [diff] [blame] | 1317 | def test_parse_certificate(self): |
wbond | af1f5a8 | 2015-07-17 12:13:15 -0400 | [diff] [blame] | 1318 | cert = self._load_cert('keys/test-der.crt') |
wbond | e91513e | 2015-06-03 14:52:18 -0400 | [diff] [blame] | 1319 | |
| 1320 | tbs_certificate = cert['tbs_certificate'] |
| 1321 | signature = tbs_certificate['signature'] |
| 1322 | issuer = tbs_certificate['issuer'] |
| 1323 | validity = tbs_certificate['validity'] |
| 1324 | subject = tbs_certificate['subject'] |
| 1325 | subject_public_key_info = tbs_certificate['subject_public_key_info'] |
| 1326 | subject_public_key_algorithm = subject_public_key_info['algorithm'] |
| 1327 | subject_public_key = subject_public_key_info['public_key'].parsed |
| 1328 | extensions = tbs_certificate['extensions'] |
| 1329 | |
| 1330 | self.assertEqual( |
| 1331 | 'v3', |
| 1332 | tbs_certificate['version'].native |
| 1333 | ) |
| 1334 | self.assertEqual( |
| 1335 | 13683582341504654466, |
| 1336 | tbs_certificate['serial_number'].native |
| 1337 | ) |
| 1338 | self.assertEqual( |
| 1339 | 'sha256_rsa', |
| 1340 | signature['algorithm'].native |
| 1341 | ) |
| 1342 | self.assertEqual( |
| 1343 | None, |
| 1344 | signature['parameters'].native |
| 1345 | ) |
| 1346 | self.assertEqual( |
| 1347 | OrderedDict([ |
| 1348 | ('country_name', 'US'), |
| 1349 | ('state_or_province_name', 'Massachusetts'), |
| 1350 | ('locality_name', 'Newbury'), |
| 1351 | ('organization_name', 'Codex Non Sufficit LC'), |
| 1352 | ('organizational_unit_name', 'Testing'), |
| 1353 | ('common_name', 'Will Bond'), |
| 1354 | ('email_address', 'will@codexns.io'), |
| 1355 | ]), |
| 1356 | issuer.native |
| 1357 | ) |
| 1358 | self.assertEqual( |
| 1359 | datetime(2015, 5, 6, 14, 37, 16, tzinfo=core.timezone.utc), |
| 1360 | validity['not_before'].native |
| 1361 | ) |
| 1362 | self.assertEqual( |
| 1363 | datetime(2025, 5, 3, 14, 37, 16, tzinfo=core.timezone.utc), |
| 1364 | validity['not_after'].native |
| 1365 | ) |
| 1366 | self.assertEqual( |
| 1367 | OrderedDict([ |
| 1368 | ('country_name', 'US'), |
| 1369 | ('state_or_province_name', 'Massachusetts'), |
| 1370 | ('locality_name', 'Newbury'), |
| 1371 | ('organization_name', 'Codex Non Sufficit LC'), |
| 1372 | ('organizational_unit_name', 'Testing'), |
| 1373 | ('common_name', 'Will Bond'), |
| 1374 | ('email_address', 'will@codexns.io'), |
| 1375 | ]), |
| 1376 | subject.native |
| 1377 | ) |
| 1378 | self.assertEqual( |
| 1379 | 'rsa', |
| 1380 | subject_public_key_algorithm['algorithm'].native |
| 1381 | ) |
| 1382 | self.assertEqual( |
| 1383 | None, |
| 1384 | subject_public_key_algorithm['parameters'].native |
| 1385 | ) |
| 1386 | self.assertEqual( |
| 1387 | 23903990516906431865559598284199534387004799030432486061102966678620221767754702651554142956492614440585611990224871381291841413369032752409360196079700921141819811294444393525264295297988924243231844876926173670633422654261873814968313363171188082579071492839040415373948505938897419917635370450127498164824808630475648771544810334682447182123219422360569466851807131368135806769502898151721274383486320505905826683946456552230958810028663378886363555981449715929872558073101554364803925363048965464124465016494920967179276744892632783712377912841537032383450409486298694116013299423220523450956288827030007092359007, |
| 1388 | subject_public_key['modulus'].native |
| 1389 | ) |
| 1390 | self.assertEqual( |
| 1391 | 65537, |
| 1392 | subject_public_key['public_exponent'].native |
| 1393 | ) |
| 1394 | self.assertEqual( |
| 1395 | None, |
| 1396 | tbs_certificate['issuer_unique_id'].native |
| 1397 | ) |
| 1398 | self.assertIsInstance( |
| 1399 | tbs_certificate['issuer_unique_id'], |
| 1400 | core.NoValue |
| 1401 | ) |
| 1402 | self.assertEqual( |
| 1403 | None, |
| 1404 | tbs_certificate['subject_unique_id'].native |
| 1405 | ) |
| 1406 | self.assertIsInstance( |
| 1407 | tbs_certificate['subject_unique_id'], |
| 1408 | core.NoValue |
| 1409 | ) |
| 1410 | |
| 1411 | self.maxDiff = None |
| 1412 | for extension in extensions: |
| 1413 | self.assertIsInstance( |
| 1414 | extension, |
| 1415 | x509.Extension |
| 1416 | ) |
| 1417 | self.assertEqual( |
| 1418 | [ |
| 1419 | OrderedDict([ |
| 1420 | ('extn_id', 'key_identifier'), |
| 1421 | ('critical', False), |
| 1422 | ('extn_value', b'\xBE\x42\x85\x3D\xCC\xFF\xE3\xF9\x28\x02\x8F\x7E\x58\x56\xB4\xFD\x03\x5C\xEA\x4B'), |
| 1423 | ]), |
| 1424 | OrderedDict([ |
| 1425 | ('extn_id', 'authority_key_identifier'), |
| 1426 | ('critical', False), |
| 1427 | ( |
| 1428 | 'extn_value', |
| 1429 | OrderedDict([ |
| 1430 | ('key_identifier', b'\xBE\x42\x85\x3D\xCC\xFF\xE3\xF9\x28\x02\x8F\x7E\x58\x56\xB4\xFD\x03\x5C\xEA\x4B'), |
| 1431 | ( |
| 1432 | 'authority_cert_issuer', |
| 1433 | [ |
| 1434 | OrderedDict([ |
| 1435 | ('country_name', 'US'), |
| 1436 | ('state_or_province_name', 'Massachusetts'), |
| 1437 | ('locality_name', 'Newbury'), |
| 1438 | ('organization_name', 'Codex Non Sufficit LC'), |
| 1439 | ('organizational_unit_name', 'Testing'), |
| 1440 | ('common_name', 'Will Bond'), |
| 1441 | ('email_address', 'will@codexns.io'), |
| 1442 | ]) |
| 1443 | ] |
| 1444 | ), |
| 1445 | ('authority_cert_serial_number', 13683582341504654466), |
| 1446 | ]) |
| 1447 | ), |
| 1448 | ]), |
| 1449 | OrderedDict([ |
| 1450 | ('extn_id', 'basic_constraints'), |
| 1451 | ('critical', False), |
| 1452 | ( |
| 1453 | 'extn_value', |
| 1454 | OrderedDict([ |
| 1455 | ('ca', True), |
| 1456 | ('path_len_constraint', None) |
| 1457 | ]) |
| 1458 | ), |
| 1459 | ]), |
| 1460 | ], |
| 1461 | extensions.native |
| 1462 | ) |
| 1463 | |
| 1464 | def test_parse_dsa_certificate(self): |
wbond | af1f5a8 | 2015-07-17 12:13:15 -0400 | [diff] [blame] | 1465 | cert = self._load_cert('keys/test-dsa-der.crt') |
wbond | e91513e | 2015-06-03 14:52:18 -0400 | [diff] [blame] | 1466 | |
| 1467 | tbs_certificate = cert['tbs_certificate'] |
| 1468 | signature = tbs_certificate['signature'] |
| 1469 | issuer = tbs_certificate['issuer'] |
| 1470 | validity = tbs_certificate['validity'] |
| 1471 | subject = tbs_certificate['subject'] |
| 1472 | subject_public_key_info = tbs_certificate['subject_public_key_info'] |
| 1473 | subject_public_key_algorithm = subject_public_key_info['algorithm'] |
| 1474 | subject_public_key = subject_public_key_info['public_key'].parsed |
| 1475 | extensions = tbs_certificate['extensions'] |
| 1476 | |
| 1477 | self.assertEqual( |
| 1478 | 'v3', |
| 1479 | tbs_certificate['version'].native |
| 1480 | ) |
| 1481 | self.assertEqual( |
| 1482 | 14308214745771946523, |
| 1483 | tbs_certificate['serial_number'].native |
| 1484 | ) |
| 1485 | self.assertEqual( |
| 1486 | 'sha256_dsa', |
| 1487 | signature['algorithm'].native |
| 1488 | ) |
| 1489 | self.assertEqual( |
| 1490 | None, |
| 1491 | signature['parameters'].native |
| 1492 | ) |
| 1493 | self.assertEqual( |
| 1494 | OrderedDict([ |
| 1495 | ('country_name', 'US'), |
| 1496 | ('state_or_province_name', 'Massachusetts'), |
| 1497 | ('locality_name', 'Newbury'), |
| 1498 | ('organization_name', 'Codex Non Sufficit LC'), |
| 1499 | ('organizational_unit_name', 'Testing'), |
| 1500 | ('common_name', 'Will Bond'), |
| 1501 | ('email_address', 'will@codexns.io'), |
| 1502 | ]), |
| 1503 | issuer.native |
| 1504 | ) |
| 1505 | self.assertEqual( |
| 1506 | datetime(2015, 5, 20, 13, 9, 2, tzinfo=core.timezone.utc), |
| 1507 | validity['not_before'].native |
| 1508 | ) |
| 1509 | self.assertEqual( |
| 1510 | datetime(2025, 5, 17, 13, 9, 2, tzinfo=core.timezone.utc), |
| 1511 | validity['not_after'].native |
| 1512 | ) |
| 1513 | self.assertEqual( |
| 1514 | OrderedDict([ |
| 1515 | ('country_name', 'US'), |
| 1516 | ('state_or_province_name', 'Massachusetts'), |
| 1517 | ('locality_name', 'Newbury'), |
| 1518 | ('organization_name', 'Codex Non Sufficit LC'), |
| 1519 | ('organizational_unit_name', 'Testing'), |
| 1520 | ('common_name', 'Will Bond'), |
| 1521 | ('email_address', 'will@codexns.io'), |
| 1522 | ]), |
| 1523 | subject.native |
| 1524 | ) |
| 1525 | self.assertEqual( |
| 1526 | 'dsa', |
| 1527 | subject_public_key_algorithm['algorithm'].native |
| 1528 | ) |
| 1529 | self.assertEqual( |
| 1530 | OrderedDict([ |
| 1531 | ('p', 4511743893397705393934377497936985478231822206263141826261443300639402520800626925517264115785551703273809312112372693877437137848393530691841757974971843334497076835630893064661599193178307024379015589119302113551197423138934242435710226975119594589912289060014025377813473273600967729027125618396732574594753039493158066887433778053086408525146692226448554390096911703556213619406958876388642882534250747780313634767409586007581976273681005928967585750017105562145167146445061803488570714706090280814293902464230717946651489964409785146803791743658888866280873858000476717727810363942159874283767926511678640730707887895260274767195555813448140889391762755466967436731106514029224490921857229134393798015954890071206959203407845438863870686180087606429828973298318856683615900474921310376145478859687052812749087809700610549251964102790514588562086548577933609968589710807989944739877028770343142449461177732058649962678857), |
| 1532 | ('q', 71587850165936478337655415373676526523562874562337607790945426056266440596923), |
| 1533 | ('g', 761437146067908309288345767887973163494473925243194806582679580640442238588269326525839153095505341738937595419375068472941615006110237832663093084973431440436421580371384720052414080562019831325744042316268714195397974084616335082272743706567701546951285088540646372701485690904535540223121118329044403681933304838754517522024738251994717369464179515923093116622352823578284891812676662979104509631349201801577889230316128523885862472086364717411346341249139971907827526291913249445756671582283459372536334490171231311487207683108274785825764378203622999309355578169139646003751751448501475767709869676880946562283552431757983801739671783678927397420797147373441051876558068212062253171347849380506793433921881336652424898488378657239798694995315456959568806256079056461448199493507273882763491729787817044805150879660784158902456811649964987582162907020243296662602990514615480712948126671999033658064244112238138589732202), |
| 1534 | ]), |
| 1535 | subject_public_key_algorithm['parameters'].native |
| 1536 | ) |
| 1537 | self.assertEqual( |
| 1538 | 934231235067929794039535952071098031636053793876274937162425423023735221571983693370780054696865229184537343792766496068557051933738826401423094028670222490622041397241325320965905259541032379046252395145258594355589801644789631904099105867133976990593761395721476198083091062806327384261369876465927159169400428623265291958463077792777155465482611741502621885386691681062128487785344975981628995609792181581218570320181053055516069553767918513262908069925035292416868414952256645902605335068760774106734518308281769128146479819566784704033671969858507248124850451414380441279385481154336362988505436125981975735568289420374790767927084033441728922597082155884801013899630856890463962357814273014111039522903328923758417820349377075487103441305806369234738881875734407495707878637895190993370257589211331043479113328811265005530361001980539377903738453549980082795009589559114091215518866106998956304437954236070776810740036, |
| 1539 | subject_public_key.native |
| 1540 | ) |
| 1541 | self.assertEqual( |
| 1542 | None, |
| 1543 | tbs_certificate['issuer_unique_id'].native |
| 1544 | ) |
| 1545 | self.assertIsInstance( |
| 1546 | tbs_certificate['issuer_unique_id'], |
| 1547 | core.NoValue |
| 1548 | ) |
| 1549 | self.assertEqual( |
| 1550 | None, |
| 1551 | tbs_certificate['subject_unique_id'].native |
| 1552 | ) |
| 1553 | self.assertIsInstance( |
| 1554 | tbs_certificate['subject_unique_id'], |
| 1555 | core.NoValue |
| 1556 | ) |
| 1557 | |
| 1558 | self.maxDiff = None |
| 1559 | for extension in extensions: |
| 1560 | self.assertIsInstance( |
| 1561 | extension, |
| 1562 | x509.Extension |
| 1563 | ) |
| 1564 | self.assertEqual( |
| 1565 | [ |
| 1566 | OrderedDict([ |
| 1567 | ('extn_id', 'key_identifier'), |
| 1568 | ('critical', False), |
| 1569 | ('extn_value', b'\x81\xA3\x37\x86\xF9\x99\x28\xF2\x74\x70\x60\x87\xF2\xD3\x7E\x8D\x19\x61\xA8\xBE'), |
| 1570 | ]), |
| 1571 | OrderedDict([ |
| 1572 | ('extn_id', 'authority_key_identifier'), |
| 1573 | ('critical', False), |
| 1574 | ( |
| 1575 | 'extn_value', |
| 1576 | OrderedDict([ |
| 1577 | ('key_identifier', b'\x81\xA3\x37\x86\xF9\x99\x28\xF2\x74\x70\x60\x87\xF2\xD3\x7E\x8D\x19\x61\xA8\xBE'), |
| 1578 | ('authority_cert_issuer', None), |
| 1579 | ('authority_cert_serial_number', None), |
| 1580 | ]) |
| 1581 | ), |
| 1582 | ]), |
| 1583 | OrderedDict([ |
| 1584 | ('extn_id', 'basic_constraints'), |
| 1585 | ('critical', False), |
| 1586 | ( |
| 1587 | 'extn_value', |
| 1588 | OrderedDict([ |
| 1589 | ('ca', True), |
| 1590 | ('path_len_constraint', None) |
| 1591 | ]) |
| 1592 | ), |
| 1593 | ]), |
| 1594 | ], |
| 1595 | extensions.native |
| 1596 | ) |
| 1597 | |
| 1598 | def test_parse_ec_certificate(self): |
wbond | af1f5a8 | 2015-07-17 12:13:15 -0400 | [diff] [blame] | 1599 | cert = self._load_cert('keys/test-ec-der.crt') |
wbond | e91513e | 2015-06-03 14:52:18 -0400 | [diff] [blame] | 1600 | |
| 1601 | tbs_certificate = cert['tbs_certificate'] |
| 1602 | signature = tbs_certificate['signature'] |
| 1603 | issuer = tbs_certificate['issuer'] |
| 1604 | validity = tbs_certificate['validity'] |
| 1605 | subject = tbs_certificate['subject'] |
| 1606 | subject_public_key_info = tbs_certificate['subject_public_key_info'] |
| 1607 | subject_public_key_algorithm = subject_public_key_info['algorithm'] |
| 1608 | public_key_params = subject_public_key_info['algorithm']['parameters'].chosen |
| 1609 | field_id = public_key_params['field_id'] |
| 1610 | curve = public_key_params['curve'] |
| 1611 | subject_public_key = subject_public_key_info['public_key'].parsed |
| 1612 | extensions = tbs_certificate['extensions'] |
| 1613 | |
| 1614 | self.assertEqual( |
| 1615 | 'v3', |
| 1616 | tbs_certificate['version'].native |
| 1617 | ) |
| 1618 | self.assertEqual( |
| 1619 | 15854128451240978884, |
| 1620 | tbs_certificate['serial_number'].native |
| 1621 | ) |
| 1622 | self.assertEqual( |
| 1623 | 'sha256_ecdsa', |
| 1624 | signature['algorithm'].native |
| 1625 | ) |
| 1626 | self.assertEqual( |
| 1627 | None, |
| 1628 | signature['parameters'].native |
| 1629 | ) |
| 1630 | self.assertEqual( |
| 1631 | OrderedDict([ |
| 1632 | ('country_name', 'US'), |
| 1633 | ('state_or_province_name', 'Massachusetts'), |
| 1634 | ('locality_name', 'Newbury'), |
| 1635 | ('organization_name', 'Codex Non Sufficit LC'), |
| 1636 | ('organizational_unit_name', 'Testing'), |
| 1637 | ('common_name', 'Will Bond'), |
| 1638 | ('email_address', 'will@codexns.io'), |
| 1639 | ]), |
| 1640 | issuer.native |
| 1641 | ) |
| 1642 | self.assertEqual( |
| 1643 | datetime(2015, 5, 20, 12, 56, 46, tzinfo=core.timezone.utc), |
| 1644 | validity['not_before'].native |
| 1645 | ) |
| 1646 | self.assertEqual( |
| 1647 | datetime(2025, 5, 17, 12, 56, 46, tzinfo=core.timezone.utc), |
| 1648 | validity['not_after'].native |
| 1649 | ) |
| 1650 | self.assertEqual( |
| 1651 | OrderedDict([ |
| 1652 | ('country_name', 'US'), |
| 1653 | ('state_or_province_name', 'Massachusetts'), |
| 1654 | ('locality_name', 'Newbury'), |
| 1655 | ('organization_name', 'Codex Non Sufficit LC'), |
| 1656 | ('organizational_unit_name', 'Testing'), |
| 1657 | ('common_name', 'Will Bond'), |
| 1658 | ('email_address', 'will@codexns.io'), |
| 1659 | ]), |
| 1660 | subject.native |
| 1661 | ) |
| 1662 | self.assertEqual( |
wbond | 680cba1 | 2015-07-01 23:53:54 -0400 | [diff] [blame] | 1663 | 'ec', |
wbond | e91513e | 2015-06-03 14:52:18 -0400 | [diff] [blame] | 1664 | subject_public_key_algorithm['algorithm'].native |
| 1665 | ) |
| 1666 | self.assertEqual( |
| 1667 | 'ecdpVer1', |
| 1668 | public_key_params['version'].native |
| 1669 | ) |
| 1670 | self.assertEqual( |
| 1671 | 'prime_field', |
| 1672 | field_id['field_type'].native |
| 1673 | ) |
| 1674 | self.assertEqual( |
| 1675 | 115792089210356248762697446949407573530086143415290314195533631308867097853951, |
| 1676 | field_id['parameters'].native |
| 1677 | ) |
| 1678 | self.assertEqual( |
| 1679 | b'\xFF\xFF\xFF\xFF\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFC', |
| 1680 | curve['a'].native |
| 1681 | ) |
| 1682 | self.assertEqual( |
| 1683 | b'\x5A\xC6\x35\xD8\xAA\x3A\x93\xE7\xB3\xEB\xBD\x55\x76\x98\x86\xBC\x65\x1D\x06\xB0\xCC\x53\xB0\xF6\x3B\xCE\x3C\x3E\x27\xD2\x60\x4B', |
| 1684 | curve['b'].native |
| 1685 | ) |
| 1686 | self.assertEqual( |
| 1687 | b'\xC4\x9D\x36\x08\x86\xE7\x04\x93\x6A\x66\x78\xE1\x13\x9D\x26\xB7\x81\x9F\x7E\x90', |
| 1688 | curve['seed'].native |
| 1689 | ) |
| 1690 | self.assertEqual( |
| 1691 | b'\x04\x6B\x17\xD1\xF2\xE1\x2C\x42\x47\xF8\xBC\xE6\xE5\x63\xA4\x40\xF2\x77\x03\x7D\x81\x2D\xEB\x33\xA0\xF4\xA1\x39\x45\xD8\x98\xC2\x96\x4F\xE3\x42\xE2\xFE\x1A\x7F\x9B\x8E\xE7\xEB\x4A\x7C\x0F\x9E\x16\x2B\xCE\x33\x57\x6B\x31\x5E\xCE\xCB\xB6\x40\x68\x37\xBF\x51\xF5', |
| 1692 | public_key_params['base'].native |
| 1693 | ) |
| 1694 | self.assertEqual( |
| 1695 | 115792089210356248762697446949407573529996955224135760342422259061068512044369, |
| 1696 | public_key_params['order'].native |
| 1697 | ) |
| 1698 | self.assertEqual( |
| 1699 | 1, |
| 1700 | public_key_params['cofactor'].native |
| 1701 | ) |
| 1702 | self.assertEqual( |
| 1703 | None, |
| 1704 | public_key_params['hash'].native |
| 1705 | ) |
| 1706 | self.assertEqual( |
| 1707 | b'G\x9f\xcbs$\x1d\xc9\xdd\xd1-\xf1:\x9f\xb7\x04\xde \xd0X\x00\x93T\xf6\x89\xc7/\x87+\xf7\xf9=;4\xed\x9e{\x0e=WB\xdfx\x03\x0b\xcc1\xc6\x03\xd7\x9f`\x01', |
| 1708 | subject_public_key.native |
| 1709 | ) |
| 1710 | self.assertEqual( |
| 1711 | None, |
| 1712 | tbs_certificate['issuer_unique_id'].native |
| 1713 | ) |
| 1714 | self.assertIsInstance( |
| 1715 | tbs_certificate['issuer_unique_id'], |
| 1716 | core.NoValue |
| 1717 | ) |
| 1718 | self.assertEqual( |
| 1719 | None, |
| 1720 | tbs_certificate['subject_unique_id'].native |
| 1721 | ) |
| 1722 | self.assertIsInstance( |
| 1723 | tbs_certificate['subject_unique_id'], |
| 1724 | core.NoValue |
| 1725 | ) |
| 1726 | |
| 1727 | self.maxDiff = None |
| 1728 | for extension in extensions: |
| 1729 | self.assertIsInstance( |
| 1730 | extension, |
| 1731 | x509.Extension |
| 1732 | ) |
| 1733 | self.assertEqual( |
| 1734 | [ |
| 1735 | OrderedDict([ |
| 1736 | ('extn_id', 'key_identifier'), |
| 1737 | ('critical', False), |
| 1738 | ('extn_value', b'\x54\xAA\x54\x70\x6C\x34\x1A\x6D\xEB\x5D\x97\xD7\x1E\xFC\xD5\x24\x3C\x8A\x0E\xD7'), |
| 1739 | ]), |
| 1740 | OrderedDict([ |
| 1741 | ('extn_id', 'authority_key_identifier'), |
| 1742 | ('critical', False), |
| 1743 | ( |
| 1744 | 'extn_value', |
| 1745 | OrderedDict([ |
| 1746 | ('key_identifier', b'\x54\xAA\x54\x70\x6C\x34\x1A\x6D\xEB\x5D\x97\xD7\x1E\xFC\xD5\x24\x3C\x8A\x0E\xD7'), |
| 1747 | ('authority_cert_issuer', None), |
| 1748 | ('authority_cert_serial_number', None), |
| 1749 | ]) |
| 1750 | ), |
| 1751 | ]), |
| 1752 | OrderedDict([ |
| 1753 | ('extn_id', 'basic_constraints'), |
| 1754 | ('critical', False), |
| 1755 | ( |
| 1756 | 'extn_value', |
| 1757 | OrderedDict([ |
| 1758 | ('ca', True), |
| 1759 | ('path_len_constraint', None) |
| 1760 | ]) |
| 1761 | ), |
| 1762 | ]), |
| 1763 | ], |
| 1764 | extensions.native |
| 1765 | ) |