1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
|
X.509
=====
.. currentmodule:: cryptography.x509
.. testsetup::
pem_req_data = b"""
-----BEGIN CERTIFICATE REQUEST-----
MIIC0zCCAbsCAQAwWTELMAkGA1UEBhMCVVMxETAPBgNVBAgMCElsbGlub2lzMRAw
DgYDVQQHDAdDaGljYWdvMREwDwYDVQQKDAhyNTA5IExMQzESMBAGA1UEAwwJaGVs
bG8uY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqhZx+Mo9VRd9
vsnWWa6NBCws21rZ0+1B/JGgB4hDsZS7iDE4Bj5z4idheFRtl8bBbdjPknq7BfoF
8v15Zq/Zv7i2xMSDL+LUrTBZezRd4bRTGqCm6YJ5EYkhqdcqeZleHCFImguHoq1J
Fh0+kObQrTHXw3ZP57a3o1IvyIUA3nNoCBL0QQhwBXaDXOojMKNR+bqB5ve8GS1y
Elr0AM/+cJsfaIahNQUgFKx3Eu3GeEOMKYOAG1lycgdQdmTUybLrT3U7vkClTseM
xHg1r5En7ALjONIhqRuq3rddYahrP8HXozb3zUy3cJ7P6IeaosuvNzvMXOX9P6HD
Ha9urDAJ1wIDAQABoDUwMwYJKoZIhvcNAQkOMSYwJDAiBgNVHREEGzAZggl3b3Js
ZC5jb22CDHdoYXRldmVyLmNvbTANBgkqhkiG9w0BAQUFAAOCAQEAS4Ro6h+z52SK
YSLCYARpnEu/rmh4jdqndt8naqcNb6uLx9mlKZ2W9on9XDjnSdQD9q+ZP5aZfESw
R0+rJhW9ZrNa/g1pt6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xlZ2FsMA0G
CSqGSIb3DQEBCwUAA4IBAQAzIYO2jx7h17FBT74tJ2zbV9OKqGb7QF8y3wUtP4xc
dH80vprI/Cfji8s86kr77aAvAqjDjaVjHn7UzebhSUivvRPmfzRgyWBacomnXTSt
Xlt2dp2nDQuwGyK2vB7dMfKnQAkxwq1sYUXznB8i0IhhCAoXp01QGPKq51YoIlnF
7DRMk6iEaL1SJbkIrLsCQyZFDf0xtfW9DqXugMMLoxeCsBhZJQzNyS2ryirrv9LH
aK3+6IZjrcyy9bkpz/gzJucyhU+75c4My/mnRCrtItRbCQuiI5pd5poDowm+HH9i
GVI9+0lAFwxOUnOnwsoI40iOoxjLMGB+CgFLKCGUcWxP
-----END CERTIFICATE-----
""".strip()
X.509 is an ITU-T standard for a `public key infrastructure`_. X.509v3 is
defined in :rfc:`5280` (which obsoletes :rfc:`2459` and :rfc:`3280`). X.509
certificates are commonly used in protocols like `TLS`_.
Loading Certificates
~~~~~~~~~~~~~~~~~~~~
.. function:: load_pem_x509_certificate(data, backend)
.. versionadded:: 0.7
Deserialize a certificate from PEM encoded data. PEM certificates are
base64 decoded and have delimiters that look like
``-----BEGIN CERTIFICATE-----``.
:param bytes data: The PEM encoded certificate data.
:param backend: A backend supporting the
:class:`~cryptography.hazmat.backends.interfaces.X509Backend`
interface.
:returns: An instance of :class:`~cryptography.x509.Certificate`.
.. function:: load_der_x509_certificate(data, backend)
.. versionadded:: 0.7
Deserialize a certificate from DER encoded data. DER is a binary format
and is commonly found in files with the ``.cer`` extension (although file
extensions are not a guarantee of encoding type).
:param bytes data: The DER encoded certificate data.
:param backend: A backend supporting the
:class:`~cryptography.hazmat.backends.interfaces.X509Backend`
interface.
:returns: An instance of :class:`~cryptography.x509.Certificate`.
.. doctest::
>>> from cryptography import x509
>>> from cryptography.hazmat.backends import default_backend
>>> cert = x509.load_pem_x509_certificate(pem_data, default_backend())
>>> cert.serial
2
Loading Certificate Signing Requests
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. function:: load_pem_x509_csr(data, backend)
.. versionadded:: 0.9
Deserialize a certificate signing request (CSR) from PEM encoded data. PEM
requests are base64 decoded and have delimiters that look like
``-----BEGIN CERTIFICATE REQUEST-----``. This format is also known as
PKCS#10.
:param bytes data: The PEM encoded request data.
:param backend: A backend supporting the
:class:`~cryptography.hazmat.backends.interfaces.X509Backend`
interface.
:returns: An instance of
:class:`~cryptography.x509.CertificateSigningRequest`.
.. function:: load_der_x509_csr(data, backend)
.. versionadded:: 0.9
Deserialize a certificate signing request (CSR) from DER encoded data. DER
is a binary format and is not commonly used with CSRs.
:param bytes data: The DER encoded request data.
:param backend: A backend supporting the
:class:`~cryptography.hazmat.backends.interfaces.X509Backend`
interface.
:returns: An instance of
:class:`~cryptography.x509.CertificateSigningRequest`.
.. doctest::
>>> from cryptography import x509
>>> from cryptography.hazmat.backends import default_backend
>>> from cryptography.hazmat.primitives import hashes
>>> csr = x509.load_pem_x509_csr(pem_req_data, default_backend())
>>> isinstance(csr.signature_hash_algorithm, hashes.SHA1)
True
X.509 Certificate Object
~~~~~~~~~~~~~~~~~~~~~~~~
.. class:: Certificate
.. versionadded:: 0.7
.. attribute:: version
:type: :class:`~cryptography.x509.Version`
The certificate version as an enumeration. Version 3 certificates are
the latest version and also the only type you should see in practice.
:raises cryptography.x509.InvalidVersion: If the version in the
certificate is not a known
:class:`X.509 version <cryptography.x509.Version>`.
.. doctest::
>>> cert.version
<Version.v3: 2>
.. method:: fingerprint(algorithm)
:param algorithm: The
:class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm`
that will be used to generate the fingerprint.
:return bytes: The fingerprint using the supplied hash algorithm, as
bytes.
.. doctest::
>>> from cryptography.hazmat.primitives import hashes
>>> cert.fingerprint(hashes.SHA256())
'\x86\xd2\x187Gc\xfc\xe7}[+E9\x8d\xb4\x8f\x10\xe5S\xda\x18u\xbe}a\x03\x08[\xac\xa04?'
.. attribute:: serial
:type: int
The serial as a Python integer.
.. doctest::
>>> cert.serial
2
.. method:: public_key()
:type:
:class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey` or
:class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPublicKey` or
:class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey`
The public key associated with the certificate.
.. doctest::
>>> from cryptography.hazmat.primitives.asymmetric import rsa
>>> public_key = cert.public_key()
>>> isinstance(public_key, rsa.RSAPublicKey)
True
.. attribute:: not_valid_before
:type: :class:`datetime.datetime`
A naïve datetime representing the beginning of the validity period for
the certificate in UTC. This value is inclusive.
.. doctest::
>>> cert.not_valid_before
datetime.datetime(2010, 1, 1, 8, 30)
.. attribute:: not_valid_after
:type: :class:`datetime.datetime`
A naïve datetime representing the end of the validity period for the
certificate in UTC. This value is inclusive.
.. doctest::
>>> cert.not_valid_after
datetime.datetime(2030, 12, 31, 8, 30)
.. attribute:: issuer
.. versionadded:: 0.8
:type: :class:`Name`
The :class:`Name` of the issuer.
.. attribute:: subject
.. versionadded:: 0.8
:type: :class:`Name`
The :class:`Name` of the subject.
.. attribute:: signature_hash_algorithm
:type: :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm`
Returns the
:class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` which
was used in signing this certificate.
.. doctest::
>>> from cryptography.hazmat.primitives import hashes
>>> isinstance(cert.signature_hash_algorithm, hashes.SHA256)
True
.. attribute:: extensions
:type: :class:`Extensions`
The extensions encoded in the certificate.
:raises cryptography.x509.DuplicateExtension: If more than one
extension of the same type is found within the certificate.
:raises cryptography.x509.UnsupportedExtension: If the certificate
contains an extension that is not supported.
:raises cryptography.x509.UnsupportedGeneralNameType: If an extension
contains a general name that is not supported.
:raises UnicodeError: If an extension contains IDNA encoding that is
invalid or not compliant with IDNA 2008.
.. doctest::
>>> for ext in cert.extensions:
... print(ext)
<Extension(oid=<ObjectIdentifier(oid=2.5.29.35, name=authorityKeyIdentifier)>, critical=False, value=<AuthorityKeyIdentifier(key_identifier='\xe4}_\xd1\\\x95\x86\x08,\x05\xae\xbeu\xb6e\xa7\xd9]\xa8f', authority_cert_issuer=None, authority_cert_serial_number=None)>)>
<Extension(oid=<ObjectIdentifier(oid=2.5.29.14, name=subjectKeyIdentifier)>, critical=False, value=<SubjectKeyIdentifier(digest='X\x01\x84$\x1b\xbc+R\x94J=\xa5\x10r\x14Q\xf5\xaf:\xc9')>)>
<Extension(oid=<ObjectIdentifier(oid=2.5.29.15, name=keyUsage)>, critical=True, value=<KeyUsage(digital_signature=False, content_commitment=False, key_encipherment=False, data_encipherment=False, key_agreement=False, key_cert_sign=True, crl_sign=True, encipher_only=None, decipher_only=None)>)>
<Extension(oid=<ObjectIdentifier(oid=2.5.29.32, name=certificatePolicies)>, critical=False, value=<CertificatePolicies([<PolicyInformation(policy_identifier=<ObjectIdentifier(oid=2.16.840.1.101.3.2.1.48.1, name=Unknown OID)>, policy_qualifiers=None)>])>)>
<Extension(oid=<ObjectIdentifier(oid=2.5.29.19, name=basicConstraints)>, critical=True, value=<BasicConstraints(ca=True, path_length=None)>)>
.. method:: public_bytes(encoding)
:param encoding: The
:class:`~cryptography.hazmat.primitives.serialization.Encoding`
that will be used to serialize the certificate.
:return bytes: The data that can be written to a file or sent
over the network to be verified by clients.
X.509 CRL (Certificate Revocation List) Object
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. class:: CertificateRevocationList
.. versionadded:: 1.0
.. method:: fingerprint(algorithm)
:param algorithm: The
:class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm`
that will be used to generate the fingerprint.
:return bytes: The fingerprint using the supplied hash algorithm, as
bytes.
.. attribute:: signature_hash_algorithm
:type: :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm`
Returns the
:class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` which
was used in signing this CRL.
.. attribute:: issuer
:type: :class:`Name`
The :class:`Name` of the issuer.
.. attribute:: next_update
:type: :class:`datetime.datetime`
A naïve datetime representing when the next update to this CRL is
expected.
.. attribute:: last_update
:type: :class:`datetime.datetime`
A naïve datetime representing when the this CRL was last updated.
.. attribute:: revoked_certificates
:type: list of :class:`RevokedCertificate`
The revoked certificates listed in this CRL.
.. attribute:: extensions
:type: :class:`Extensions`
The extensions encoded in the CRL.
X.509 CSR (Certificate Signing Request) Object
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. class:: CertificateSigningRequest
.. versionadded:: 0.9
.. method:: public_key()
:type:
:class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey` or
:class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPublicKey` or
:class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey`
The public key associated with the request.
.. doctest::
>>> from cryptography.hazmat.primitives.asymmetric import rsa
>>> public_key = csr.public_key()
>>> isinstance(public_key, rsa.RSAPublicKey)
True
.. attribute:: subject
:type: :class:`Name`
The :class:`Name` of the subject.
.. attribute:: signature_hash_algorithm
:type: :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm`
Returns the
:class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` which
was used in signing this request.
.. doctest::
>>> from cryptography.hazmat.primitives import hashes
>>> isinstance(csr.signature_hash_algorithm, hashes.SHA1)
True
.. method:: public_bytes(encoding)
:param encoding: The
:class:`~cryptography.hazmat.primitives.serialization.Encoding`
that will be used to serialize the certificate request.
:return bytes: The data that can be written to a file or sent
over the network to be signed by the certificate
authority.
X.509 Revoked Certificate Object
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. class:: RevokedCertificate
.. versionadded:: 1.0
.. attribute:: serial_number
:type: :class:`int`
An integer representing the serial number of the revoked certificate.
.. attribute:: revocation_date
:type: :class:`datetime.datetime`
A naïve datetime representing the date this certificates was revoked.
.. attribute:: extensions
:type: :class:`Extensions`
The extensions encoded in the revoked certificate.
.. class:: Name
.. versionadded:: 0.8
An X509 Name is an ordered list of attributes. The object is iterable to
get every attribute or you can use :meth:`Name.get_attributes_for_oid` to
obtain the specific type you want. Names are sometimes represented as a
slash or comma delimited string (e.g. ``/CN=mydomain.com/O=My Org/C=US`` or
``CN=mydomain.com, O=My Org, C=US``).
.. doctest::
>>> len(cert.subject)
3
>>> for attribute in cert.subject:
... print(attribute)
<NameAttribute(oid=<ObjectIdentifier(oid=2.5.4.6, name=countryName)>, value=u'US')>
<NameAttribute(oid=<ObjectIdentifier(oid=2.5.4.10, name=organizationName)>, value=u'Test Certificates 2011')>
<NameAttribute(oid=<ObjectIdentifier(oid=2.5.4.3, name=commonName)>, value=u'Good CA')>
.. method:: get_attributes_for_oid(oid)
:param oid: An :class:`ObjectIdentifier` instance.
:returns: A list of :class:`NameAttribute` instances that match the
OID provided. If nothing matches an empty list will be returned.
.. doctest::
>>> cert.subject.get_attributes_for_oid(x509.OID_COMMON_NAME)
[<NameAttribute(oid=<ObjectIdentifier(oid=2.5.4.3, name=commonName)>, value=u'Good CA')>]
.. class:: Version
.. versionadded:: 0.7
An enumeration for X.509 versions.
.. attribute:: v1
For version 1 X.509 certificates.
.. attribute:: v3
For version 3 X.509 certificates.
.. class:: NameAttribute
.. versionadded:: 0.8
An X.509 name consists of a list of NameAttribute instances.
.. attribute:: oid
:type: :class:`ObjectIdentifier`
The attribute OID.
.. attribute:: value
:type: :term:`text`
The value of the attribute.
.. class:: ObjectIdentifier
.. versionadded:: 0.8
Object identifiers (frequently seen abbreviated as OID) identify the type
of a value (see: :class:`NameAttribute`).
.. attribute:: dotted_string
:type: :class:`str`
The dotted string value of the OID (e.g. ``"2.5.4.3"``)
.. _general_name_classes:
General Name Classes
~~~~~~~~~~~~~~~~~~~~
.. class:: GeneralName
.. versionadded:: 0.9
This is the generic interface that all the following classes are registered
against.
.. class:: RFC822Name
.. versionadded:: 0.9
This corresponds to an email address. For example, ``user@example.com``.
.. attribute:: value
:type: :term:`text`
.. class:: DNSName
.. versionadded:: 0.9
This corresponds to a domain name. For example, ``cryptography.io``.
.. attribute:: value
:type: :term:`text`
.. class:: DirectoryName
.. versionadded:: 0.9
This corresponds to a directory name.
.. attribute:: value
:type: :class:`Name`
.. class:: UniformResourceIdentifier
.. versionadded:: 0.9
This corresponds to a uniform resource identifier. For example,
``https://cryptography.io``. The URI is parsed and IDNA decoded (see
:rfc:`5895`).
.. note::
URIs that do not contain ``://`` in them will not be decoded.
.. attribute:: value
:type: :term:`text`
.. class:: IPAddress
.. versionadded:: 0.9
This corresponds to an IP address.
.. attribute:: value
:type: :class:`~ipaddress.IPv4Address`,
:class:`~ipaddress.IPv6Address`, :class:`~ipaddress.IPv4Network`,
or :class:`~ipaddress.IPv6Network`.
.. class:: RegisteredID
.. versionadded:: 0.9
This corresponds to a registered ID.
.. attribute:: value
:type: :class:`ObjectIdentifier`
X.509 Extensions
~~~~~~~~~~~~~~~~
.. class:: Extensions
.. versionadded:: 0.9
An X.509 Extensions instance is an ordered list of extensions. The object
is iterable to get every extension.
.. method:: get_extension_for_oid(oid)
:param oid: An :class:`ObjectIdentifier` instance.
:returns: An instance of the extension class.
:raises cryptography.x509.ExtensionNotFound: If the certificate does
not have the extension requested.
.. doctest::
>>> cert.extensions.get_extension_for_oid(x509.OID_BASIC_CONSTRAINTS)
<Extension(oid=<ObjectIdentifier(oid=2.5.29.19, name=basicConstraints)>, critical=True, value=<BasicConstraints(ca=True, path_length=None)>)>
.. class:: Extension
.. versionadded:: 0.9
.. attribute:: oid
:type: :class:`ObjectIdentifier`
The :ref:`extension OID <extension_oids>`.
.. attribute:: critical
:type: bool
Determines whether a given extension is critical or not. :rfc:`5280`
requires that "A certificate-using system MUST reject the certificate
if it encounters a critical extension it does not recognize or a
critical extension that contains information that it cannot process".
.. attribute:: value
Returns an instance of the extension type corresponding to the OID.
.. class:: KeyUsage
.. versionadded:: 0.9
The key usage extension defines the purpose of the key contained in the
certificate. The usage restriction might be employed when a key that could
be used for more than one operation is to be restricted. It corresponds to
:data:`OID_KEY_USAGE`.
.. attribute:: digital_signature
:type: bool
This purpose is set to true when the subject public key is used for verifying
digital signatures, other than signatures on certificates
(``key_cert_sign``) and CRLs (``crl_sign``).
.. attribute:: content_commitment
:type: bool
This purpose is set to true when the subject public key is used for verifying
digital signatures, other than signatures on certificates
(``key_cert_sign``) and CRLs (``crl_sign``). It is used to provide a
non-repudiation service that protects against the signing entity
falsely denying some action. In the case of later conflict, a
reliable third party may determine the authenticity of the signed
data. This was called ``non_repudiation`` in older revisions of the
X.509 specification.
.. attribute:: key_encipherment
:type: bool
This purpose is set to true when the subject public key is used for
enciphering private or secret keys.
.. attribute:: data_encipherment
:type: bool
This purpose is set to true when the subject public key is used for
directly enciphering raw user data without the use of an intermediate
symmetric cipher.
.. attribute:: key_agreement
:type: bool
This purpose is set to true when the subject public key is used for key
agreement. For example, when a Diffie-Hellman key is to be used for
key management, then this purpose is set to true.
.. attribute:: key_cert_sign
:type: bool
This purpose is set to true when the subject public key is used for
verifying signatures on public key certificates. If this purpose is set
to true then ``ca`` must be true in the :class:`BasicConstraints`
extension.
.. attribute:: crl_sign
:type: bool
This purpose is set to true when the subject public key is used for
verifying signatures on certificate revocation lists.
.. attribute:: encipher_only
:type: bool
When this purposes is set to true and the ``key_agreement`` purpose is
also set, the subject public key may be used only for enciphering data
while performing key agreement.
:raises ValueError: This is raised if accessed when ``key_agreement``
is false.
.. attribute:: decipher_only
:type: bool
When this purposes is set to true and the ``key_agreement`` purpose is
also set, the subject public key may be used only for deciphering data
while performing key agreement.
:raises ValueError: This is raised if accessed when ``key_agreement``
is false.
.. class:: BasicConstraints
.. versionadded:: 0.9
Basic constraints is an X.509 extension type that defines whether a given
certificate is allowed to sign additional certificates and what path
length restrictions may exist. It corresponds to
:data:`OID_BASIC_CONSTRAINTS`.
.. attribute:: ca
:type: bool
Whether the certificate can sign certificates.
.. attribute:: path_length
:type: int or None
The maximum path length for certificates subordinate to this
certificate. This attribute only has meaning if ``ca`` is true.
If ``ca`` is true then a path length of None means there's no
restriction on the number of subordinate CAs in the certificate chain.
If it is zero or greater then it defines the maximum length for a
subordinate CA's certificate chain. For example, a ``path_length`` of 1
means the certificate can sign a subordinate CA, but the subordinate CA
is not allowed to create subordinates with ``ca`` set to true.
.. class:: ExtendedKeyUsage
.. versionadded:: 0.9
This extension indicates one or more purposes for which the certified
public key may be used, in addition to or in place of the basic
purposes indicated in the key usage extension. The object is
iterable to obtain the list of :ref:`extended key usage OIDs <eku_oids>`.
.. class:: OCSPNoCheck
.. versionadded:: 1.0
This presence of this extension indicates that an OCSP client can trust a
responder for the lifetime of the responder's certificate. CAs issuing
such a certificate should realize that a compromise of the responder's key
is as serious as the compromise of a CA key used to sign CRLs, at least for
the validity period of this certificate. CA's may choose to issue this type
of certificate with a very short lifetime and renew it frequently. This
extension is only relevant when the certificate is an authorized OCSP
responder.
.. class:: AuthorityKeyIdentifier
.. versionadded:: 0.9
The authority key identifier extension provides a means of identifying the
public key corresponding to the private key used to sign a certificate.
This extension is typically used to assist in determining the appropriate
certificate chain. For more information about generation and use of this
extension see `RFC 5280 section 4.2.1.1`_.
.. attribute:: key_identifier
:type: bytes
A value derived from the public key used to verify the certificate's
signature.
.. attribute:: authority_cert_issuer
:type: :class:`Name` or None
The :class:`Name` of the issuer's issuer.
.. attribute:: authority_cert_serial_number
:type: int or None
The serial number of the issuer's issuer.
.. class:: SubjectKeyIdentifier
.. versionadded:: 0.9
The subject key identifier extension provides a means of identifying
certificates that contain a particular public key.
.. attribute:: digest
:type: bytes
The binary value of the identifier.
.. class:: SubjectAlternativeName
.. versionadded:: 0.9
Subject alternative name is an X.509 extension that provides a list of
:ref:`general name <general_name_classes>` instances that provide a set
of identities for which the certificate is valid. The object is iterable to
get every element.
.. method:: get_values_for_type(type)
:param type: A :class:`GeneralName` provider. This is one of the
:ref:`general name classes <general_name_classes>`.
:returns: A list of values extracted from the matched general names.
.. doctest::
>>> from cryptography import x509
>>> from cryptography.hazmat.backends import default_backend
>>> from cryptography.hazmat.primitives import hashes
>>> cert = x509.load_pem_x509_certificate(cryptography_cert_pem, default_backend())
>>> # Get the subjectAltName extension from the certificate
>>> ext = cert.extensions.get_extension_for_oid(x509.OID_SUBJECT_ALTERNATIVE_NAME)
>>> # Get the dNSName entries from the SAN extension
>>> ext.value.get_values_for_type(x509.DNSName)
[u'www.cryptography.io', u'cryptography.io']
.. class:: AuthorityInformationAccess
.. versionadded:: 0.9
The authority information access extension indicates how to access
information and services for the issuer of the certificate in which
the extension appears. Information and services may include online
validation services (such as OCSP) and issuer data. It is an iterable,
containing one or more :class:`AccessDescription` instances.
.. class:: AccessDescription
.. versionadded:: 0.9
.. attribute:: access_method
:type: :class:`ObjectIdentifier`
The access method defines what the ``access_location`` means. It must
be either :data:`OID_OCSP` or :data:`OID_CA_ISSUERS`. If it is
:data:`OID_OCSP` the access location will be where to obtain OCSP
information for the certificate. If it is :data:`OID_CA_ISSUERS` the
access location will provide additional information about the issuing
certificate.
.. attribute:: access_location
:type: :class:`GeneralName`
Where to access the information defined by the access method.
.. class:: CRLDistributionPoints
.. versionadded:: 0.9
The CRL distribution points extension identifies how CRL information is
obtained. It is an iterable, containing one or more
:class:`DistributionPoint` instances.
.. class:: DistributionPoint
.. versionadded:: 0.9
.. attribute:: full_name
:type: list of :class:`GeneralName` instances or None
This field describes methods to retrieve the CRL. At most one of
``full_name`` or ``relative_name`` will be non-None.
.. attribute:: relative_name
:type: :class:`Name` or None
This field describes methods to retrieve the CRL relative to the CRL
issuer. At most one of ``full_name`` or ``relative_name`` will be
non-None.
.. attribute:: crl_issuer
:type: list of :class:`GeneralName` instances or None
Information about the issuer of the CRL.
.. attribute:: reasons
:type: frozenset of :class:`ReasonFlags` or None
The reasons a given distribution point may be used for when performing
revocation checks.
.. class:: ReasonFlags
.. versionadded:: 0.9
An enumeration for CRL reasons.
.. attribute:: unspecified
It is unspecified why the certificate was revoked. This reason cannot
be used as a reason flag in a :class:`DistributionPoint`.
.. attribute:: key_compromise
This reason indicates that the private key was compromised.
.. attribute:: ca_compromise
This reason indicates that the CA issuing the certificate was
compromised.
.. attribute:: affiliation_changed
This reason indicates that the subject's name or other information has
changed.
.. attribute:: superseded
This reason indicates that a certificate has been superseded.
.. attribute:: cessation_of_operation
This reason indicates that the certificate is no longer required.
.. attribute:: certificate_hold
This reason indicates that the certificate is on hold.
.. attribute:: privilege_withdrawn
This reason indicates that the privilege granted by this certificate
have been withdrawn.
.. attribute:: aa_compromise
When an attribute authority has been compromised.
.. attribute:: remove_from_crl
This reason indicates that the certificate was on hold and should be
removed from the CRL. This reason cannot be used as a reason flag
in a :class:`DistributionPoint`.
.. class:: InhibitAnyPolicy
.. versionadded:: 1.0
The inhibit ``anyPolicy`` extension indicates that the special OID
:data:`OID_ANY_POLICY`, is not considered an explicit match for other
:class:`CertificatePolicies` except when it appears in an intermediate
self-issued CA certificate. The value indicates the number of additional
non-self-issued certificates that may appear in the path before
:data:`OID_ANY_POLICY` is no longer permitted. For example, a value
of one indicates that :data:`OID_ANY_POLICY` may be processed in
certificates issued by the subject of this certificate, but not in
additional certificates in the path.
.. attribute:: skip_certs
:type: int
.. class:: CertificatePolicies
.. versionadded:: 0.9
The certificate policies extension is an iterable, containing one or more
:class:`PolicyInformation` instances.
Certificate Policies Classes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
These classes may be present within a :class:`CertificatePolicies` instance.
.. class:: PolicyInformation
.. versionadded:: 0.9
Contains a policy identifier and an optional list of qualifiers.
.. attribute:: policy_identifier
:type: :class:`ObjectIdentifier`
.. attribute:: policy_qualifiers
:type: list
A list consisting of :term:`text` and/or :class:`UserNotice` objects.
If the value is text it is a pointer to the practice statement
published by the certificate authority. If it is a user notice it is
meant for display to the relying party when the certificate is
used.
.. class:: UserNotice
.. versionadded:: 0.9
User notices are intended for display to a relying party when a certificate
is used. In practice, few if any UIs expose this data and it is a rarely
encoded component.
.. attribute:: notice_reference
:type: :class:`NoticeReference` or None
The notice reference field names an organization and identifies,
by number, a particular statement prepared by that organization.
.. attribute:: explicit_text
This field includes an arbitrary textual statement directly in the
certificate.
:type: :term:`text`
.. class:: NoticeReference
Notice reference can name an organization and provide information about
notices related to the certificate. For example, it might identify the
organization name and notice number 1. Application software could
have a notice file containing the current set of notices for the named
organization; the application would then extract the notice text from the
file and display it. In practice this is rarely seen.
.. versionadded:: 0.9
.. attribute:: organization
:type: :term:`text`
.. attribute:: notice_numbers
:type: list
A list of integers.
Object Identifiers
~~~~~~~~~~~~~~~~~~
X.509 elements are frequently identified by :class:`ObjectIdentifier`
instances. The following common OIDs are available as constants.
Name OIDs
~~~~~~~~~
.. data:: OID_COMMON_NAME
Corresponds to the dotted string ``"2.5.4.3"``. Historically the domain
name would be encoded here for server certificates. :rfc:`2818` deprecates
this practice and names of that type should now be located in a
SubjectAlternativeName extension. This OID is typically seen in X.509 names.
.. data:: OID_COUNTRY_NAME
Corresponds to the dotted string ``"2.5.4.6"``. This OID is typically seen
in X.509 names.
.. data:: OID_LOCALITY_NAME
Corresponds to the dotted string ``"2.5.4.7"``. This OID is typically seen
in X.509 names.
.. data:: OID_STATE_OR_PROVINCE_NAME
Corresponds to the dotted string ``"2.5.4.8"``. This OID is typically seen
in X.509 names.
.. data:: OID_ORGANIZATION_NAME
Corresponds to the dotted string ``"2.5.4.10"``. This OID is typically seen
in X.509 names.
.. data:: OID_ORGANIZATIONAL_UNIT_NAME
Corresponds to the dotted string ``"2.5.4.11"``. This OID is typically seen
in X.509 names.
.. data:: OID_SERIAL_NUMBER
Corresponds to the dotted string ``"2.5.4.5"``. This is distinct from the
serial number of the certificate itself (which can be obtained with
:func:`Certificate.serial`). This OID is typically seen in X.509 names.
.. data:: OID_SURNAME
Corresponds to the dotted string ``"2.5.4.4"``. This OID is typically seen
in X.509 names.
.. data:: OID_GIVEN_NAME
Corresponds to the dotted string ``"2.5.4.42"``. This OID is typically seen
in X.509 names.
.. data:: OID_TITLE
Corresponds to the dotted string ``"2.5.4.12"``. This OID is typically seen
in X.509 names.
.. data:: OID_GENERATION_QUALIFIER
Corresponds to the dotted string ``"2.5.4.44"``. This OID is typically seen
in X.509 names.
.. data:: OID_DN_QUALIFIER
Corresponds to the dotted string ``"2.5.4.46"``. This specifies
disambiguating information to add to the relative distinguished name of an
entry. See :rfc:`2256`. This OID is typically seen in X.509 names.
.. data:: OID_PSEUDONYM
Corresponds to the dotted string ``"2.5.4.65"``. This OID is typically seen
in X.509 names.
.. data:: OID_DOMAIN_COMPONENT
Corresponds to the dotted string ``"0.9.2342.19200300.100.1.25"``. A string
holding one component of a domain name. See :rfc:`4519`. This OID is
typically seen in X.509 names.
.. data:: OID_EMAIL_ADDRESS
Corresponds to the dotted string ``"1.2.840.113549.1.9.1"``. This OID is
typically seen in X.509 names.
Signature Algorithm OIDs
~~~~~~~~~~~~~~~~~~~~~~~~
.. data:: OID_RSA_WITH_MD5
Corresponds to the dotted string ``"1.2.840.113549.1.1.4"``. This is
an MD5 digest signed by an RSA key.
.. data:: OID_RSA_WITH_SHA1
Corresponds to the dotted string ``"1.2.840.113549.1.1.5"``. This is
a SHA1 digest signed by an RSA key.
.. data:: OID_RSA_WITH_SHA224
Corresponds to the dotted string ``"1.2.840.113549.1.1.14"``. This is
a SHA224 digest signed by an RSA key.
.. data:: OID_RSA_WITH_SHA256
Corresponds to the dotted string ``"1.2.840.113549.1.1.11"``. This is
a SHA256 digest signed by an RSA key.
.. data:: OID_RSA_WITH_SHA384
Corresponds to the dotted string ``"1.2.840.113549.1.1.12"``. This is
a SHA384 digest signed by an RSA key.
.. data:: OID_RSA_WITH_SHA512
Corresponds to the dotted string ``"1.2.840.113549.1.1.13"``. This is
a SHA512 digest signed by an RSA key.
.. data:: OID_ECDSA_WITH_SHA224
Corresponds to the dotted string ``"1.2.840.10045.4.3.1"``. This is
a SHA224 digest signed by an ECDSA key.
.. data:: OID_ECDSA_WITH_SHA256
Corresponds to the dotted string ``"1.2.840.10045.4.3.2"``. This is
a SHA256 digest signed by an ECDSA key.
.. data:: OID_ECDSA_WITH_SHA384
Corresponds to the dotted string ``"1.2.840.10045.4.3.3"``. This is
a SHA384 digest signed by an ECDSA key.
.. data:: OID_ECDSA_WITH_SHA512
Corresponds to the dotted string ``"1.2.840.10045.4.3.4"``. This is
a SHA512 digest signed by an ECDSA key.
.. data:: OID_DSA_WITH_SHA1
Corresponds to the dotted string ``"1.2.840.10040.4.3"``. This is
a SHA1 digest signed by a DSA key.
.. data:: OID_DSA_WITH_SHA224
Corresponds to the dotted string ``"2.16.840.1.101.3.4.3.1"``. This is
a SHA224 digest signed by a DSA key.
.. data:: OID_DSA_WITH_SHA256
Corresponds to the dotted string ``"2.16.840.1.101.3.4.3.2"``. This is
a SHA256 digest signed by a DSA key.
.. _eku_oids:
Extended Key Usage OIDs
~~~~~~~~~~~~~~~~~~~~~~~
.. data:: OID_SERVER_AUTH
Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.1"``. This is used to
denote that a certificate may be used for TLS web server authentication.
.. data:: OID_CLIENT_AUTH
Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.2"``. This is used to
denote that a certificate may be used for TLS web client authentication.
.. data:: OID_CODE_SIGNING
Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.3"``. This is used to
denote that a certificate may be used for code signing.
.. data:: OID_EMAIL_PROTECTION
Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.4"``. This is used to
denote that a certificate may be used for email protection.
.. data:: OID_TIME_STAMPING
Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.8"``. This is used to
denote that a certificate may be used for time stamping.
.. data:: OID_OCSP_SIGNING
Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.9"``. This is used to
denote that a certificate may be used for signing OCSP responses.
Authority Information Access OIDs
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. data:: OID_OCSP
Corresponds to the dotted string ``"1.3.6.1.5.5.7.48.1"``. Used as the
identifier for OCSP data in :class:`AccessDescription` objects.
.. data:: OID_CA_ISSUERS
Corresponds to the dotted string ``"1.3.6.1.5.5.7.48.2"``. Used as the
identifier for CA issuer data in :class:`AccessDescription` objects.
Policy Qualifier OIDs
~~~~~~~~~~~~~~~~~~~~~
.. data:: OID_CPS_QUALIFIER
Corresponds to the dotted string ``"1.3.6.1.5.5.7.2.1"``.
.. data:: OID_CPS_USER_NOTICE
Corresponds to the dotted string ``"1.3.6.1.5.5.7.2.2"``.
.. data:: OID_ANY_POLICY
Corresponds to the dotted string ``"2.5.29.32.0"``.
.. _extension_oids:
Extension OIDs
~~~~~~~~~~~~~~
.. data:: OID_BASIC_CONSTRAINTS
Corresponds to the dotted string ``"2.5.29.19"``. The identifier for the
:class:`BasicConstraints` extension type.
.. data:: OID_KEY_USAGE
Corresponds to the dotted string ``"2.5.29.15"``. The identifier for the
:class:`KeyUsage` extension type.
.. data:: OID_SUBJECT_ALTERNATIVE_NAME
Corresponds to the dotted string ``"2.5.29.17"``. The identifier for the
:class:`SubjectAlternativeName` extension type.
.. data:: OID_SUBJECT_KEY_IDENTIFIER
Corresponds to the dotted string ``"2.5.29.14"``. The identifier for the
:class:`SubjectKeyIdentifier` extension type.
.. data:: OID_CRL_DISTRIBUTION_POINTS
Corresponds to the dotted string ``"2.5.29.31"``. The identifier for the
:class:`CRLDistributionPoints` extension type.
.. data:: OID_CERTIFICATE_POLICIES
Corresponds to the dotted string ``"2.5.29.32"``. The identifier for the
:class:`CertificatePolicies` extension type.
.. data:: OID_AUTHORITY_KEY_IDENTIFIER
Corresponds to the dotted string ``"2.5.29.35"``. The identifier for the
:class:`AuthorityKeyIdentifier` extension type.
.. data:: OID_EXTENDED_KEY_USAGE
Corresponds to the dotted string ``"2.5.29.37"``. The identifier for the
:class:`ExtendedKeyUsage` extension type.
.. data:: OID_AUTHORITY_INFORMATION_ACCESS
Corresponds to the dotted string ``"1.3.6.1.5.5.7.1.1"``. The identifier
for the :class:`AuthorityInformationAccess` extension type.
.. data:: OID_OCSP_NO_CHECK
Corresponds to the dotted string ``"1.3.6.1.5.5.7.48.1.5"``. The identifier
for the :class:`OCSPNoCheck` extension type.
Exceptions
~~~~~~~~~~
.. class:: InvalidVersion
This is raised when an X.509 certificate has an invalid version number.
.. attribute:: parsed_version
:type: int
Returns the raw version that was parsed from the certificate.
.. class:: DuplicateExtension
This is raised when more than one X.509 extension of the same type is
found within a certificate.
.. attribute:: oid
:type: :class:`ObjectIdentifier`
Returns the OID.
.. class:: UnsupportedExtension
This is raised when a certificate contains an unsupported extension type.
.. attribute:: oid
:type: :class:`ObjectIdentifier`
Returns the OID.
.. class:: ExtensionNotFound
This is raised when calling :meth:`Extensions.get_extension_for_oid` with
an extension OID that is not present in the certificate.
.. attribute:: oid
:type: :class:`ObjectIdentifier`
Returns the OID.
.. class:: UnsupportedGeneralNameType
This is raised when a certificate contains an unsupported general name
type in an extension.
.. attribute:: type
:type: int
The integer value of the unsupported type. The complete list of
types can be found in `RFC 5280 section 4.2.1.6`_.
.. _`public key infrastructure`: https://en.wikipedia.org/wiki/Public_key_infrastructure
.. _`TLS`: https://en.wikipedia.org/wiki/Transport_Layer_Security
.. _`RFC 5280 section 4.2.1.1`: https://tools.ietf.org/html/rfc5280#section-4.2.1.1
.. _`RFC 5280 section 4.2.1.6`: https://tools.ietf.org/html/rfc5280#section-4.2.1.6
|