blob: bbea490ec85f8be06880efcd3e3fa827c3437f42 [file] [log] [blame]
Alex Gaynor4af5b372015-07-12 10:30:59 -05001X.509 Reference
2===============
Paul Kehrer016e08a2014-11-26 09:41:18 -10003
Paul Kehrera9d78c12014-11-26 10:59:03 -10004.. currentmodule:: cryptography.x509
Paul Kehrer016e08a2014-11-26 09:41:18 -10005
Paul Kehrerd26c4db2015-03-15 15:36:24 -05006.. testsetup::
7
Erik Trauschkedc570402015-09-24 20:24:28 -07008 pem_crl_data = b"""
9 -----BEGIN X509 CRL-----
10 MIIBtDCBnQIBAjANBgkqhkiG9w0BAQsFADAnMQswCQYDVQQGEwJVUzEYMBYGA1UE
11 AwwPY3J5cHRvZ3JhcGh5LmlvGA8yMDE1MDEwMTAwMDAwMFoYDzIwMTYwMTAxMDAw
12 MDAwWjA+MDwCAQAYDzIwMTUwMTAxMDAwMDAwWjAmMBgGA1UdGAQRGA8yMDE1MDEw
13 MTAwMDAwMFowCgYDVR0VBAMKAQEwDQYJKoZIhvcNAQELBQADggEBABRA4ww50Lz5
14 zk1j2+aluC4HPHqb7o06h4pTDcCGeXUKXIGeP5ntGGmIoxa26sNoLeOr8+5b43Gf
15 yWraHertllOwaOpNFEe+YZFaE9femtoDbf+GLMvRx/0wDfd3KxPoXnXKMXb2d1w4
16 RCLgmkYx6JyvS+5ciuLQVIKC+l7jwIUeZFLJMUJ8msM4pFYoGameeZmtjMbd/TNg
17 cVBfmZxNMHuLladJxvSo2esARo0TYPhYsgrREKoHwhpzSxdynjn4bOVkILfguwsN
18 qtEEMZFEv5Kb0GqRp2+Iagv2S6dg9JGvxVdsoGjaB6EbYSZ3Psx4aODasIn11uwo
19 X4B9vUQNXqc=
20 -----END X509 CRL-----
21 """.strip()
22
Paul Kehrerd26c4db2015-03-15 15:36:24 -050023 pem_req_data = b"""
24 -----BEGIN CERTIFICATE REQUEST-----
25 MIIC0zCCAbsCAQAwWTELMAkGA1UEBhMCVVMxETAPBgNVBAgMCElsbGlub2lzMRAw
26 DgYDVQQHDAdDaGljYWdvMREwDwYDVQQKDAhyNTA5IExMQzESMBAGA1UEAwwJaGVs
27 bG8uY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqhZx+Mo9VRd9
28 vsnWWa6NBCws21rZ0+1B/JGgB4hDsZS7iDE4Bj5z4idheFRtl8bBbdjPknq7BfoF
29 8v15Zq/Zv7i2xMSDL+LUrTBZezRd4bRTGqCm6YJ5EYkhqdcqeZleHCFImguHoq1J
30 Fh0+kObQrTHXw3ZP57a3o1IvyIUA3nNoCBL0QQhwBXaDXOojMKNR+bqB5ve8GS1y
31 Elr0AM/+cJsfaIahNQUgFKx3Eu3GeEOMKYOAG1lycgdQdmTUybLrT3U7vkClTseM
32 xHg1r5En7ALjONIhqRuq3rddYahrP8HXozb3zUy3cJ7P6IeaosuvNzvMXOX9P6HD
33 Ha9urDAJ1wIDAQABoDUwMwYJKoZIhvcNAQkOMSYwJDAiBgNVHREEGzAZggl3b3Js
34 ZC5jb22CDHdoYXRldmVyLmNvbTANBgkqhkiG9w0BAQUFAAOCAQEAS4Ro6h+z52SK
35 YSLCYARpnEu/rmh4jdqndt8naqcNb6uLx9mlKZ2W9on9XDjnSdQD9q+ZP5aZfESw
36 R0+rJhW9ZrNa/g1pt6M24ihclHYDAxYMWxT1z/TXXGM3TmZZ6gfYlNE1kkBuODHa
37 UYsR/1Ht1E1EsmmUimt2n+zQR2K8T9Coa+boaUW/GsTEuz1aaJAkj5ZvTDiIhRG4
38 AOCqFZOLAQmCCNgJnnspD9hDz/Ons085LF5wnYjN4/Nsk5tS6AGs3xjZ3jPoOGGn
39 82WQ9m4dBGoVDZXsobVTaN592JEYwN5iu72zRn7Einb4V4H5y3yD2dD4yWPlt4pk
40 5wFkeYsZEA==
41 -----END CERTIFICATE REQUEST-----
42 """.strip()
43
Paul Kehrerd3dafbd2015-03-15 16:24:18 -050044 pem_data = b"""
45 -----BEGIN CERTIFICATE-----
46 MIIDfDCCAmSgAwIBAgIBAjANBgkqhkiG9w0BAQsFADBFMQswCQYDVQQGEwJVUzEf
47 MB0GA1UEChMWVGVzdCBDZXJ0aWZpY2F0ZXMgMjAxMTEVMBMGA1UEAxMMVHJ1c3Qg
48 QW5jaG9yMB4XDTEwMDEwMTA4MzAwMFoXDTMwMTIzMTA4MzAwMFowQDELMAkGA1UE
49 BhMCVVMxHzAdBgNVBAoTFlRlc3QgQ2VydGlmaWNhdGVzIDIwMTExEDAOBgNVBAMT
50 B0dvb2QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCQWJpHYo37
51 Xfb7oJSPe+WvfTlzIG21WQ7MyMbGtK/m8mejCzR6c+f/pJhEH/OcDSMsXq8h5kXa
52 BGqWK+vSwD/Pzp5OYGptXmGPcthDtAwlrafkGOS4GqIJ8+k9XGKs+vQUXJKsOk47
53 RuzD6PZupq4s16xaLVqYbUC26UcY08GpnoLNHJZS/EmXw1ZZ3d4YZjNlpIpWFNHn
54 UGmdiGKXUPX/9H0fVjIAaQwjnGAbpgyCumWgzIwPpX+ElFOUr3z7BoVnFKhIXze+
55 VmQGSWxZxvWDUN90Ul0tLEpLgk3OVxUB4VUGuf15OJOpgo1xibINPmWt14Vda2N9
56 yrNKloJGZNqLAgMBAAGjfDB6MB8GA1UdIwQYMBaAFOR9X9FclYYILAWuvnW2ZafZ
57 XahmMB0GA1UdDgQWBBRYAYQkG7wrUpRKPaUQchRR9a86yTAOBgNVHQ8BAf8EBAMC
58 AQYwFwYDVR0gBBAwDjAMBgpghkgBZQMCATABMA8GA1UdEwEB/wQFMAMBAf8wDQYJ
59 KoZIhvcNAQELBQADggEBADWHlxbmdTXNwBL/llwhQqwnazK7CC2WsXBBqgNPWj7m
60 tvQ+aLG8/50Qc2Sun7o2VnwF9D18UUe8Gj3uPUYH+oSI1vDdyKcjmMbKRU4rk0eo
61 3UHNDXwqIVc9CQS9smyV+x1HCwL4TTrq+LXLKx/qVij0Yqk+UJfAtrg2jnYKXsCu
62 FMBQQnWCGrwa1g1TphRp/RmYHnMynYFmZrXtzFz+U9XEA7C+gPq4kqDI/iVfIT1s
63 6lBtdB50lrDVwl2oYfAvW/6sC2se2QleZidUmrziVNP4oEeXINokU6T6p//HM1FG
64 QYw2jOvpKcKtWCSAnegEbgsGYzATKjmPJPJ0npHFqzM=
65 -----END CERTIFICATE-----
66 """.strip()
67
Paul Kehrer93ae8052015-05-02 23:18:09 -050068 cryptography_cert_pem = b"""
69 -----BEGIN CERTIFICATE-----
70 MIIFvTCCBKWgAwIBAgICPyAwDQYJKoZIhvcNAQELBQAwRzELMAkGA1UEBhMCVVMx
71 FjAUBgNVBAoTDUdlb1RydXN0IEluYy4xIDAeBgNVBAMTF1JhcGlkU1NMIFNIQTI1
72 NiBDQSAtIEczMB4XDTE0MTAxNTEyMDkzMloXDTE4MTExNjAxMTUwM1owgZcxEzAR
73 BgNVBAsTCkdUNDg3NDI5NjUxMTAvBgNVBAsTKFNlZSB3d3cucmFwaWRzc2wuY29t
74 L3Jlc291cmNlcy9jcHMgKGMpMTQxLzAtBgNVBAsTJkRvbWFpbiBDb250cm9sIFZh
75 bGlkYXRlZCAtIFJhcGlkU1NMKFIpMRwwGgYDVQQDExN3d3cuY3J5cHRvZ3JhcGh5
76 LmlvMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAom/FebKJIot7Sp3s
77 itG1sicpe3thCssjI+g1JDAS7I3GLVNmbms1DOdIIqwf01gZkzzXBN2+9sOnyRaR
78 PPfCe1jTr3dk2y6rPE559vPa1nZQkhlzlhMhlPyjaT+S7g4Tio4qV2sCBZU01DZJ
79 CaksfohN+5BNVWoJzTbOcrHOEJ+M8B484KlBCiSxqf9cyNQKru4W3bHaCVNVJ8eu
80 6i6KyhzLa0L7yK3LXwwXVs583C0/vwFhccGWsFODqD/9xHUzsBIshE8HKjdjDi7Y
81 3BFQzVUQFjBB50NSZfAA/jcdt1blxJouc7z9T8Oklh+V5DDBowgAsrT4b6Z2Fq6/
82 r7D1GqivLK/ypUQmxq2WXWAUBb/Q6xHgxASxI4Br+CByIUQJsm8L2jzc7k+mF4hW
83 ltAIUkbo8fGiVnat0505YJgxWEDKOLc4Gda6d/7GVd5AvKrz242bUqeaWo6e4MTx
84 diku2Ma3rhdcr044Qvfh9hGyjqNjvhWY/I+VRWgihU7JrYvgwFdJqsQ5eiKT4OHi
85 gsejvWwkZzDtiQ+aQTrzM1FsY2swJBJsLSX4ofohlVRlIJCn/ME+XErj553431Lu
86 YQ5SzMd3nXzN78Vj6qzTfMUUY72UoT1/AcFiUMobgIqrrmwuNxfrkbVE2b6Bga74
87 FsJX63prvrJ41kuHK/16RQBM7fcCAwEAAaOCAWAwggFcMB8GA1UdIwQYMBaAFMOc
88 8/zTRgg0u85Gf6B8W/PiCMtZMFcGCCsGAQUFBwEBBEswSTAfBggrBgEFBQcwAYYT
89 aHR0cDovL2d2LnN5bWNkLmNvbTAmBggrBgEFBQcwAoYaaHR0cDovL2d2LnN5bWNi
90 LmNvbS9ndi5jcnQwDgYDVR0PAQH/BAQDAgWgMB0GA1UdJQQWMBQGCCsGAQUFBwMB
91 BggrBgEFBQcDAjAvBgNVHREEKDAmghN3d3cuY3J5cHRvZ3JhcGh5Lmlvgg9jcnlw
92 dG9ncmFwaHkuaW8wKwYDVR0fBCQwIjAgoB6gHIYaaHR0cDovL2d2LnN5bWNiLmNv
93 bS9ndi5jcmwwDAYDVR0TAQH/BAIwADBFBgNVHSAEPjA8MDoGCmCGSAGG+EUBBzYw
94 LDAqBggrBgEFBQcCARYeaHR0cHM6Ly93d3cucmFwaWRzc2wuY29tL2xlZ2FsMA0G
95 CSqGSIb3DQEBCwUAA4IBAQAzIYO2jx7h17FBT74tJ2zbV9OKqGb7QF8y3wUtP4xc
96 dH80vprI/Cfji8s86kr77aAvAqjDjaVjHn7UzebhSUivvRPmfzRgyWBacomnXTSt
97 Xlt2dp2nDQuwGyK2vB7dMfKnQAkxwq1sYUXznB8i0IhhCAoXp01QGPKq51YoIlnF
98 7DRMk6iEaL1SJbkIrLsCQyZFDf0xtfW9DqXugMMLoxeCsBhZJQzNyS2ryirrv9LH
99 aK3+6IZjrcyy9bkpz/gzJucyhU+75c4My/mnRCrtItRbCQuiI5pd5poDowm+HH9i
100 GVI9+0lAFwxOUnOnwsoI40iOoxjLMGB+CgFLKCGUcWxP
101 -----END CERTIFICATE-----
102 """.strip()
103
Paul Kehrerb2de9482014-12-11 14:54:48 -0600104Loading Certificates
105~~~~~~~~~~~~~~~~~~~~
Paul Kehrer016e08a2014-11-26 09:41:18 -1000106
107.. function:: load_pem_x509_certificate(data, backend)
108
109 .. versionadded:: 0.7
110
Paul Kehrere76cd272014-12-14 19:00:51 -0600111 Deserialize a certificate from PEM encoded data. PEM certificates are
112 base64 decoded and have delimiters that look like
113 ``-----BEGIN CERTIFICATE-----``.
Paul Kehrer016e08a2014-11-26 09:41:18 -1000114
115 :param bytes data: The PEM encoded certificate data.
116
117 :param backend: A backend supporting the
118 :class:`~cryptography.hazmat.backends.interfaces.X509Backend`
119 interface.
120
Paul Kehrere76cd272014-12-14 19:00:51 -0600121 :returns: An instance of :class:`~cryptography.x509.Certificate`.
Paul Kehrer016e08a2014-11-26 09:41:18 -1000122
123.. function:: load_der_x509_certificate(data, backend)
124
125 .. versionadded:: 0.7
126
Paul Kehrere76cd272014-12-14 19:00:51 -0600127 Deserialize a certificate from DER encoded data. DER is a binary format
Paul Kehrer92aac382014-12-15 16:25:28 -0600128 and is commonly found in files with the ``.cer`` extension (although file
129 extensions are not a guarantee of encoding type).
Paul Kehrer016e08a2014-11-26 09:41:18 -1000130
131 :param bytes data: The DER encoded certificate data.
132
133 :param backend: A backend supporting the
134 :class:`~cryptography.hazmat.backends.interfaces.X509Backend`
135 interface.
136
Paul Kehrere76cd272014-12-14 19:00:51 -0600137 :returns: An instance of :class:`~cryptography.x509.Certificate`.
Paul Kehrer016e08a2014-11-26 09:41:18 -1000138
Paul Kehrer016e08a2014-11-26 09:41:18 -1000139.. doctest::
140
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600141 >>> from cryptography import x509
Paul Kehrer016e08a2014-11-26 09:41:18 -1000142 >>> from cryptography.hazmat.backends import default_backend
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600143 >>> cert = x509.load_pem_x509_certificate(pem_data, default_backend())
Paul Kehrer016e08a2014-11-26 09:41:18 -1000144 >>> cert.serial
145 2
146
Erik Trauschkedc570402015-09-24 20:24:28 -0700147Loading Certificate Revocation Lists
148~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
149
150.. function:: load_pem_x509_crl(data, backend)
151
152 .. versionadded:: 1.1
153
154 Deserialize a certificate revocation list (CRL) from PEM encoded data. PEM
155 requests are base64 decoded and have delimiters that look like
Erik Trauschke32bbfe02015-10-21 08:04:55 -0700156 ``-----BEGIN X509 CRL-----``.
Erik Trauschkedc570402015-09-24 20:24:28 -0700157
158 :param bytes data: The PEM encoded request data.
159
160 :param backend: A backend supporting the
161 :class:`~cryptography.hazmat.backends.interfaces.X509Backend`
162 interface.
163
164 :returns: An instance of
165 :class:`~cryptography.x509.CertificateRevocationList`.
166
167.. function:: load_der_x509_crl(data, backend)
168
169 .. versionadded:: 1.1
170
171 Deserialize a certificate revocation list (CRL) from DER encoded data. DER
172 is a binary format.
173
174 :param bytes data: The DER encoded request data.
175
176 :param backend: A backend supporting the
177 :class:`~cryptography.hazmat.backends.interfaces.X509Backend`
178 interface.
179
180 :returns: An instance of
181 :class:`~cryptography.x509.CertificateRevocationList`.
182
183.. doctest::
184
185 >>> from cryptography import x509
186 >>> from cryptography.hazmat.backends import default_backend
187 >>> from cryptography.hazmat.primitives import hashes
188 >>> crl = x509.load_pem_x509_crl(pem_crl_data, default_backend())
189 >>> isinstance(crl.signature_hash_algorithm, hashes.SHA256)
190 True
191
Paul Kehrera1a1f232015-03-15 15:34:35 -0500192Loading Certificate Signing Requests
193~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600194
Paul Kehrer31e39882015-03-11 11:37:04 -0500195.. function:: load_pem_x509_csr(data, backend)
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600196
197 .. versionadded:: 0.9
198
Paul Kehrera1a1f232015-03-15 15:34:35 -0500199 Deserialize a certificate signing request (CSR) from PEM encoded data. PEM
Paul Kehrer5aadb9c2015-03-11 20:48:42 -0500200 requests are base64 decoded and have delimiters that look like
Paul Kehrerd3dafbd2015-03-15 16:24:18 -0500201 ``-----BEGIN CERTIFICATE REQUEST-----``. This format is also known as
202 PKCS#10.
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600203
204 :param bytes data: The PEM encoded request data.
205
206 :param backend: A backend supporting the
207 :class:`~cryptography.hazmat.backends.interfaces.X509Backend`
208 interface.
209
Paul Kehrera1a1f232015-03-15 15:34:35 -0500210 :returns: An instance of
211 :class:`~cryptography.x509.CertificateSigningRequest`.
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600212
Paul Kehrer1effb6e2015-03-30 15:05:59 -0500213.. function:: load_der_x509_csr(data, backend)
214
215 .. versionadded:: 0.9
216
217 Deserialize a certificate signing request (CSR) from DER encoded data. DER
218 is a binary format and is not commonly used with CSRs.
219
220 :param bytes data: The DER encoded request data.
221
222 :param backend: A backend supporting the
223 :class:`~cryptography.hazmat.backends.interfaces.X509Backend`
224 interface.
225
226 :returns: An instance of
227 :class:`~cryptography.x509.CertificateSigningRequest`.
228
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600229.. doctest::
230
231 >>> from cryptography import x509
232 >>> from cryptography.hazmat.backends import default_backend
233 >>> from cryptography.hazmat.primitives import hashes
Paul Kehrera1a1f232015-03-15 15:34:35 -0500234 >>> csr = x509.load_pem_x509_csr(pem_req_data, default_backend())
235 >>> isinstance(csr.signature_hash_algorithm, hashes.SHA1)
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600236 True
237
Paul Kehrere76cd272014-12-14 19:00:51 -0600238X.509 Certificate Object
239~~~~~~~~~~~~~~~~~~~~~~~~
Paul Kehrerb2de9482014-12-11 14:54:48 -0600240
Paul Kehrere76cd272014-12-14 19:00:51 -0600241.. class:: Certificate
Paul Kehrerb2de9482014-12-11 14:54:48 -0600242
243 .. versionadded:: 0.7
244
245 .. attribute:: version
246
Paul Kehrere76cd272014-12-14 19:00:51 -0600247 :type: :class:`~cryptography.x509.Version`
Paul Kehrerb2de9482014-12-11 14:54:48 -0600248
Paul Kehrere76cd272014-12-14 19:00:51 -0600249 The certificate version as an enumeration. Version 3 certificates are
250 the latest version and also the only type you should see in practice.
Paul Kehrerb2de9482014-12-11 14:54:48 -0600251
Alex Gaynor89c4dc82014-12-16 16:49:33 -0800252 :raises cryptography.x509.InvalidVersion: If the version in the
Alex Gaynor6d7ab4c2014-12-16 16:50:33 -0800253 certificate is not a known
254 :class:`X.509 version <cryptography.x509.Version>`.
Paul Kehrer92aac382014-12-15 16:25:28 -0600255
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600256 .. doctest::
257
258 >>> cert.version
259 <Version.v3: 2>
260
Paul Kehrerb2de9482014-12-11 14:54:48 -0600261 .. method:: fingerprint(algorithm)
262
263 :param algorithm: The
Paul Kehrer601278a2015-02-12 12:51:00 -0600264 :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm`
Paul Kehrerb2de9482014-12-11 14:54:48 -0600265 that will be used to generate the fingerprint.
266
Erik Trauschke2dcce902015-05-14 16:12:24 -0700267 :return bytes: The fingerprint using the supplied hash algorithm, as
Paul Kehrerb2de9482014-12-11 14:54:48 -0600268 bytes.
269
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600270 .. doctest::
271
272 >>> from cryptography.hazmat.primitives import hashes
273 >>> cert.fingerprint(hashes.SHA256())
Paul Kehrer78a81502014-12-16 14:47:52 -0600274 '\x86\xd2\x187Gc\xfc\xe7}[+E9\x8d\xb4\x8f\x10\xe5S\xda\x18u\xbe}a\x03\x08[\xac\xa04?'
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600275
Paul Kehrerb2de9482014-12-11 14:54:48 -0600276 .. attribute:: serial
277
278 :type: int
279
280 The serial as a Python integer.
281
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600282 .. doctest::
283
284 >>> cert.serial
285 2
286
Paul Kehrerb2de9482014-12-11 14:54:48 -0600287 .. method:: public_key()
288
Alex Gaynor4c2561a2015-10-12 23:53:39 -0400289 The public key associated with the certificate.
290
291 :returns:
Alex Stapletonf79c2312014-12-30 12:50:14 +0000292 :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey` or
Paul Kehrer45efdbc2015-02-12 10:58:22 -0600293 :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPublicKey` or
294 :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey`
Paul Kehrerb2de9482014-12-11 14:54:48 -0600295
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600296 .. doctest::
297
Alex Stapletonf79c2312014-12-30 12:50:14 +0000298 >>> from cryptography.hazmat.primitives.asymmetric import rsa
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600299 >>> public_key = cert.public_key()
Alex Stapletonf79c2312014-12-30 12:50:14 +0000300 >>> isinstance(public_key, rsa.RSAPublicKey)
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600301 True
302
Paul Kehrerb2de9482014-12-11 14:54:48 -0600303 .. attribute:: not_valid_before
304
305 :type: :class:`datetime.datetime`
306
Paul Kehrer78a81502014-12-16 14:47:52 -0600307 A naïve datetime representing the beginning of the validity period for
308 the certificate in UTC. This value is inclusive.
Paul Kehrerb2de9482014-12-11 14:54:48 -0600309
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600310 .. doctest::
311
312 >>> cert.not_valid_before
313 datetime.datetime(2010, 1, 1, 8, 30)
314
Paul Kehrerb2de9482014-12-11 14:54:48 -0600315 .. attribute:: not_valid_after
316
317 :type: :class:`datetime.datetime`
318
Paul Kehrer78a81502014-12-16 14:47:52 -0600319 A naïve datetime representing the end of the validity period for the
320 certificate in UTC. This value is inclusive.
Paul Kehrerb2de9482014-12-11 14:54:48 -0600321
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600322 .. doctest::
323
324 >>> cert.not_valid_after
325 datetime.datetime(2030, 12, 31, 8, 30)
326
Paul Kehrer719d5362015-01-01 20:03:52 -0600327 .. attribute:: issuer
328
329 .. versionadded:: 0.8
330
331 :type: :class:`Name`
332
333 The :class:`Name` of the issuer.
334
335 .. attribute:: subject
336
337 .. versionadded:: 0.8
338
339 :type: :class:`Name`
340
341 The :class:`Name` of the subject.
342
Paul Kehrer8802a5b2015-02-13 12:06:57 -0600343 .. attribute:: signature_hash_algorithm
Paul Kehrer56da2a52015-02-11 23:35:07 -0600344
Paul Kehrer8802a5b2015-02-13 12:06:57 -0600345 :type: :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm`
Paul Kehrer56da2a52015-02-11 23:35:07 -0600346
Paul Kehrere612ec72015-02-16 14:33:35 -0600347 Returns the
Paul Kehrer71d40c62015-02-19 08:21:04 -0600348 :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` which
Paul Kehrer1a7ba872015-02-19 18:09:05 -0600349 was used in signing this certificate.
Paul Kehrer56da2a52015-02-11 23:35:07 -0600350
351 .. doctest::
352
Paul Kehrer8802a5b2015-02-13 12:06:57 -0600353 >>> from cryptography.hazmat.primitives import hashes
354 >>> isinstance(cert.signature_hash_algorithm, hashes.SHA256)
355 True
Paul Kehrer719d5362015-01-01 20:03:52 -0600356
Paul Kehrerfbb7ac82015-03-16 19:26:29 -0500357 .. attribute:: extensions
358
359 :type: :class:`Extensions`
360
361 The extensions encoded in the certificate.
362
363 :raises cryptography.x509.DuplicateExtension: If more than one
364 extension of the same type is found within the certificate.
365
Paul Kehrerd8fc0be2015-04-21 08:31:10 -0500366 :raises cryptography.x509.UnsupportedExtension: If the certificate
367 contains an extension that is not supported.
368
Paul Kehrerbed07352015-04-21 08:31:10 -0500369 :raises cryptography.x509.UnsupportedGeneralNameType: If an extension
370 contains a general name that is not supported.
371
Paul Kehrerb8968812015-05-15 09:01:34 -0700372 :raises UnicodeError: If an extension contains IDNA encoding that is
373 invalid or not compliant with IDNA 2008.
374
Paul Kehrerfa56a232015-03-17 13:14:03 -0500375 .. doctest::
376
377 >>> for ext in cert.extensions:
378 ... print(ext)
Paul Kehrerd774de92015-05-03 10:52:25 -0500379 <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)>)>
Paul Kehrercbfb1012015-04-10 20:57:20 -0400380 <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')>)>
Paul Kehrerb511ba82015-04-15 11:22:48 -0400381 <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)>)>
Paul Kehrer2008d9c2015-05-12 22:19:56 -0500382 <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)>])>)>
Paul Kehrerfa56a232015-03-17 13:14:03 -0500383 <Extension(oid=<ObjectIdentifier(oid=2.5.29.19, name=basicConstraints)>, critical=True, value=<BasicConstraints(ca=True, path_length=None)>)>
384
Paul Kehrerd91e7c12015-10-01 16:50:42 -0500385 .. attribute:: signature
386
387 .. versionadded:: 1.2
388
389 :type: bytes
390
391 The bytes of the certificate's signature.
392
Paul Kehrerd2898052015-11-03 22:00:41 +0900393 .. attribute:: tbs_certificate_bytes
Paul Kehrerd91e7c12015-10-01 16:50:42 -0500394
395 .. versionadded:: 1.2
396
397 :type: bytes
398
399 The DER encoded bytes payload (as defined by :rfc:`5280`) that is hashed
400 and then signed by the private key of the certificate's issuer. This
401 data may be used to validate a signature, but use extreme caution as
402 certificate validation is a complex problem that involves much more
403 than just signature checks.
404
Andre Carona8aded62015-05-19 20:11:57 -0400405 .. method:: public_bytes(encoding)
406
Alex Gaynord0b376b2015-07-05 13:58:12 -0400407 .. versionadded:: 1.0
408
Andre Carona8aded62015-05-19 20:11:57 -0400409 :param encoding: The
410 :class:`~cryptography.hazmat.primitives.serialization.Encoding`
411 that will be used to serialize the certificate.
412
413 :return bytes: The data that can be written to a file or sent
414 over the network to be verified by clients.
415
Erik Trauschke2dcce902015-05-14 16:12:24 -0700416X.509 CRL (Certificate Revocation List) Object
417~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
418
419.. class:: CertificateRevocationList
420
421 .. versionadded:: 1.0
422
Erik Trauschke3cdabaf2015-10-13 09:42:53 -0700423 A CertificateRevocationList is an object representing a list of revoked
424 certificates. The object is iterable and will yield the RevokedCertificate
425 objects stored in this CRL.
426
427 .. doctest::
Erik Trauschkeb14f7d12015-10-13 09:55:39 -0700428
Erik Trauschke3cdabaf2015-10-13 09:42:53 -0700429 >>> len(crl)
430 1
Paul Kehrerdcdf9672015-10-21 20:27:28 -0500431 >>> revoked_certificate = crl[0]
432 >>> type(revoked_certificate)
Erik Trauschke3cdabaf2015-10-13 09:42:53 -0700433 <class 'cryptography.hazmat.backends.openssl.x509._RevokedCertificate'>
434 >>> for r in crl:
435 ... print(r.serial_number)
436 0
437
Erik Trauschke2dcce902015-05-14 16:12:24 -0700438 .. method:: fingerprint(algorithm)
439
440 :param algorithm: The
441 :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm`
442 that will be used to generate the fingerprint.
443
444 :return bytes: The fingerprint using the supplied hash algorithm, as
445 bytes.
446
Erik Trauschkedc570402015-09-24 20:24:28 -0700447 .. doctest::
448
449 >>> from cryptography.hazmat.primitives import hashes
450 >>> crl.fingerprint(hashes.SHA256())
451 'e\xcf.\xc4:\x83?1\xdc\xf3\xfc\x95\xd7\xb3\x87\xb3\x8e\xf8\xb93!\x87\x07\x9d\x1b\xb4!\xb9\xe4W\xf4\x1f'
452
Erik Trauschke2dcce902015-05-14 16:12:24 -0700453 .. attribute:: signature_hash_algorithm
454
455 :type: :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm`
456
457 Returns the
458 :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` which
459 was used in signing this CRL.
460
Erik Trauschkedc570402015-09-24 20:24:28 -0700461 .. doctest::
462
463 >>> from cryptography.hazmat.primitives import hashes
464 >>> isinstance(crl.signature_hash_algorithm, hashes.SHA256)
465 True
466
Erik Trauschke2dcce902015-05-14 16:12:24 -0700467 .. attribute:: issuer
468
469 :type: :class:`Name`
470
471 The :class:`Name` of the issuer.
472
Erik Trauschkedc570402015-09-24 20:24:28 -0700473 .. doctest::
474
475 >>> crl.issuer
476 <Name([<NameAttribute(oid=<ObjectIdentifier(oid=2.5.4.6, name=countryName)>, value=u'US')>, <NameAttribute(oid=<ObjectIdentifier(oid=2.5.4.3, name=commonName)>, value=u'cryptography.io')>])>
477
Erik Trauschke2dcce902015-05-14 16:12:24 -0700478 .. attribute:: next_update
479
480 :type: :class:`datetime.datetime`
481
482 A naïve datetime representing when the next update to this CRL is
483 expected.
484
Erik Trauschkedc570402015-09-24 20:24:28 -0700485 .. doctest::
486
487 >>> crl.next_update
488 datetime.datetime(2016, 1, 1, 0, 0)
489
Erik Trauschke2dcce902015-05-14 16:12:24 -0700490 .. attribute:: last_update
491
492 :type: :class:`datetime.datetime`
493
494 A naïve datetime representing when the this CRL was last updated.
495
Erik Trauschkedc570402015-09-24 20:24:28 -0700496 .. doctest::
Erik Trauschke2dcce902015-05-14 16:12:24 -0700497
Erik Trauschkedc570402015-09-24 20:24:28 -0700498 >>> crl.last_update
499 datetime.datetime(2015, 1, 1, 0, 0)
Erik Trauschke2dcce902015-05-14 16:12:24 -0700500
501 .. attribute:: extensions
502
503 :type: :class:`Extensions`
504
505 The extensions encoded in the CRL.
506
Erik Trauschke6abe2bb2015-11-19 10:27:01 -0800507 .. attribute:: signature
508
509 .. versionadded:: 1.2
510
511 :type: bytes
512
513 The bytes of the CRL's signature.
514
515 .. attribute:: tbs_certlist_bytes
516
517 .. versionadded:: 1.2
518
519 :type: bytes
520
521 The DER encoded bytes payload (as defined by :rfc:`5280`) that is hashed
522 and then signed by the private key of the CRL's issuer. This data may be
523 used to validate a signature, but use extreme caution as CRL validation
524 is a complex problem that involves much more than just signature checks.
525
Paul Kehrer54a837d2015-12-20 23:42:32 -0600526 .. method:: public_bytes(encoding)
527
528 .. versionadded:: 1.2
529
530 :param encoding: The
531 :class:`~cryptography.hazmat.primitives.serialization.Encoding`
532 that will be used to serialize the certificate revocation list.
533
534 :return bytes: The data that can be written to a file or sent
535 over the network and used as part of a certificate verification
536 process.
537
Erik Trauschke6abe2bb2015-11-19 10:27:01 -0800538
Andre Caron9bbfcea2015-05-18 20:55:29 -0400539X.509 Certificate Builder
540~~~~~~~~~~~~~~~~~~~~~~~~~
541
542.. class:: CertificateBuilder
543
Ian Cordasco1517a4b2015-08-02 22:11:19 -0500544 .. versionadded:: 1.0
545
546 .. doctest::
547
548 >>> from cryptography import x509
549 >>> from cryptography.hazmat.backends import default_backend
550 >>> from cryptography.hazmat.primitives import hashes
551 >>> from cryptography.hazmat.primitives.asymmetric import rsa
Paul Kehrere27f6582015-08-10 18:33:38 -0500552 >>> from cryptography.x509.oid import NameOID
Ian Cordasco1517a4b2015-08-02 22:11:19 -0500553 >>> import datetime
554 >>> import uuid
555 >>> one_day = datetime.timedelta(1, 0, 0)
556 >>> private_key = rsa.generate_private_key(
557 ... public_exponent=65537,
558 ... key_size=2048,
559 ... backend=default_backend()
560 ... )
Cory Benfieldc47b2522015-12-07 15:25:12 +0000561 >>> public_key = private_key.public_key()
Ian Cordasco1517a4b2015-08-02 22:11:19 -0500562 >>> builder = x509.CertificateBuilder()
563 >>> builder = builder.subject_name(x509.Name([
Paul Kehrere27f6582015-08-10 18:33:38 -0500564 ... x509.NameAttribute(NameOID.COMMON_NAME, u'cryptography.io'),
Ian Cordasco1517a4b2015-08-02 22:11:19 -0500565 ... ]))
566 >>> builder = builder.issuer_name(x509.Name([
Paul Kehrere27f6582015-08-10 18:33:38 -0500567 ... x509.NameAttribute(NameOID.COMMON_NAME, u'cryptography.io'),
Ian Cordasco1517a4b2015-08-02 22:11:19 -0500568 ... ]))
569 >>> builder = builder.not_valid_before(datetime.datetime.today() - one_day)
570 >>> builder = builder.not_valid_after(datetime.datetime(2018, 8, 2))
571 >>> builder = builder.serial_number(int(uuid.uuid4()))
572 >>> builder = builder.public_key(public_key)
573 >>> builder = builder.add_extension(
574 ... x509.BasicConstraints(ca=False, path_length=None), critical=True,
575 ... )
576 >>> certificate = builder.sign(
577 ... private_key=private_key, algorithm=hashes.SHA256(),
578 ... backend=default_backend()
579 ... )
580 >>> isinstance(certificate, x509.Certificate)
581 True
582
Ian Cordasco0092a0b2015-07-18 21:46:41 -0500583 .. method:: issuer_name(name)
Andre Caron9bbfcea2015-05-18 20:55:29 -0400584
585 Sets the issuer's distinguished name.
586
Ian Cordascoc9682ad2015-08-01 12:11:13 -0500587 :param name: The :class:`~cryptography.x509.Name` that describes the
588 issuer (CA).
Andre Caron9bbfcea2015-05-18 20:55:29 -0400589
Ian Cordasco0092a0b2015-07-18 21:46:41 -0500590 .. method:: subject_name(name)
Andre Caron9bbfcea2015-05-18 20:55:29 -0400591
592 Sets the subject's distinguished name.
593
Ian Cordascoc9682ad2015-08-01 12:11:13 -0500594 :param name: The :class:`~cryptography.x509.Name` that describes the
Ian Cordasco85fc4d52015-08-01 20:29:31 -0500595 subject.
Andre Caron9bbfcea2015-05-18 20:55:29 -0400596
Ian Cordasco0092a0b2015-07-18 21:46:41 -0500597 .. method:: public_key(public_key)
Andre Caron9bbfcea2015-05-18 20:55:29 -0400598
599 Sets the subject's public key.
600
Ian Cordasco8f571422015-08-02 11:31:08 -0500601 :param public_key: The subject's public key. This can be one of
602 :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey`,
603 :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPublicKey` or
604 :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey`
Andre Caron9bbfcea2015-05-18 20:55:29 -0400605
Ian Cordasco0092a0b2015-07-18 21:46:41 -0500606 .. method:: serial_number(serial_number)
Andre Caron9bbfcea2015-05-18 20:55:29 -0400607
608 Sets the certificate's serial number (an integer). The CA's policy
609 determines how it attributes serial numbers to certificates. The only
610 requirement is that this number uniquely identify the certificate given
611 the issuer.
612
613 :param serial_number: Integer number that will be used by the CA to
614 identify this certificate (most notably during certificate
Ian Cordasco17c89002015-08-02 21:13:59 -0500615 revocation checking). Users are encouraged to use a method of
616 generating 20 bytes of entropy, e.g., UUID4. For more information
Ian Cordascob7530a42015-08-02 22:47:06 -0500617 on secure random number generation, see :doc:`/random-numbers`.
Andre Caron9bbfcea2015-05-18 20:55:29 -0400618
Ian Cordasco0092a0b2015-07-18 21:46:41 -0500619 .. method:: not_valid_before(time)
Andre Caron9bbfcea2015-05-18 20:55:29 -0400620
621 Sets the certificate's activation time. This is the time from which
622 clients can start trusting the certificate. It may be different from
623 the time at which the certificate was created.
624
Ian Cordasco17c89002015-08-02 21:13:59 -0500625 :param time: The :class:`datetime.datetime` object (in UTC) that marks the
Andre Caron9bbfcea2015-05-18 20:55:29 -0400626 activation time for the certificate. The certificate may not be
627 trusted clients if it is used before this time.
628
Ian Cordasco0092a0b2015-07-18 21:46:41 -0500629 .. method:: not_valid_after(time)
Andre Caron9bbfcea2015-05-18 20:55:29 -0400630
631 Sets the certificate's expiration time. This is the time from which
632 clients should no longer trust the certificate. The CA's policy will
633 determine how long the certificate should remain in use.
634
Ian Cordasco17c89002015-08-02 21:13:59 -0500635 :param time: The :class:`datetime.datetime` object (in UTC) that marks the
Andre Caron9bbfcea2015-05-18 20:55:29 -0400636 expiration time for the certificate. The certificate may not be
637 trusted clients if it is used after this time.
638
Ian Cordasco17c89002015-08-02 21:13:59 -0500639 .. method:: add_extension(extension, critical)
Andre Caron9bbfcea2015-05-18 20:55:29 -0400640
641 Adds an X.509 extension to the certificate.
642
Paul Kehrer2c145cc2015-10-02 11:27:21 -0500643 :param extension: An extension conforming to the
644 :class:`~cryptography.x509.ExtensionType` interface.
Andre Caron9bbfcea2015-05-18 20:55:29 -0400645
Ian Cordasco17c89002015-08-02 21:13:59 -0500646 :param critical: Set to ``True`` if the extension must be understood and
647 handled by whoever reads the certificate.
648
Paul Kehrer9add80e2015-08-03 17:53:14 +0100649 .. method:: sign(private_key, algorithm, backend)
Andre Caron9bbfcea2015-05-18 20:55:29 -0400650
651 Sign the certificate using the CA's private key.
652
Ian Cordascoc5e1c252015-07-31 23:33:35 -0500653 :param private_key: The
654 :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey`,
655 :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPrivateKey` or
656 :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateKey`
657 that will be used to sign the certificate.
658
Andre Caron9bbfcea2015-05-18 20:55:29 -0400659 :param algorithm: The
660 :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` that
661 will be used to generate the signature.
662
Paul Kehrer9add80e2015-08-03 17:53:14 +0100663 :param backend: Backend that will be used to build the certificate.
664 Must support the
665 :class:`~cryptography.hazmat.backends.interfaces.X509Backend`
666 interface.
667
Benjamin Peterson9ed312b2015-10-12 20:51:34 -0700668 :returns: :class:`~cryptography.x509.Certificate`
Andre Caron9bbfcea2015-05-18 20:55:29 -0400669
670
Paul Kehrer5aadb9c2015-03-11 20:48:42 -0500671X.509 CSR (Certificate Signing Request) Object
672~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600673
Paul Kehrera1a1f232015-03-15 15:34:35 -0500674.. class:: CertificateSigningRequest
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600675
676 .. versionadded:: 0.9
677
678 .. method:: public_key()
679
Alex Gaynor4c2561a2015-10-12 23:53:39 -0400680 The public key associated with the request.
681
682 :returns:
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600683 :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey` or
684 :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPublicKey` or
685 :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey`
686
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600687 .. doctest::
688
689 >>> from cryptography.hazmat.primitives.asymmetric import rsa
Paul Kehrera1a1f232015-03-15 15:34:35 -0500690 >>> public_key = csr.public_key()
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600691 >>> isinstance(public_key, rsa.RSAPublicKey)
692 True
693
694 .. attribute:: subject
695
696 :type: :class:`Name`
697
698 The :class:`Name` of the subject.
699
700 .. attribute:: signature_hash_algorithm
701
702 :type: :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm`
703
704 Returns the
705 :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` which
706 was used in signing this request.
707
708 .. doctest::
709
710 >>> from cryptography.hazmat.primitives import hashes
Paul Kehrera1a1f232015-03-15 15:34:35 -0500711 >>> isinstance(csr.signature_hash_algorithm, hashes.SHA1)
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600712 True
713
Paul Kehrerc4e61942015-08-01 21:21:13 +0100714 .. attribute:: extensions
715
716 :type: :class:`Extensions`
717
718 The extensions encoded in the certificate signing request.
719
720 :raises cryptography.x509.DuplicateExtension: If more than one
Paul Kehrer24283d22015-08-01 21:31:19 +0100721 extension of the same type is found within the certificate signing request.
Paul Kehrerc4e61942015-08-01 21:21:13 +0100722
Paul Kehrer24283d22015-08-01 21:31:19 +0100723 :raises cryptography.x509.UnsupportedExtension: If the certificate signing request
Paul Kehrerc4e61942015-08-01 21:21:13 +0100724 contains an extension that is not supported.
725
726 :raises cryptography.x509.UnsupportedGeneralNameType: If an extension
727 contains a general name that is not supported.
728
729 :raises UnicodeError: If an extension contains IDNA encoding that is
730 invalid or not compliant with IDNA 2008.
731
732
Andre Caron476c5df2015-05-18 10:23:28 -0400733 .. method:: public_bytes(encoding)
734
Alex Gaynord0b376b2015-07-05 13:58:12 -0400735 .. versionadded:: 1.0
736
Andre Caron476c5df2015-05-18 10:23:28 -0400737 :param encoding: The
738 :class:`~cryptography.hazmat.primitives.serialization.Encoding`
739 that will be used to serialize the certificate request.
740
741 :return bytes: The data that can be written to a file or sent
742 over the network to be signed by the certificate
743 authority.
744
Paul Kehrerab209392015-12-01 14:50:31 -0600745 .. attribute:: signature
746
747 .. versionadded:: 1.2
748
749 :type: bytes
750
751 The bytes of the certificate signing request's signature.
752
753 .. attribute:: tbs_certrequest_bytes
754
755 .. versionadded:: 1.2
756
757 :type: bytes
758
759 The DER encoded bytes payload (as defined by :rfc:`2986`) that is
760 hashed and then signed by the private key (corresponding to the public
761 key embedded in the CSR). This data may be used to validate the CSR
762 signature.
763
Paul Kehrerbfac2d12015-12-19 23:32:08 -0600764X.509 Certificate Revocation List Builder
765~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
766
767.. class:: CertificateRevocationListBuilder
768
769 .. versionadded:: 1.2
770
771 .. doctest::
772
773 >>> from cryptography import x509
774 >>> from cryptography.hazmat.backends import default_backend
775 >>> from cryptography.hazmat.primitives import hashes
776 >>> from cryptography.hazmat.primitives.asymmetric import rsa
777 >>> from cryptography.x509.oid import NameOID
778 >>> import datetime
779 >>> one_day = datetime.timedelta(1, 0, 0)
780 >>> private_key = rsa.generate_private_key(
781 ... public_exponent=65537,
782 ... key_size=2048,
783 ... backend=default_backend()
784 ... )
785 >>> builder = x509.CertificateRevocationListBuilder()
786 >>> builder = builder.issuer_name(x509.Name([
787 ... x509.NameAttribute(NameOID.COMMON_NAME, u'cryptography.io CA'),
788 ... ]))
789 >>> builder = builder.last_update(datetime.datetime.today())
790 >>> builder = builder.next_update(datetime.datetime.today() + one_day)
Paul Kehrer4c7fd5f2015-12-25 13:40:55 -0600791 >>> revoked_cert = x509.RevokedCertificateBuilder().serial_number(
792 ... 333
793 ... ).revocation_date(
794 ... datetime.datetime.today()
795 ... ).build(default_backend())
796 >>> builder = builder.add_revoked_certificate(revoked_cert)
Paul Kehrerbfac2d12015-12-19 23:32:08 -0600797 >>> crl = builder.sign(
798 ... private_key=private_key, algorithm=hashes.SHA256(),
799 ... backend=default_backend()
800 ... )
Paul Kehrer4c7fd5f2015-12-25 13:40:55 -0600801 >>> len(crl)
802 1
Paul Kehrerbfac2d12015-12-19 23:32:08 -0600803
804 .. method:: issuer_name(name)
805
806 Sets the issuer's distinguished name.
807
808 :param name: The :class:`~cryptography.x509.Name` that describes the
809 issuer (CA).
810
811 .. method:: last_update(time)
812
Paul Kehrer0325b9d2015-12-24 19:19:59 -0600813 Sets this CRL's activation time. This is the time from which
814 clients can start trusting this CRL. It may be different from
815 the time at which this CRL was created. This is also known as the
Paul Kehrerbfac2d12015-12-19 23:32:08 -0600816 ``thisUpdate`` time.
817
Paul Kehrer0325b9d2015-12-24 19:19:59 -0600818 :param time: The :class:`datetime.datetime` object (in UTC) that marks
819 the activation time for this CRL. The CRL may not be trusted if it
820 is used before this time.
Paul Kehrerbfac2d12015-12-19 23:32:08 -0600821
822 .. method:: next_update(time)
823
Paul Kehrer0325b9d2015-12-24 19:19:59 -0600824 Sets this CRL's next update time. This is the time by which
825 a new CRL will be issued. The CA is allowed to issue a new CRL before
826 this date, however clients are not required to check for it.
Paul Kehrerbfac2d12015-12-19 23:32:08 -0600827
Paul Kehrer0325b9d2015-12-24 19:19:59 -0600828 :param time: The :class:`datetime.datetime` object (in UTC) that marks
829 the next update time for this CRL.
Paul Kehrerbfac2d12015-12-19 23:32:08 -0600830
Paul Kehrer426b48d2015-12-24 20:50:43 -0600831 .. method:: add_extension(extension, critical)
832
833 Adds an X.509 extension to this CRL.
834
835 :param extension: An extension with the
836 :class:`~cryptography.x509.ExtensionType` interface.
837
838 :param critical: Set to ``True`` if the extension must be understood and
839 handled by whoever reads the CRL.
840
Paul Kehrer4c7fd5f2015-12-25 13:40:55 -0600841 .. method:: add_revoked_certificate(revoked_certificate)
842
843 Adds a revoked certificate to this CRL.
844
845 :param revoked_certificate: An instance of
846 :class:`~cryptography.x509.RevokedCertificate`. These can be
847 obtained from an existing CRL or created with
848 :class:`~cryptography.x509.RevokedCertificateBuilder`.
849
Paul Kehrerbfac2d12015-12-19 23:32:08 -0600850 .. method:: sign(private_key, algorithm, backend)
851
Paul Kehrer0325b9d2015-12-24 19:19:59 -0600852 Sign this CRL using the CA's private key.
Paul Kehrerbfac2d12015-12-19 23:32:08 -0600853
854 :param private_key: The
855 :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey`,
856 :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPrivateKey` or
857 :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateKey`
858 that will be used to sign the certificate.
859
860 :param algorithm: The
861 :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` that
862 will be used to generate the signature.
863
864 :param backend: Backend that will be used to build the CRL.
865 Must support the
866 :class:`~cryptography.hazmat.backends.interfaces.X509Backend`
867 interface.
868
869 :returns: :class:`~cryptography.x509.CertificateRevocationList`
870
Erik Trauschke2dcce902015-05-14 16:12:24 -0700871X.509 Revoked Certificate Object
Erik Trauschkec5a8d172015-05-28 10:24:25 -0700872~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Erik Trauschke2dcce902015-05-14 16:12:24 -0700873
874.. class:: RevokedCertificate
875
876 .. versionadded:: 1.0
877
878 .. attribute:: serial_number
879
880 :type: :class:`int`
881
882 An integer representing the serial number of the revoked certificate.
883
Erik Trauschkedc570402015-09-24 20:24:28 -0700884 .. doctest::
885
Erik Trauschke3cdabaf2015-10-13 09:42:53 -0700886 >>> revoked_certificate.serial_number
Erik Trauschkedc570402015-09-24 20:24:28 -0700887 0
888
Erik Trauschke2dcce902015-05-14 16:12:24 -0700889 .. attribute:: revocation_date
890
891 :type: :class:`datetime.datetime`
892
893 A naïve datetime representing the date this certificates was revoked.
894
Erik Trauschkedc570402015-09-24 20:24:28 -0700895 .. doctest::
896
Erik Trauschke77f5a252015-10-14 08:06:38 -0700897 >>> revoked_certificate.revocation_date
Erik Trauschkedc570402015-09-24 20:24:28 -0700898 datetime.datetime(2015, 1, 1, 0, 0)
899
Erik Trauschke2dcce902015-05-14 16:12:24 -0700900 .. attribute:: extensions
901
902 :type: :class:`Extensions`
903
904 The extensions encoded in the revoked certificate.
Andre Caron476c5df2015-05-18 10:23:28 -0400905
Erik Trauschkedc570402015-09-24 20:24:28 -0700906 .. doctest::
907
Erik Trauschke77f5a252015-10-14 08:06:38 -0700908 >>> for ext in revoked_certificate.extensions:
Erik Trauschkedc570402015-09-24 20:24:28 -0700909 ... print(ext)
Paul Kehrer23c0bbc2015-12-25 22:35:19 -0600910 <Extension(oid=<ObjectIdentifier(oid=2.5.29.24, name=invalidityDate)>, critical=False, value=<InvalidityDate(invalidity_date=2015-01-01 00:00:00)>)>
Paul Kehrer7058ece2015-12-25 22:28:29 -0600911 <Extension(oid=<ObjectIdentifier(oid=2.5.29.21, name=cRLReason)>, critical=False, value=<CRLReason(reason=ReasonFlags.key_compromise)>)>
Erik Trauschkedc570402015-09-24 20:24:28 -0700912
Paul Kehrerc33ffd72015-12-25 10:59:22 -0600913X.509 Revoked Certificate Builder
914~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
915
916.. class:: RevokedCertificateBuilder
917
918 This class is used to create :class:`~cryptography.x509.RevokedCertificate`
919 objects that can be used with the
920 :class:`~cryptography.x509.CertificateRevocationListBuilder`.
921
922 .. versionadded:: 1.2
923
924 .. doctest::
925
926 >>> from cryptography import x509
927 >>> from cryptography.hazmat.backends import default_backend
928 >>> import datetime
929 >>> builder = x509.RevokedCertificateBuilder()
930 >>> builder = builder.revocation_date(datetime.datetime.today())
931 >>> builder = builder.serial_number(3333)
932 >>> revoked_certificate = builder.build(default_backend())
933 >>> isinstance(revoked_certificate, x509.RevokedCertificate)
934 True
935
936 .. method:: serial_number(serial_number)
937
938 Sets the revoked certificate's serial number.
939
940 :param serial_number: Integer number that is used to identify the
941 revoked certificate.
942
943 .. method:: revocation_date(time)
944
945 Sets the certificate's revocation date.
946
947 :param time: The :class:`datetime.datetime` object (in UTC) that marks the
948 revocation time for the certificate.
949
Paul Kehrere5f152b2015-12-25 23:55:47 -0600950 .. method:: add_extension(extension, critical)
951
952 Adds an X.509 extension to this revoked certificate.
953
954 :param extension: An instance of one of the
955 :ref:`CRL entry extensions <crl_entry_extensions>`.
956
957 :param critical: Set to ``True`` if the extension must be understood and
958 handled.
959
Paul Kehrerc33ffd72015-12-25 10:59:22 -0600960 .. method:: build(backend)
961
962 Create a revoked certificate object using the provided backend.
963
964 :param backend: Backend that will be used to build the revoked
965 certificate. Must support the
966 :class:`~cryptography.hazmat.backends.interfaces.X509Backend`
967 interface.
968
969 :returns: :class:`~cryptography.x509.RevokedCertificate`
970
Andre Caron0ef595f2015-05-18 13:53:43 -0400971X.509 CSR (Certificate Signing Request) Builder Object
972~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
973
974.. class:: CertificateSigningRequestBuilder
975
Andre Carond259ee52015-06-02 23:47:11 -0400976 .. versionadded:: 1.0
977
978 .. doctest::
979
980 >>> from cryptography import x509
981 >>> from cryptography.hazmat.backends import default_backend
982 >>> from cryptography.hazmat.primitives import hashes
983 >>> from cryptography.hazmat.primitives.asymmetric import rsa
Paul Kehrere27f6582015-08-10 18:33:38 -0500984 >>> from cryptography.x509.oid import NameOID
Andre Carond259ee52015-06-02 23:47:11 -0400985 >>> private_key = rsa.generate_private_key(
986 ... public_exponent=65537,
987 ... key_size=2048,
988 ... backend=default_backend()
989 ... )
990 >>> builder = x509.CertificateSigningRequestBuilder()
Andre Carona9a51172015-06-06 20:18:44 -0400991 >>> builder = builder.subject_name(x509.Name([
Paul Kehrere27f6582015-08-10 18:33:38 -0500992 ... x509.NameAttribute(NameOID.COMMON_NAME, u'cryptography.io'),
Andre Carond259ee52015-06-02 23:47:11 -0400993 ... ]))
Ian Cordascof06b6be2015-06-21 10:09:18 -0500994 >>> builder = builder.add_extension(
Ian Cordasco0112b022015-06-16 17:51:18 -0500995 ... x509.BasicConstraints(ca=False, path_length=None), critical=True,
Andre Caron472fd692015-06-06 20:04:44 -0400996 ... )
Andre Carond259ee52015-06-02 23:47:11 -0400997 >>> request = builder.sign(
Alex Gaynorde9e5842015-06-26 20:11:23 -0400998 ... private_key, hashes.SHA256(), default_backend()
Andre Carond259ee52015-06-02 23:47:11 -0400999 ... )
1000 >>> isinstance(request, x509.CertificateSigningRequest)
1001 True
1002
Andre Carona9a51172015-06-06 20:18:44 -04001003 .. method:: subject_name(name)
Andre Caron0ef595f2015-05-18 13:53:43 -04001004
Andre Caron341ff852015-06-06 20:14:31 -04001005 :param name: The :class:`~cryptography.x509.Name` of the certificate
1006 subject.
1007 :returns: A new
1008 :class:`~cryptography.x509.CertificateSigningRequestBuilder`.
Andre Caron0ef595f2015-05-18 13:53:43 -04001009
Ian Cordascof06b6be2015-06-21 10:09:18 -05001010 .. method:: add_extension(extension, critical)
Andre Caron0ef595f2015-05-18 13:53:43 -04001011
Paul Kehrer2c145cc2015-10-02 11:27:21 -05001012 :param extension: An extension conforming to the
1013 :class:`~cryptography.x509.ExtensionType` interface.
Andre Caron472fd692015-06-06 20:04:44 -04001014 :param critical: Set to `True` if the extension must be understood and
1015 handled by whoever reads the certificate.
Andre Caron341ff852015-06-06 20:14:31 -04001016 :returns: A new
1017 :class:`~cryptography.x509.CertificateSigningRequestBuilder`.
Andre Caron0ef595f2015-05-18 13:53:43 -04001018
Alex Gaynorb3b0fbe2015-06-26 19:57:18 -04001019 .. method:: sign(private_key, algorithm, backend)
Andre Caron0ef595f2015-05-18 13:53:43 -04001020
1021 :param backend: Backend that will be used to sign the request.
1022 Must support the
1023 :class:`~cryptography.hazmat.backends.interfaces.X509Backend`
1024 interface.
1025
1026 :param private_key: The
Andre Caron24f9bf42015-06-06 20:14:54 -04001027 :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey`,
1028 :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPrivateKey` or
1029 :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateKey`
Andre Caron0ef595f2015-05-18 13:53:43 -04001030 that will be used to sign the request. When the request is
1031 signed by a certificate authority, the private key's associated
1032 public key will be stored in the resulting certificate.
1033
1034 :param algorithm: The
1035 :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm`
1036 that will be used to generate the request signature.
1037
Andre Caron341ff852015-06-06 20:14:31 -04001038 :returns: A new
1039 :class:`~cryptography.x509.CertificateSigningRequest`.
Andre Caron0ef595f2015-05-18 13:53:43 -04001040
1041
Paul Kehrer719d5362015-01-01 20:03:52 -06001042.. class:: Name
1043
1044 .. versionadded:: 0.8
1045
Paul Kehrer53d8d492015-02-13 18:47:30 -06001046 An X509 Name is an ordered list of attributes. The object is iterable to
Paul Kehrerd21596e2015-02-14 09:17:26 -06001047 get every attribute or you can use :meth:`Name.get_attributes_for_oid` to
Paul Kehrer719d5362015-01-01 20:03:52 -06001048 obtain the specific type you want. Names are sometimes represented as a
Paul Kehrer53d8d492015-02-13 18:47:30 -06001049 slash or comma delimited string (e.g. ``/CN=mydomain.com/O=My Org/C=US`` or
1050 ``CN=mydomain.com, O=My Org, C=US``).
Paul Kehrer719d5362015-01-01 20:03:52 -06001051
Paul Kehrer53d8d492015-02-13 18:47:30 -06001052 .. doctest::
Paul Kehrer719d5362015-01-01 20:03:52 -06001053
Paul Kehrer8b21a4a2015-02-14 07:56:36 -06001054 >>> len(cert.subject)
Paul Kehrer53d8d492015-02-13 18:47:30 -06001055 3
Paul Kehrer8b21a4a2015-02-14 07:56:36 -06001056 >>> for attribute in cert.subject:
1057 ... print(attribute)
1058 <NameAttribute(oid=<ObjectIdentifier(oid=2.5.4.6, name=countryName)>, value=u'US')>
1059 <NameAttribute(oid=<ObjectIdentifier(oid=2.5.4.10, name=organizationName)>, value=u'Test Certificates 2011')>
1060 <NameAttribute(oid=<ObjectIdentifier(oid=2.5.4.3, name=commonName)>, value=u'Good CA')>
Paul Kehrer719d5362015-01-01 20:03:52 -06001061
Paul Kehrere901d642015-02-11 18:50:58 -06001062 .. method:: get_attributes_for_oid(oid)
Paul Kehrer719d5362015-01-01 20:03:52 -06001063
Paul Kehrere901d642015-02-11 18:50:58 -06001064 :param oid: An :class:`ObjectIdentifier` instance.
Paul Kehrer719d5362015-01-01 20:03:52 -06001065
Paul Kehrere901d642015-02-11 18:50:58 -06001066 :returns: A list of :class:`NameAttribute` instances that match the
1067 OID provided. If nothing matches an empty list will be returned.
Paul Kehrer719d5362015-01-01 20:03:52 -06001068
1069 .. doctest::
1070
Paul Kehrere27f6582015-08-10 18:33:38 -05001071 >>> cert.subject.get_attributes_for_oid(NameOID.COMMON_NAME)
Paul Kehrere901d642015-02-11 18:50:58 -06001072 [<NameAttribute(oid=<ObjectIdentifier(oid=2.5.4.3, name=commonName)>, value=u'Good CA')>]
Paul Kehrerb2de9482014-12-11 14:54:48 -06001073
Paul Kehrere76cd272014-12-14 19:00:51 -06001074.. class:: Version
Paul Kehrer016e08a2014-11-26 09:41:18 -10001075
1076 .. versionadded:: 0.7
1077
1078 An enumeration for X.509 versions.
1079
1080 .. attribute:: v1
1081
1082 For version 1 X.509 certificates.
1083
1084 .. attribute:: v3
1085
1086 For version 3 X.509 certificates.
1087
Paul Kehrer806bfb22015-02-02 17:05:24 -06001088.. class:: NameAttribute
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001089
1090 .. versionadded:: 0.8
1091
Paul Kehrer834d22f2015-02-06 11:01:07 -06001092 An X.509 name consists of a list of NameAttribute instances.
Paul Kehrer5b0a8d62015-01-30 20:05:55 -06001093
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001094 .. attribute:: oid
1095
1096 :type: :class:`ObjectIdentifier`
1097
1098 The attribute OID.
1099
1100 .. attribute:: value
1101
Paul Kehrerd5852cb2015-01-30 08:25:23 -06001102 :type: :term:`text`
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001103
1104 The value of the attribute.
1105
1106.. class:: ObjectIdentifier
1107
1108 .. versionadded:: 0.8
1109
Paul Kehrer5b0a8d62015-01-30 20:05:55 -06001110 Object identifiers (frequently seen abbreviated as OID) identify the type
Paul Kehrer806bfb22015-02-02 17:05:24 -06001111 of a value (see: :class:`NameAttribute`).
Paul Kehrer5b0a8d62015-01-30 20:05:55 -06001112
Paul Kehrerd44f9a62015-02-04 14:47:34 -06001113 .. attribute:: dotted_string
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001114
1115 :type: :class:`str`
1116
Paul Kehrerfedf4f42015-02-06 11:22:07 -06001117 The dotted string value of the OID (e.g. ``"2.5.4.3"``)
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001118
Paul Kehrer31bdf792015-03-25 14:11:00 -05001119.. _general_name_classes:
1120
1121General Name Classes
1122~~~~~~~~~~~~~~~~~~~~
1123
1124.. class:: GeneralName
1125
1126 .. versionadded:: 0.9
1127
1128 This is the generic interface that all the following classes are registered
1129 against.
1130
Paul Kehrer47c32ba2015-10-28 09:12:07 +09001131.. class:: RFC822Name(value)
Paul Kehrer31bdf792015-03-25 14:11:00 -05001132
1133 .. versionadded:: 0.9
1134
1135 This corresponds to an email address. For example, ``user@example.com``.
1136
1137 .. attribute:: value
1138
1139 :type: :term:`text`
1140
Paul Kehrer47c32ba2015-10-28 09:12:07 +09001141.. class:: DNSName(value)
Paul Kehrer31bdf792015-03-25 14:11:00 -05001142
1143 .. versionadded:: 0.9
1144
1145 This corresponds to a domain name. For example, ``cryptography.io``.
1146
1147 .. attribute:: value
1148
1149 :type: :term:`text`
1150
Paul Kehrer47c32ba2015-10-28 09:12:07 +09001151.. class:: DirectoryName(value)
Paul Kehrer31bdf792015-03-25 14:11:00 -05001152
1153 .. versionadded:: 0.9
1154
1155 This corresponds to a directory name.
1156
1157 .. attribute:: value
1158
1159 :type: :class:`Name`
1160
Paul Kehrer47c32ba2015-10-28 09:12:07 +09001161.. class:: UniformResourceIdentifier(value)
Paul Kehrer31bdf792015-03-25 14:11:00 -05001162
1163 .. versionadded:: 0.9
1164
1165 This corresponds to a uniform resource identifier. For example,
Paul Kehrerb8ef82e2015-04-22 16:04:24 -05001166 ``https://cryptography.io``. The URI is parsed and IDNA decoded (see
1167 :rfc:`5895`).
1168
1169 .. note::
1170
1171 URIs that do not contain ``://`` in them will not be decoded.
Paul Kehrer31bdf792015-03-25 14:11:00 -05001172
1173 .. attribute:: value
1174
1175 :type: :term:`text`
1176
Paul Kehrer47c32ba2015-10-28 09:12:07 +09001177.. class:: IPAddress(value)
Paul Kehrer31bdf792015-03-25 14:11:00 -05001178
1179 .. versionadded:: 0.9
1180
1181 This corresponds to an IP address.
1182
1183 .. attribute:: value
1184
Paul Kehrereb177932015-05-17 18:33:33 -07001185 :type: :class:`~ipaddress.IPv4Address`,
1186 :class:`~ipaddress.IPv6Address`, :class:`~ipaddress.IPv4Network`,
1187 or :class:`~ipaddress.IPv6Network`.
Paul Kehrer31bdf792015-03-25 14:11:00 -05001188
Paul Kehrer47c32ba2015-10-28 09:12:07 +09001189.. class:: RegisteredID(value)
Paul Kehrer31bdf792015-03-25 14:11:00 -05001190
1191 .. versionadded:: 0.9
1192
1193 This corresponds to a registered ID.
1194
1195 .. attribute:: value
1196
1197 :type: :class:`ObjectIdentifier`
1198
Paul Kehrer47c32ba2015-10-28 09:12:07 +09001199.. class:: OtherName(type_id, value)
Joshua Tauberer2ee5e3c2015-07-04 20:09:46 +00001200
1201 .. versionadded:: 1.0
1202
Joshua Tauberer18b6fc82015-07-05 21:44:51 +00001203 This corresponds to an ``otherName.`` An ``otherName`` has a type identifier and a value represented in binary DER format.
Joshua Tauberer2ee5e3c2015-07-04 20:09:46 +00001204
1205 .. attribute:: type_id
1206
1207 :type: :class:`ObjectIdentifier`
1208
1209 .. attribute:: value
1210
1211 :type: `bytes`
1212
Paul Kehrer8cf26422015-03-21 09:50:24 -05001213X.509 Extensions
1214~~~~~~~~~~~~~~~~
1215
Paul Kehrerfbb7ac82015-03-16 19:26:29 -05001216.. class:: Extensions
1217
1218 .. versionadded:: 0.9
1219
1220 An X.509 Extensions instance is an ordered list of extensions. The object
1221 is iterable to get every extension.
1222
Paul Kehrerfa56a232015-03-17 13:14:03 -05001223 .. method:: get_extension_for_oid(oid)
1224
1225 :param oid: An :class:`ObjectIdentifier` instance.
1226
1227 :returns: An instance of the extension class.
1228
1229 :raises cryptography.x509.ExtensionNotFound: If the certificate does
1230 not have the extension requested.
1231
Paul Kehrerfa56a232015-03-17 13:14:03 -05001232 .. doctest::
1233
Paul Kehrere27f6582015-08-10 18:33:38 -05001234 >>> from cryptography.x509.oid import ExtensionOID
1235 >>> cert.extensions.get_extension_for_oid(ExtensionOID.BASIC_CONSTRAINTS)
Paul Kehrerfa56a232015-03-17 13:14:03 -05001236 <Extension(oid=<ObjectIdentifier(oid=2.5.29.19, name=basicConstraints)>, critical=True, value=<BasicConstraints(ca=True, path_length=None)>)>
1237
Phoebe Queen019b7f82015-08-12 03:52:03 +01001238 .. method:: get_extension_for_class(extclass)
1239
Phoebe Queen6a603eb2015-08-12 14:14:49 +01001240 .. versionadded:: 1.1
1241
Phoebe Queen019b7f82015-08-12 03:52:03 +01001242 :param extclass: An extension class.
1243
1244 :returns: An instance of the extension class.
1245
1246 :raises cryptography.x509.ExtensionNotFound: If the certificate does
1247 not have the extension requested.
1248
1249 .. doctest::
1250
1251 >>> from cryptography import x509
1252 >>> cert.extensions.get_extension_for_class(x509.BasicConstraints)
1253 <Extension(oid=<ObjectIdentifier(oid=2.5.29.19, name=basicConstraints)>, critical=True, value=<BasicConstraints(ca=True, path_length=None)>)>
1254
Paul Kehrer8cf26422015-03-21 09:50:24 -05001255.. class:: Extension
1256
1257 .. versionadded:: 0.9
1258
Paul Kehrer85894662015-03-22 13:19:31 -05001259 .. attribute:: oid
1260
1261 :type: :class:`ObjectIdentifier`
1262
Paul Kehrere27f6582015-08-10 18:33:38 -05001263 One of the :class:`~cryptography.x509.oid.ExtensionOID` OIDs.
Paul Kehrer8cf26422015-03-21 09:50:24 -05001264
1265 .. attribute:: critical
1266
1267 :type: bool
1268
Paul Kehrer58b75692015-03-22 23:24:58 -05001269 Determines whether a given extension is critical or not. :rfc:`5280`
1270 requires that "A certificate-using system MUST reject the certificate
1271 if it encounters a critical extension it does not recognize or a
1272 critical extension that contains information that it cannot process".
Paul Kehrer8cf26422015-03-21 09:50:24 -05001273
Paul Kehrer85894662015-03-22 13:19:31 -05001274 .. attribute:: value
1275
1276 Returns an instance of the extension type corresponding to the OID.
1277
Paul Kehrer14f0bd02015-08-06 11:55:18 +01001278.. class:: ExtensionType
1279
1280 .. versionadded:: 1.0
1281
1282 This is the interface against which all the following extension types are
1283 registered.
1284
Paul Kehrer47c32ba2015-10-28 09:12:07 +09001285.. class:: KeyUsage(digital_signature, content_commitment, key_encipherment, data_encipherment, key_agreement, key_cert_sign, crl_sign, encipher_only, decipher_only)
Paul Kehrercecbbba2015-03-30 14:58:38 -05001286
1287 .. versionadded:: 0.9
1288
1289 The key usage extension defines the purpose of the key contained in the
1290 certificate. The usage restriction might be employed when a key that could
Paul Kehrerb33de932015-08-06 23:41:05 +01001291 be used for more than one operation is to be restricted.
Paul Kehrercecbbba2015-03-30 14:58:38 -05001292
Paul Kehrer822f3d32015-08-06 11:47:32 +01001293 .. attribute:: oid
1294
1295 .. versionadded:: 1.0
1296
1297 :type: :class:`ObjectIdentifier`
1298
Paul Kehrere27f6582015-08-10 18:33:38 -05001299 Returns :attr:`~cryptography.x509.oid.ExtensionOID.KEY_USAGE`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001300
Paul Kehrercecbbba2015-03-30 14:58:38 -05001301 .. attribute:: digital_signature
1302
1303 :type: bool
1304
Paul Kehrer738407b2015-04-01 22:39:02 -05001305 This purpose is set to true when the subject public key is used for verifying
Paul Kehrercecbbba2015-03-30 14:58:38 -05001306 digital signatures, other than signatures on certificates
1307 (``key_cert_sign``) and CRLs (``crl_sign``).
1308
1309 .. attribute:: content_commitment
1310
1311 :type: bool
1312
Paul Kehrer738407b2015-04-01 22:39:02 -05001313 This purpose is set to true when the subject public key is used for verifying
Paul Kehrercecbbba2015-03-30 14:58:38 -05001314 digital signatures, other than signatures on certificates
1315 (``key_cert_sign``) and CRLs (``crl_sign``). It is used to provide a
1316 non-repudiation service that protects against the signing entity
1317 falsely denying some action. In the case of later conflict, a
1318 reliable third party may determine the authenticity of the signed
1319 data. This was called ``non_repudiation`` in older revisions of the
1320 X.509 specification.
1321
1322 .. attribute:: key_encipherment
1323
1324 :type: bool
1325
Paul Kehrer738407b2015-04-01 22:39:02 -05001326 This purpose is set to true when the subject public key is used for
1327 enciphering private or secret keys.
Paul Kehrercecbbba2015-03-30 14:58:38 -05001328
1329 .. attribute:: data_encipherment
1330
1331 :type: bool
1332
Paul Kehrer738407b2015-04-01 22:39:02 -05001333 This purpose is set to true when the subject public key is used for
1334 directly enciphering raw user data without the use of an intermediate
1335 symmetric cipher.
Paul Kehrercecbbba2015-03-30 14:58:38 -05001336
1337 .. attribute:: key_agreement
1338
1339 :type: bool
1340
Paul Kehrer738407b2015-04-01 22:39:02 -05001341 This purpose is set to true when the subject public key is used for key
1342 agreement. For example, when a Diffie-Hellman key is to be used for
1343 key management, then this purpose is set to true.
Paul Kehrercecbbba2015-03-30 14:58:38 -05001344
1345 .. attribute:: key_cert_sign
1346
1347 :type: bool
1348
Paul Kehrer738407b2015-04-01 22:39:02 -05001349 This purpose is set to true when the subject public key is used for
1350 verifying signatures on public key certificates. If this purpose is set
1351 to true then ``ca`` must be true in the :class:`BasicConstraints`
1352 extension.
Paul Kehrercecbbba2015-03-30 14:58:38 -05001353
1354 .. attribute:: crl_sign
1355
1356 :type: bool
1357
Paul Kehrer738407b2015-04-01 22:39:02 -05001358 This purpose is set to true when the subject public key is used for
1359 verifying signatures on certificate revocation lists.
Paul Kehrercecbbba2015-03-30 14:58:38 -05001360
1361 .. attribute:: encipher_only
1362
1363 :type: bool
1364
Paul Kehrer738407b2015-04-01 22:39:02 -05001365 When this purposes is set to true and the ``key_agreement`` purpose is
1366 also set, the subject public key may be used only for enciphering data
1367 while performing key agreement.
Paul Kehrercecbbba2015-03-30 14:58:38 -05001368
1369 :raises ValueError: This is raised if accessed when ``key_agreement``
1370 is false.
1371
1372 .. attribute:: decipher_only
1373
1374 :type: bool
1375
Paul Kehrer738407b2015-04-01 22:39:02 -05001376 When this purposes is set to true and the ``key_agreement`` purpose is
1377 also set, the subject public key may be used only for deciphering data
1378 while performing key agreement.
Paul Kehrercecbbba2015-03-30 14:58:38 -05001379
1380 :raises ValueError: This is raised if accessed when ``key_agreement``
1381 is false.
1382
1383
Paul Kehrer47c32ba2015-10-28 09:12:07 +09001384.. class:: BasicConstraints(ca, path_length)
Paul Kehrer8cf26422015-03-21 09:50:24 -05001385
1386 .. versionadded:: 0.9
1387
Paul Kehrer85894662015-03-22 13:19:31 -05001388 Basic constraints is an X.509 extension type that defines whether a given
Paul Kehrer8cf26422015-03-21 09:50:24 -05001389 certificate is allowed to sign additional certificates and what path
Paul Kehrerb33de932015-08-06 23:41:05 +01001390 length restrictions may exist.
Paul Kehrer8cf26422015-03-21 09:50:24 -05001391
Paul Kehrer822f3d32015-08-06 11:47:32 +01001392 .. attribute:: oid
1393
1394 .. versionadded:: 1.0
1395
1396 :type: :class:`ObjectIdentifier`
1397
Paul Kehrere27f6582015-08-10 18:33:38 -05001398 Returns :attr:`~cryptography.x509.oid.ExtensionOID.BASIC_CONSTRAINTS`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001399
Paul Kehrer8cf26422015-03-21 09:50:24 -05001400 .. attribute:: ca
1401
1402 :type: bool
1403
1404 Whether the certificate can sign certificates.
1405
1406 .. attribute:: path_length
1407
Paul Kehrerfd1444c2015-03-21 19:47:05 -05001408 :type: int or None
Paul Kehrer8cf26422015-03-21 09:50:24 -05001409
1410 The maximum path length for certificates subordinate to this
1411 certificate. This attribute only has meaning if ``ca`` is true.
1412 If ``ca`` is true then a path length of None means there's no
1413 restriction on the number of subordinate CAs in the certificate chain.
Alex Gaynor99c5f152015-05-03 10:01:04 -04001414 If it is zero or greater then it defines the maximum length for a
1415 subordinate CA's certificate chain. For example, a ``path_length`` of 1
1416 means the certificate can sign a subordinate CA, but the subordinate CA
1417 is not allowed to create subordinates with ``ca`` set to true.
Paul Kehrer8cf26422015-03-21 09:50:24 -05001418
Paul Kehrer47c32ba2015-10-28 09:12:07 +09001419.. class:: ExtendedKeyUsage(usages)
Paul Kehrerffa2a152015-03-31 08:18:25 -05001420
1421 .. versionadded:: 0.9
1422
1423 This extension indicates one or more purposes for which the certified
1424 public key may be used, in addition to or in place of the basic
1425 purposes indicated in the key usage extension. The object is
Paul Kehrere27f6582015-08-10 18:33:38 -05001426 iterable to obtain the list of
1427 :class:`~cryptography.x509.oid.ExtendedKeyUsageOID` OIDs present.
Paul Kehrerffa2a152015-03-31 08:18:25 -05001428
Paul Kehrer1cb9e552015-10-28 09:37:29 +09001429 :param list usages: A list of
Paul Kehrer47c32ba2015-10-28 09:12:07 +09001430 :class:`~cryptography.x509.oid.ExtendedKeyUsageOID` OIDs.
1431
Paul Kehrer822f3d32015-08-06 11:47:32 +01001432 .. attribute:: oid
1433
1434 .. versionadded:: 1.0
1435
1436 :type: :class:`ObjectIdentifier`
1437
Paul Kehrere27f6582015-08-10 18:33:38 -05001438 Returns :attr:`~cryptography.x509.oid.ExtensionOID.EXTENDED_KEY_USAGE`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001439
1440
Paul Kehrer47c32ba2015-10-28 09:12:07 +09001441.. class:: OCSPNoCheck()
Paul Kehrer4a1038e2015-05-18 10:28:31 -07001442
Paul Kehrer506a2152015-05-26 08:01:18 -05001443 .. versionadded:: 1.0
Paul Kehrer4a1038e2015-05-18 10:28:31 -07001444
1445 This presence of this extension indicates that an OCSP client can trust a
1446 responder for the lifetime of the responder's certificate. CAs issuing
1447 such a certificate should realize that a compromise of the responder's key
1448 is as serious as the compromise of a CA key used to sign CRLs, at least for
1449 the validity period of this certificate. CA's may choose to issue this type
1450 of certificate with a very short lifetime and renew it frequently. This
1451 extension is only relevant when the certificate is an authorized OCSP
1452 responder.
1453
Paul Kehrer822f3d32015-08-06 11:47:32 +01001454 .. attribute:: oid
1455
1456 .. versionadded:: 1.0
1457
1458 :type: :class:`ObjectIdentifier`
1459
Paul Kehrere27f6582015-08-10 18:33:38 -05001460 Returns :attr:`~cryptography.x509.oid.ExtensionOID.OCSP_NO_CHECK`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001461
Paul Kehrer47c32ba2015-10-28 09:12:07 +09001462.. class:: NameConstraints(permitted_subtrees, excluded_subtrees)
Paul Kehrere0017be2015-05-17 20:39:40 -06001463
1464 .. versionadded:: 1.0
1465
1466 The name constraints extension, which only has meaning in a CA certificate,
1467 defines a name space within which all subject names in certificates issued
1468 beneath the CA certificate must (or must not) be in. For specific details
1469 on the way this extension should be processed see :rfc:`5280`.
1470
Paul Kehrer822f3d32015-08-06 11:47:32 +01001471 .. attribute:: oid
1472
1473 .. versionadded:: 1.0
1474
1475 :type: :class:`ObjectIdentifier`
1476
Paul Kehrere27f6582015-08-10 18:33:38 -05001477 Returns :attr:`~cryptography.x509.oid.ExtensionOID.NAME_CONSTRAINTS`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001478
Paul Kehrere0017be2015-05-17 20:39:40 -06001479 .. attribute:: permitted_subtrees
1480
1481 :type: list of :class:`GeneralName` objects or None
1482
1483 The set of permitted name patterns. If a name matches this and an
1484 element in ``excluded_subtrees`` it is invalid. At least one of
1485 ``permitted_subtrees`` and ``excluded_subtrees`` will be non-None.
1486
1487 .. attribute:: excluded_subtrees
1488
1489 :type: list of :class:`GeneralName` objects or None
1490
1491 Any name matching a restriction in the ``excluded_subtrees`` field is
1492 invalid regardless of information appearing in the
1493 ``permitted_subtrees``. At least one of ``permitted_subtrees`` and
1494 ``excluded_subtrees`` will be non-None.
1495
Paul Kehrer47c32ba2015-10-28 09:12:07 +09001496.. class:: AuthorityKeyIdentifier(key_identifier, authority_cert_issuer, authority_cert_serial_number)
Paul Kehrer2eb4ed92015-04-11 15:33:45 -04001497
1498 .. versionadded:: 0.9
1499
1500 The authority key identifier extension provides a means of identifying the
1501 public key corresponding to the private key used to sign a certificate.
Paul Kehrer8c8cd722015-04-19 09:15:04 -05001502 This extension is typically used to assist in determining the appropriate
1503 certificate chain. For more information about generation and use of this
1504 extension see `RFC 5280 section 4.2.1.1`_.
Paul Kehrer2eb4ed92015-04-11 15:33:45 -04001505
Paul Kehrer822f3d32015-08-06 11:47:32 +01001506 .. attribute:: oid
1507
1508 .. versionadded:: 1.0
1509
1510 :type: :class:`ObjectIdentifier`
1511
Paul Kehrere27f6582015-08-10 18:33:38 -05001512 Returns
1513 :attr:`~cryptography.x509.oid.ExtensionOID.AUTHORITY_KEY_IDENTIFIER`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001514
Paul Kehrer2eb4ed92015-04-11 15:33:45 -04001515 .. attribute:: key_identifier
1516
1517 :type: bytes
1518
Paul Kehrer9104b1d2015-04-18 09:23:44 -05001519 A value derived from the public key used to verify the certificate's
Paul Kehrer8c8cd722015-04-19 09:15:04 -05001520 signature.
Paul Kehrer9104b1d2015-04-18 09:23:44 -05001521
Paul Kehrer2eb4ed92015-04-11 15:33:45 -04001522 .. attribute:: authority_cert_issuer
1523
1524 :type: :class:`Name` or None
1525
Paul Kehrer9104b1d2015-04-18 09:23:44 -05001526 The :class:`Name` of the issuer's issuer.
1527
Paul Kehrer2eb4ed92015-04-11 15:33:45 -04001528 .. attribute:: authority_cert_serial_number
1529
1530 :type: int or None
1531
Paul Kehrer9104b1d2015-04-18 09:23:44 -05001532 The serial number of the issuer's issuer.
1533
Paul Kehrer253929a2015-08-05 17:30:39 +01001534 .. classmethod:: from_issuer_public_key(public_key)
1535
1536 .. versionadded:: 1.0
1537
1538 Creates a new AuthorityKeyIdentifier instance using the public key
1539 provided to generate the appropriate digest. This should be the
Paul Kehrer26ac47f2015-08-08 15:20:52 -05001540 **issuer's public key**. The resulting object will contain
1541 :attr:`~cryptography.x509.AuthorityKeyIdentifier.key_identifier`, but
1542 :attr:`~cryptography.x509.AuthorityKeyIdentifier.authority_cert_issuer`
1543 and
1544 :attr:`~cryptography.x509.AuthorityKeyIdentifier.authority_cert_serial_number`
1545 will be None.
1546 The generated ``key_identifier`` is the SHA1 hash of the ``subjectPublicKey``
1547 ASN.1 bit string. This is the first recommendation in :rfc:`5280`
Paul Kehrer253929a2015-08-05 17:30:39 +01001548 section 4.2.1.2.
1549
Paul Kehrercc671822015-08-08 15:41:54 -05001550 :param public_key: One of
1551 :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey`
1552 ,
1553 :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPublicKey`
1554 , or
1555 :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey`.
Paul Kehrer253929a2015-08-05 17:30:39 +01001556
1557 .. doctest::
1558
1559 >>> from cryptography import x509
1560 >>> from cryptography.hazmat.backends import default_backend
Paul Kehrercc671822015-08-08 15:41:54 -05001561 >>> issuer_cert = x509.load_pem_x509_certificate(pem_data, default_backend())
1562 >>> x509.AuthorityKeyIdentifier.from_issuer_public_key(issuer_cert.public_key())
Paul Kehrer253929a2015-08-05 17:30:39 +01001563 <AuthorityKeyIdentifier(key_identifier='X\x01\x84$\x1b\xbc+R\x94J=\xa5\x10r\x14Q\xf5\xaf:\xc9', authority_cert_issuer=None, authority_cert_serial_number=None)>
1564
Paul Kehrer47c32ba2015-10-28 09:12:07 +09001565.. class:: SubjectKeyIdentifier(digest)
Paul Kehrer1eb82a62015-03-31 20:00:33 -05001566
1567 .. versionadded:: 0.9
1568
1569 The subject key identifier extension provides a means of identifying
1570 certificates that contain a particular public key.
1571
Paul Kehrer822f3d32015-08-06 11:47:32 +01001572 .. attribute:: oid
1573
1574 .. versionadded:: 1.0
1575
1576 :type: :class:`ObjectIdentifier`
1577
Paul Kehrere27f6582015-08-10 18:33:38 -05001578 Returns
1579 :attr:`~cryptography.x509.oid.ExtensionOID.SUBJECT_KEY_IDENTIFIER`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001580
Paul Kehrer1eb82a62015-03-31 20:00:33 -05001581 .. attribute:: digest
1582
1583 :type: bytes
1584
1585 The binary value of the identifier.
1586
Paul Kehrerd4a7f062015-08-05 18:32:18 +01001587 .. classmethod:: from_public_key(public_key)
Paul Kehrerf22f6122015-08-05 12:57:13 +01001588
1589 .. versionadded:: 1.0
1590
1591 Creates a new SubjectKeyIdentifier instance using the public key
1592 provided to generate the appropriate digest. This should be the public
Paul Kehrereb9ec002015-08-08 10:03:02 -05001593 key that is in the certificate. The generated digest is the SHA1 hash
1594 of the ``subjectPublicKey`` ASN.1 bit string. This is the first
1595 recommendation in :rfc:`5280` section 4.2.1.2.
Paul Kehrerf22f6122015-08-05 12:57:13 +01001596
1597 :param public_key: One of
1598 :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey`
1599 ,
1600 :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPublicKey`
1601 , or
1602 :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey`.
1603
Paul Kehrer253929a2015-08-05 17:30:39 +01001604 .. doctest::
1605
1606 >>> from cryptography import x509
1607 >>> from cryptography.hazmat.backends import default_backend
Paul Kehrercc671822015-08-08 15:41:54 -05001608 >>> csr = x509.load_pem_x509_csr(pem_req_data, default_backend())
1609 >>> x509.SubjectKeyIdentifier.from_public_key(csr.public_key())
1610 <SubjectKeyIdentifier(digest='\xdb\xaa\xf0\x06\x11\xdbD\xfe\xbf\x93\x03\x8av\x88WP7\xa6\x91\xf7')>
Paul Kehrer253929a2015-08-05 17:30:39 +01001611
Paul Kehrer47c32ba2015-10-28 09:12:07 +09001612.. class:: SubjectAlternativeName(general_names)
Paul Kehrer31bdf792015-03-25 14:11:00 -05001613
1614 .. versionadded:: 0.9
1615
1616 Subject alternative name is an X.509 extension that provides a list of
1617 :ref:`general name <general_name_classes>` instances that provide a set
1618 of identities for which the certificate is valid. The object is iterable to
1619 get every element.
1620
Paul Kehrer1cb9e552015-10-28 09:37:29 +09001621 :param list general_names: A list of :class:`GeneralName` instances.
Paul Kehrer47c32ba2015-10-28 09:12:07 +09001622
Paul Kehrer822f3d32015-08-06 11:47:32 +01001623 .. attribute:: oid
1624
1625 .. versionadded:: 1.0
1626
1627 :type: :class:`ObjectIdentifier`
1628
Paul Kehrere27f6582015-08-10 18:33:38 -05001629 Returns
1630 :attr:`~cryptography.x509.oid.ExtensionOID.SUBJECT_ALTERNATIVE_NAME`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001631
Paul Kehrer31bdf792015-03-25 14:11:00 -05001632 .. method:: get_values_for_type(type)
1633
1634 :param type: A :class:`GeneralName` provider. This is one of the
1635 :ref:`general name classes <general_name_classes>`.
1636
1637 :returns: A list of values extracted from the matched general names.
Joshua Taubererd2afad32015-07-06 22:37:53 +00001638 The type of the returned values depends on the :class:`GeneralName`.
Paul Kehrer31bdf792015-03-25 14:11:00 -05001639
Paul Kehrer93ae8052015-05-02 23:18:09 -05001640 .. doctest::
1641
1642 >>> from cryptography import x509
1643 >>> from cryptography.hazmat.backends import default_backend
1644 >>> from cryptography.hazmat.primitives import hashes
1645 >>> cert = x509.load_pem_x509_certificate(cryptography_cert_pem, default_backend())
Paul Kehrerd0cd5072015-05-02 23:27:00 -05001646 >>> # Get the subjectAltName extension from the certificate
Paul Kehrere27f6582015-08-10 18:33:38 -05001647 >>> ext = cert.extensions.get_extension_for_oid(ExtensionOID.SUBJECT_ALTERNATIVE_NAME)
Paul Kehrerd0cd5072015-05-02 23:27:00 -05001648 >>> # Get the dNSName entries from the SAN extension
1649 >>> ext.value.get_values_for_type(x509.DNSName)
Paul Kehrer93ae8052015-05-02 23:18:09 -05001650 [u'www.cryptography.io', u'cryptography.io']
1651
Paul Kehrer8cf26422015-03-21 09:50:24 -05001652
Paul Kehrer47c32ba2015-10-28 09:12:07 +09001653.. class:: IssuerAlternativeName(general_names)
Paul Kehrer99125c92015-06-07 18:37:10 -05001654
1655 .. versionadded:: 1.0
1656
1657 Issuer alternative name is an X.509 extension that provides a list of
1658 :ref:`general name <general_name_classes>` instances that provide a set
1659 of identities for the certificate issuer. The object is iterable to
1660 get every element.
1661
Paul Kehrer1cb9e552015-10-28 09:37:29 +09001662 :param list general_names: A list of :class:`GeneralName` instances.
Paul Kehrer47c32ba2015-10-28 09:12:07 +09001663
Paul Kehrer822f3d32015-08-06 11:47:32 +01001664 .. attribute:: oid
1665
1666 .. versionadded:: 1.0
1667
1668 :type: :class:`ObjectIdentifier`
1669
Paul Kehrere27f6582015-08-10 18:33:38 -05001670 Returns
1671 :attr:`~cryptography.x509.oid.ExtensionOID.ISSUER_ALTERNATIVE_NAME`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001672
Paul Kehrer99125c92015-06-07 18:37:10 -05001673 .. method:: get_values_for_type(type)
1674
1675 :param type: A :class:`GeneralName` provider. This is one of the
1676 :ref:`general name classes <general_name_classes>`.
1677
1678 :returns: A list of values extracted from the matched general names.
1679
1680
Paul Kehrer47c32ba2015-10-28 09:12:07 +09001681.. class:: AuthorityInformationAccess(descriptions)
Paul Kehrer3e6d5582015-05-02 21:57:56 -05001682
1683 .. versionadded:: 0.9
1684
1685 The authority information access extension indicates how to access
1686 information and services for the issuer of the certificate in which
1687 the extension appears. Information and services may include online
1688 validation services (such as OCSP) and issuer data. It is an iterable,
Paul Kehrere27f6582015-08-10 18:33:38 -05001689 containing one or more :class:`~cryptography.x509.AccessDescription`
1690 instances.
Paul Kehrer3e6d5582015-05-02 21:57:56 -05001691
Paul Kehrer1cb9e552015-10-28 09:37:29 +09001692 :param list descriptions: A list of :class:`AccessDescription` objects.
Paul Kehrer47c32ba2015-10-28 09:12:07 +09001693
Paul Kehrer822f3d32015-08-06 11:47:32 +01001694 .. attribute:: oid
1695
1696 .. versionadded:: 1.0
1697
1698 :type: :class:`ObjectIdentifier`
1699
Paul Kehrere27f6582015-08-10 18:33:38 -05001700 Returns
1701 :attr:`~cryptography.x509.oid.ExtensionOID.AUTHORITY_INFORMATION_ACCESS`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001702
Paul Kehrer3e6d5582015-05-02 21:57:56 -05001703
Paul Kehrer47c32ba2015-10-28 09:12:07 +09001704.. class:: AccessDescription(access_method, access_location)
Paul Kehrer3e6d5582015-05-02 21:57:56 -05001705
Paul Kehrer5a485522015-05-06 00:29:12 -05001706 .. versionadded:: 0.9
1707
Paul Kehrer3e6d5582015-05-02 21:57:56 -05001708 .. attribute:: access_method
1709
1710 :type: :class:`ObjectIdentifier`
1711
Paul Kehrerf506bca2015-05-02 22:31:47 -05001712 The access method defines what the ``access_location`` means. It must
Paul Kehrere27f6582015-08-10 18:33:38 -05001713 be either
1714 :attr:`~cryptography.x509.oid.AuthorityInformationAccessOID.OCSP` or
1715 :attr:`~cryptography.x509.oid.AuthorityInformationAccessOID.CA_ISSUERS`.
1716 If it is
1717 :attr:`~cryptography.x509.oid.AuthorityInformationAccessOID.OCSP`
1718 the access location will be where to obtain OCSP
1719 information for the certificate. If it is
1720 :attr:`~cryptography.x509.oid.AuthorityInformationAccessOID.CA_ISSUERS`
1721 the access location will provide additional information about the
1722 issuing certificate.
Paul Kehrer3e6d5582015-05-02 21:57:56 -05001723
1724 .. attribute:: access_location
1725
1726 :type: :class:`GeneralName`
1727
Paul Kehrerf506bca2015-05-02 22:31:47 -05001728 Where to access the information defined by the access method.
1729
Paul Kehrer47c32ba2015-10-28 09:12:07 +09001730.. class:: CRLDistributionPoints(distribution_points)
Paul Kehrer5a485522015-05-06 00:29:12 -05001731
1732 .. versionadded:: 0.9
1733
1734 The CRL distribution points extension identifies how CRL information is
1735 obtained. It is an iterable, containing one or more
1736 :class:`DistributionPoint` instances.
1737
Paul Kehrer1cb9e552015-10-28 09:37:29 +09001738 :param list distribution_points: A list of :class:`DistributionPoint`
1739 instances.
Paul Kehrer47c32ba2015-10-28 09:12:07 +09001740
Paul Kehrer822f3d32015-08-06 11:47:32 +01001741 .. attribute:: oid
1742
1743 .. versionadded:: 1.0
1744
1745 :type: :class:`ObjectIdentifier`
1746
Paul Kehrere27f6582015-08-10 18:33:38 -05001747 Returns
1748 :attr:`~cryptography.x509.oid.ExtensionOID.CRL_DISTRIBUTION_POINTS`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001749
Paul Kehrer47c32ba2015-10-28 09:12:07 +09001750.. class:: DistributionPoint(full_name, relative_name, reasons, crl_issuer)
Paul Kehrer5a485522015-05-06 00:29:12 -05001751
1752 .. versionadded:: 0.9
1753
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05001754 .. attribute:: full_name
Paul Kehrer5a485522015-05-06 00:29:12 -05001755
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05001756 :type: list of :class:`GeneralName` instances or None
Paul Kehrer5a485522015-05-06 00:29:12 -05001757
Paul Kehrerf2c072b2015-05-09 17:04:28 -05001758 This field describes methods to retrieve the CRL. At most one of
1759 ``full_name`` or ``relative_name`` will be non-None.
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05001760
1761 .. attribute:: relative_name
1762
1763 :type: :class:`Name` or None
1764
1765 This field describes methods to retrieve the CRL relative to the CRL
Paul Kehrerf2c072b2015-05-09 17:04:28 -05001766 issuer. At most one of ``full_name`` or ``relative_name`` will be
1767 non-None.
Paul Kehrer5a485522015-05-06 00:29:12 -05001768
1769 .. attribute:: crl_issuer
1770
1771 :type: list of :class:`GeneralName` instances or None
1772
1773 Information about the issuer of the CRL.
1774
1775 .. attribute:: reasons
1776
Paul Kehrer3fd02602015-05-09 19:46:13 -05001777 :type: frozenset of :class:`ReasonFlags` or None
Paul Kehrer5a485522015-05-06 00:29:12 -05001778
1779 The reasons a given distribution point may be used for when performing
1780 revocation checks.
1781
1782.. class:: ReasonFlags
1783
1784 .. versionadded:: 0.9
1785
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05001786 An enumeration for CRL reasons.
1787
1788 .. attribute:: unspecified
1789
1790 It is unspecified why the certificate was revoked. This reason cannot
1791 be used as a reason flag in a :class:`DistributionPoint`.
Paul Kehrer5a485522015-05-06 00:29:12 -05001792
1793 .. attribute:: key_compromise
1794
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05001795 This reason indicates that the private key was compromised.
Paul Kehrer5a485522015-05-06 00:29:12 -05001796
1797 .. attribute:: ca_compromise
1798
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05001799 This reason indicates that the CA issuing the certificate was
1800 compromised.
Paul Kehrer5a485522015-05-06 00:29:12 -05001801
1802 .. attribute:: affiliation_changed
1803
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05001804 This reason indicates that the subject's name or other information has
1805 changed.
Paul Kehrer5a485522015-05-06 00:29:12 -05001806
1807 .. attribute:: superseded
1808
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05001809 This reason indicates that a certificate has been superseded.
Paul Kehrer5a485522015-05-06 00:29:12 -05001810
1811 .. attribute:: cessation_of_operation
1812
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05001813 This reason indicates that the certificate is no longer required.
Paul Kehrer5a485522015-05-06 00:29:12 -05001814
1815 .. attribute:: certificate_hold
1816
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05001817 This reason indicates that the certificate is on hold.
Paul Kehrer5a485522015-05-06 00:29:12 -05001818
1819 .. attribute:: privilege_withdrawn
1820
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05001821 This reason indicates that the privilege granted by this certificate
1822 have been withdrawn.
Paul Kehrer5a485522015-05-06 00:29:12 -05001823
1824 .. attribute:: aa_compromise
1825
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05001826 When an attribute authority has been compromised.
1827
1828 .. attribute:: remove_from_crl
1829
1830 This reason indicates that the certificate was on hold and should be
1831 removed from the CRL. This reason cannot be used as a reason flag
1832 in a :class:`DistributionPoint`.
Paul Kehrer5a485522015-05-06 00:29:12 -05001833
Paul Kehrer47c32ba2015-10-28 09:12:07 +09001834.. class:: InhibitAnyPolicy(skip_certs)
Paul Kehrer16fae762015-05-01 23:14:20 -05001835
1836 .. versionadded:: 1.0
1837
1838 The inhibit ``anyPolicy`` extension indicates that the special OID
Paul Kehrere27f6582015-08-10 18:33:38 -05001839 :attr:`~cryptography.x509.oid.CertificatePoliciesOID.ANY_POLICY`, is not
1840 considered an explicit match for other :class:`CertificatePolicies` except
1841 when it appears in an intermediate self-issued CA certificate. The value
1842 indicates the number of additional non-self-issued certificates that may
1843 appear in the path before
1844 :attr:`~cryptography.x509.oid.CertificatePoliciesOID.ANY_POLICY` is no
1845 longer permitted. For example, a value of one indicates that
1846 :attr:`~cryptography.x509.oid.CertificatePoliciesOID.ANY_POLICY` may be
1847 processed in certificates issued by the subject of this certificate, but
1848 not in additional certificates in the path.
Paul Kehrer16fae762015-05-01 23:14:20 -05001849
Paul Kehrer822f3d32015-08-06 11:47:32 +01001850 .. attribute:: oid
1851
1852 .. versionadded:: 1.0
1853
1854 :type: :class:`ObjectIdentifier`
1855
Paul Kehrere27f6582015-08-10 18:33:38 -05001856 Returns
1857 :attr:`~cryptography.x509.oid.ExtensionOID.INHIBIT_ANY_POLICY`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001858
Paul Kehrer16fae762015-05-01 23:14:20 -05001859 .. attribute:: skip_certs
1860
1861 :type: int
1862
Paul Kehrer3b95cd72015-12-22 21:40:20 -06001863.. class:: CRLNumber(crl_number)
1864
1865 .. versionadded:: 1.2
1866
Paul Kehrere32b9942015-12-22 22:26:53 -06001867 The CRL number is a CRL extension that conveys a monotonically increasing
1868 sequence number for a given CRL scope and CRL issuer. This extension allows
1869 users to easily determine when a particular CRL supersedes another CRL.
1870 :rfc:`5280` requires that this extension be present in conforming CRLs.
Paul Kehrer3b95cd72015-12-22 21:40:20 -06001871
1872 .. attribute:: oid
1873
1874 :type: :class:`ObjectIdentifier`
1875
1876 Returns
1877 :attr:`~cryptography.x509.oid.ExtensionOID.CRL_NUMBER`.
1878
1879 .. attribute:: crl_number
1880
1881 :type: int
1882
Paul Kehrer47c32ba2015-10-28 09:12:07 +09001883.. class:: CertificatePolicies(policies)
Paul Kehrer0d210922015-04-28 17:31:07 -05001884
1885 .. versionadded:: 0.9
1886
Paul Kehrer2e879742015-05-02 23:09:56 -05001887 The certificate policies extension is an iterable, containing one or more
1888 :class:`PolicyInformation` instances.
Paul Kehrer0d210922015-04-28 17:31:07 -05001889
Paul Kehrer1cb9e552015-10-28 09:37:29 +09001890 :param list policies: A list of :class:`PolicyInformation` instances.
Paul Kehrer47c32ba2015-10-28 09:12:07 +09001891
Paul Kehrer822f3d32015-08-06 11:47:32 +01001892 .. attribute:: oid
1893
1894 .. versionadded:: 1.0
1895
1896 :type: :class:`ObjectIdentifier`
1897
Paul Kehrere27f6582015-08-10 18:33:38 -05001898 Returns
1899 :attr:`~cryptography.x509.oid.ExtensionOID.CERTIFICATE_POLICIES`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001900
Paul Kehrer0d210922015-04-28 17:31:07 -05001901Certificate Policies Classes
1902~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1903
1904These classes may be present within a :class:`CertificatePolicies` instance.
1905
Paul Kehrer47c32ba2015-10-28 09:12:07 +09001906.. class:: PolicyInformation(policy_identifier, policy_qualifiers)
Paul Kehrer0d210922015-04-28 17:31:07 -05001907
1908 .. versionadded:: 0.9
1909
1910 Contains a policy identifier and an optional list of qualifiers.
1911
1912 .. attribute:: policy_identifier
1913
1914 :type: :class:`ObjectIdentifier`
1915
1916 .. attribute:: policy_qualifiers
1917
1918 :type: list
1919
Paul Kehrerba35b3b2015-05-10 13:07:59 -05001920 A list consisting of :term:`text` and/or :class:`UserNotice` objects.
Paul Kehrer3f8ddeb2015-05-11 00:25:36 -05001921 If the value is text it is a pointer to the practice statement
1922 published by the certificate authority. If it is a user notice it is
1923 meant for display to the relying party when the certificate is
1924 used.
Paul Kehrer2e879742015-05-02 23:09:56 -05001925
Paul Kehrer47c32ba2015-10-28 09:12:07 +09001926.. class:: UserNotice(notice_reference, explicit_text)
Paul Kehrer0d210922015-04-28 17:31:07 -05001927
1928 .. versionadded:: 0.9
1929
Paul Kehrer2e879742015-05-02 23:09:56 -05001930 User notices are intended for display to a relying party when a certificate
1931 is used. In practice, few if any UIs expose this data and it is a rarely
1932 encoded component.
1933
Paul Kehrer0d210922015-04-28 17:31:07 -05001934 .. attribute:: notice_reference
1935
1936 :type: :class:`NoticeReference` or None
1937
Paul Kehrer2e879742015-05-02 23:09:56 -05001938 The notice reference field names an organization and identifies,
1939 by number, a particular statement prepared by that organization.
1940
Paul Kehrer0d210922015-04-28 17:31:07 -05001941 .. attribute:: explicit_text
1942
Paul Kehrer2e879742015-05-02 23:09:56 -05001943 This field includes an arbitrary textual statement directly in the
1944 certificate.
1945
Paul Kehrer0d210922015-04-28 17:31:07 -05001946 :type: :term:`text`
1947
Paul Kehrer47c32ba2015-10-28 09:12:07 +09001948.. class:: NoticeReference(organization, notice_numbers)
Paul Kehrer0d210922015-04-28 17:31:07 -05001949
Paul Kehrer2e879742015-05-02 23:09:56 -05001950 Notice reference can name an organization and provide information about
1951 notices related to the certificate. For example, it might identify the
1952 organization name and notice number 1. Application software could
1953 have a notice file containing the current set of notices for the named
1954 organization; the application would then extract the notice text from the
1955 file and display it. In practice this is rarely seen.
1956
Paul Kehrer0d210922015-04-28 17:31:07 -05001957 .. versionadded:: 0.9
1958
1959 .. attribute:: organization
1960
Paul Kehrer66c61702015-05-12 16:39:18 -05001961 :type: :term:`text`
Paul Kehrer0d210922015-04-28 17:31:07 -05001962
Paul Kehrer3f8ddeb2015-05-11 00:25:36 -05001963 .. attribute:: notice_numbers
Paul Kehrer0d210922015-04-28 17:31:07 -05001964
Paul Kehrer66c61702015-05-12 16:39:18 -05001965 :type: list
Paul Kehrer0d210922015-04-28 17:31:07 -05001966
Paul Kehrer66c61702015-05-12 16:39:18 -05001967 A list of integers.
Paul Kehrer0d210922015-04-28 17:31:07 -05001968
Paul Kehrere5f152b2015-12-25 23:55:47 -06001969.. _crl_entry_extensions:
1970
Paul Kehrer49bb7562015-12-25 16:17:40 -06001971CRL Entry Extensions
1972~~~~~~~~~~~~~~~~~~~~
1973
1974These extensions are only valid within a :class:`RevokedCertificate` object.
1975
1976.. class:: CertificateIssuer(general_names)
1977
1978 .. versionadded:: 1.2
1979
1980 The certificate issuer is an extension that is only valid inside
1981 :class:`~cryptography.x509.RevokedCertificate` objects. If the
1982 ``indirectCRL`` property of the parent CRL's IssuingDistributionPoint
1983 extension is set, then this extension identifies the certificate issuer
1984 associated with the revoked certificate. The object is iterable to get
1985 every element.
1986
1987 :param list general_names: A list of :class:`GeneralName` instances.
1988
1989 .. attribute:: oid
1990
1991 :type: :class:`ObjectIdentifier`
1992
1993 Returns
1994 :attr:`~cryptography.x509.oid.CRLEntryExtensionOID.CERTIFICATE_ISSUER`.
1995
1996 .. method:: get_values_for_type(type)
1997
1998 :param type: A :class:`GeneralName` instance. This is one of the
1999 :ref:`general name classes <general_name_classes>`.
2000
2001 :returns: A list of values extracted from the matched general names.
2002 The type of the returned values depends on the :class:`GeneralName`.
2003
Paul Kehrer7058ece2015-12-25 22:28:29 -06002004.. class:: CRLReason(reason)
2005
2006 .. versionadded:: 1.2
2007
2008 CRL reason (also known as ``reasonCode``) is an extension that is only
2009 valid inside :class:`~cryptography.x509.RevokedCertificate` objects. It
2010 identifies a reason for the certificate revocation.
2011
2012 :param reason: A value from the
2013 :class:`~cryptography.x509.oid.CRLEntryExtensionOID` enum.
2014
2015 .. attribute:: oid
2016
2017 :type: :class:`ObjectIdentifier`
2018
2019 Returns
2020 :attr:`~cryptography.x509.oid.CRLEntryExtensionOID.CRL_REASON`.
2021
2022 .. attribute:: reason
2023
2024 :type: An element from :class:`~cryptography.x509.ReasonFlags`
2025
Paul Kehrer23c0bbc2015-12-25 22:35:19 -06002026.. class:: InvalidityDate(invalidity_date)
2027
2028 .. versionadded:: 1.2
2029
2030 Invalidity date is an extension that is only valid inside
2031 :class:`~cryptography.x509.RevokedCertificate` objects. It provides
2032 the date on which it is known or suspected that the private key was
2033 compromised or that the certificate otherwise became invalid.
2034 This date may be earlier than the revocation date in the CRL entry,
2035 which is the date at which the CA processed the revocation.
2036
2037 :param invalidity_date: The :class:`datetime.datetime` when it is known
2038 or suspected that the private key was compromised.
2039
2040 .. attribute:: oid
2041
2042 :type: :class:`ObjectIdentifier`
2043
2044 Returns
2045 :attr:`~cryptography.x509.oid.CRLEntryExtensionOID.INVALIDITY_DATE`.
2046
2047 .. attribute:: invalidity_date
2048
2049 :type: :class:`datetime.datetime`
2050
Paul Kehrer49bb7562015-12-25 16:17:40 -06002051
Paul Kehrer912d3fb2015-01-29 11:19:22 -06002052Object Identifiers
2053~~~~~~~~~~~~~~~~~~
2054
Paul Kehrer4bb46492015-02-07 16:59:14 -06002055X.509 elements are frequently identified by :class:`ObjectIdentifier`
2056instances. The following common OIDs are available as constants.
Paul Kehrer912d3fb2015-01-29 11:19:22 -06002057
Paul Kehrere27f6582015-08-10 18:33:38 -05002058.. currentmodule:: cryptography.x509.oid
Paul Kehrer56da2a52015-02-11 23:35:07 -06002059
Paul Kehrere27f6582015-08-10 18:33:38 -05002060.. class:: NameOID
Paul Kehrer912d3fb2015-01-29 11:19:22 -06002061
Paul Kehrere27f6582015-08-10 18:33:38 -05002062 These OIDs are typically seen in X.509 names.
Paul Kehrer858b9b72015-02-05 09:50:31 -06002063
Paul Kehrere27f6582015-08-10 18:33:38 -05002064 .. versionadded:: 1.0
Paul Kehrer912d3fb2015-01-29 11:19:22 -06002065
Paul Kehrere27f6582015-08-10 18:33:38 -05002066 .. attribute:: COMMON_NAME
Paul Kehrer858b9b72015-02-05 09:50:31 -06002067
Paul Kehrere27f6582015-08-10 18:33:38 -05002068 Corresponds to the dotted string ``"2.5.4.3"``. Historically the domain
2069 name would be encoded here for server certificates. :rfc:`2818`
2070 deprecates this practice and names of that type should now be located
2071 in a :class:`~cryptography.x509.SubjectAlternativeName` extension.
Paul Kehrer912d3fb2015-01-29 11:19:22 -06002072
Paul Kehrere27f6582015-08-10 18:33:38 -05002073 .. attribute:: COUNTRY_NAME
Paul Kehrer858b9b72015-02-05 09:50:31 -06002074
Paul Kehrere27f6582015-08-10 18:33:38 -05002075 Corresponds to the dotted string ``"2.5.4.6"``.
Paul Kehrer912d3fb2015-01-29 11:19:22 -06002076
Paul Kehrere27f6582015-08-10 18:33:38 -05002077 .. attribute:: LOCALITY_NAME
Paul Kehrer858b9b72015-02-05 09:50:31 -06002078
Paul Kehrere27f6582015-08-10 18:33:38 -05002079 Corresponds to the dotted string ``"2.5.4.7"``.
Paul Kehrer912d3fb2015-01-29 11:19:22 -06002080
Paul Kehrere27f6582015-08-10 18:33:38 -05002081 .. attribute:: STATE_OR_PROVINCE_NAME
Paul Kehrer858b9b72015-02-05 09:50:31 -06002082
Paul Kehrere27f6582015-08-10 18:33:38 -05002083 Corresponds to the dotted string ``"2.5.4.8"``.
Paul Kehrer912d3fb2015-01-29 11:19:22 -06002084
Paul Kehrere27f6582015-08-10 18:33:38 -05002085 .. attribute:: ORGANIZATION_NAME
Paul Kehrer858b9b72015-02-05 09:50:31 -06002086
Paul Kehrere27f6582015-08-10 18:33:38 -05002087 Corresponds to the dotted string ``"2.5.4.10"``.
Paul Kehrer912d3fb2015-01-29 11:19:22 -06002088
Paul Kehrere27f6582015-08-10 18:33:38 -05002089 .. attribute:: ORGANIZATIONAL_UNIT_NAME
Paul Kehrer858b9b72015-02-05 09:50:31 -06002090
Paul Kehrere27f6582015-08-10 18:33:38 -05002091 Corresponds to the dotted string ``"2.5.4.11"``.
Paul Kehrer912d3fb2015-01-29 11:19:22 -06002092
Paul Kehrere27f6582015-08-10 18:33:38 -05002093 .. attribute:: SERIAL_NUMBER
Paul Kehrer858b9b72015-02-05 09:50:31 -06002094
Paul Kehrere27f6582015-08-10 18:33:38 -05002095 Corresponds to the dotted string ``"2.5.4.5"``. This is distinct from
2096 the serial number of the certificate itself (which can be obtained with
2097 :func:`~cryptography.x509.Certificate.serial`).
Paul Kehrer912d3fb2015-01-29 11:19:22 -06002098
Paul Kehrere27f6582015-08-10 18:33:38 -05002099 .. attribute:: SURNAME
Paul Kehrer858b9b72015-02-05 09:50:31 -06002100
Paul Kehrere27f6582015-08-10 18:33:38 -05002101 Corresponds to the dotted string ``"2.5.4.4"``.
Paul Kehrer912d3fb2015-01-29 11:19:22 -06002102
Paul Kehrere27f6582015-08-10 18:33:38 -05002103 .. attribute:: GIVEN_NAME
Paul Kehrer858b9b72015-02-05 09:50:31 -06002104
Paul Kehrere27f6582015-08-10 18:33:38 -05002105 Corresponds to the dotted string ``"2.5.4.42"``.
Paul Kehrer912d3fb2015-01-29 11:19:22 -06002106
Paul Kehrere27f6582015-08-10 18:33:38 -05002107 .. attribute:: TITLE
Paul Kehrer858b9b72015-02-05 09:50:31 -06002108
Paul Kehrere27f6582015-08-10 18:33:38 -05002109 Corresponds to the dotted string ``"2.5.4.12"``.
Paul Kehrer912d3fb2015-01-29 11:19:22 -06002110
Paul Kehrere27f6582015-08-10 18:33:38 -05002111 .. attribute:: GENERATION_QUALIFIER
Paul Kehrer858b9b72015-02-05 09:50:31 -06002112
Paul Kehrere27f6582015-08-10 18:33:38 -05002113 Corresponds to the dotted string ``"2.5.4.44"``.
Paul Kehrer912d3fb2015-01-29 11:19:22 -06002114
Paul Kehrere27f6582015-08-10 18:33:38 -05002115 .. attribute:: DN_QUALIFIER
Paul Kehrer858b9b72015-02-05 09:50:31 -06002116
Paul Kehrere27f6582015-08-10 18:33:38 -05002117 Corresponds to the dotted string ``"2.5.4.46"``. This specifies
2118 disambiguating information to add to the relative distinguished name of an
2119 entry. See :rfc:`2256`.
Paul Kehrer912d3fb2015-01-29 11:19:22 -06002120
Paul Kehrere27f6582015-08-10 18:33:38 -05002121 .. attribute:: PSEUDONYM
Paul Kehrer858b9b72015-02-05 09:50:31 -06002122
Paul Kehrere27f6582015-08-10 18:33:38 -05002123 Corresponds to the dotted string ``"2.5.4.65"``.
Paul Kehrer912d3fb2015-01-29 11:19:22 -06002124
Paul Kehrere27f6582015-08-10 18:33:38 -05002125 .. attribute:: DOMAIN_COMPONENT
Paul Kehrer858b9b72015-02-05 09:50:31 -06002126
Paul Kehrere27f6582015-08-10 18:33:38 -05002127 Corresponds to the dotted string ``"0.9.2342.19200300.100.1.25"``. A string
2128 holding one component of a domain name. See :rfc:`4519`.
Paul Kehrer56da2a52015-02-11 23:35:07 -06002129
Paul Kehrere27f6582015-08-10 18:33:38 -05002130 .. attribute:: EMAIL_ADDRESS
Paul Kehrer56da2a52015-02-11 23:35:07 -06002131
Paul Kehrere27f6582015-08-10 18:33:38 -05002132 Corresponds to the dotted string ``"1.2.840.113549.1.9.1"``.
Paul Kehrer56da2a52015-02-11 23:35:07 -06002133
Alex Gaynor1d3f2bf2015-12-19 12:15:09 -05002134 .. attribute:: JURISDICTION_COUNTRY_NAME
2135
2136 Corresponds to the dotted string ``"1.3.6.1.4.1.311.60.2.1.3"``.
2137
Alex Gaynor45e507f2015-12-19 13:44:23 -05002138 .. attribute:: JURISDICTION_LOCALITY_NAME
2139
2140 Corresponds to the dotted string ``"1.3.6.1.4.1.311.60.2.1.1"``.
2141
2142 .. attribute:: JURISDICTION_STATE_OR_PROVINCE_NAME
2143
2144 Corresponds to the dotted string ``"1.3.6.1.4.1.311.60.2.1.2"``.
2145
Alex Gaynora2293c82015-12-19 20:49:15 -05002146 .. attribute:: BUSINESS_CATEGORY
2147
2148 Corresponds to the dotted string ``"2.5.4.15"``.
2149
Paul Kehrer56da2a52015-02-11 23:35:07 -06002150
Paul Kehrere27f6582015-08-10 18:33:38 -05002151.. class:: SignatureAlgorithmOID
Paul Kehrer56da2a52015-02-11 23:35:07 -06002152
Paul Kehrere27f6582015-08-10 18:33:38 -05002153 .. versionadded:: 1.0
Paul Kehrer56da2a52015-02-11 23:35:07 -06002154
Paul Kehrere27f6582015-08-10 18:33:38 -05002155 .. attribute:: RSA_WITH_MD5
Paul Kehrer56da2a52015-02-11 23:35:07 -06002156
Paul Kehrere27f6582015-08-10 18:33:38 -05002157 Corresponds to the dotted string ``"1.2.840.113549.1.1.4"``. This is
2158 an MD5 digest signed by an RSA key.
Paul Kehrer56da2a52015-02-11 23:35:07 -06002159
Paul Kehrere27f6582015-08-10 18:33:38 -05002160 .. attribute:: RSA_WITH_SHA1
Paul Kehrer56da2a52015-02-11 23:35:07 -06002161
Paul Kehrere27f6582015-08-10 18:33:38 -05002162 Corresponds to the dotted string ``"1.2.840.113549.1.1.5"``. This is
2163 a SHA1 digest signed by an RSA key.
Paul Kehrer56da2a52015-02-11 23:35:07 -06002164
Paul Kehrere27f6582015-08-10 18:33:38 -05002165 .. attribute:: RSA_WITH_SHA224
Paul Kehrer56da2a52015-02-11 23:35:07 -06002166
Paul Kehrere27f6582015-08-10 18:33:38 -05002167 Corresponds to the dotted string ``"1.2.840.113549.1.1.14"``. This is
2168 a SHA224 digest signed by an RSA key.
Paul Kehrer56da2a52015-02-11 23:35:07 -06002169
Paul Kehrere27f6582015-08-10 18:33:38 -05002170 .. attribute:: RSA_WITH_SHA256
Paul Kehrer56da2a52015-02-11 23:35:07 -06002171
Paul Kehrere27f6582015-08-10 18:33:38 -05002172 Corresponds to the dotted string ``"1.2.840.113549.1.1.11"``. This is
2173 a SHA256 digest signed by an RSA key.
Alex Gaynor3aadabf2015-06-23 22:06:21 -04002174
Paul Kehrere27f6582015-08-10 18:33:38 -05002175 .. attribute:: RSA_WITH_SHA384
Alex Gaynor3aadabf2015-06-23 22:06:21 -04002176
Paul Kehrere27f6582015-08-10 18:33:38 -05002177 Corresponds to the dotted string ``"1.2.840.113549.1.1.12"``. This is
2178 a SHA384 digest signed by an RSA key.
Paul Kehrer56da2a52015-02-11 23:35:07 -06002179
Paul Kehrere27f6582015-08-10 18:33:38 -05002180 .. attribute:: RSA_WITH_SHA512
Paul Kehrer56da2a52015-02-11 23:35:07 -06002181
Paul Kehrere27f6582015-08-10 18:33:38 -05002182 Corresponds to the dotted string ``"1.2.840.113549.1.1.13"``. This is
2183 a SHA512 digest signed by an RSA key.
Paul Kehrer56da2a52015-02-11 23:35:07 -06002184
Paul Kehrere27f6582015-08-10 18:33:38 -05002185 .. attribute:: ECDSA_WITH_SHA1
Paul Kehrer56da2a52015-02-11 23:35:07 -06002186
Paul Kehrere27f6582015-08-10 18:33:38 -05002187 Corresponds to the dotted string ``"1.2.840.10045.4.1"``. This is a SHA1
2188 digest signed by an ECDSA key.
Paul Kehrer56da2a52015-02-11 23:35:07 -06002189
Paul Kehrere27f6582015-08-10 18:33:38 -05002190 .. attribute:: ECDSA_WITH_SHA224
Paul Kehrer56da2a52015-02-11 23:35:07 -06002191
Paul Kehrere27f6582015-08-10 18:33:38 -05002192 Corresponds to the dotted string ``"1.2.840.10045.4.3.1"``. This is
2193 a SHA224 digest signed by an ECDSA key.
2194
2195 .. attribute:: ECDSA_WITH_SHA256
2196
2197 Corresponds to the dotted string ``"1.2.840.10045.4.3.2"``. This is
2198 a SHA256 digest signed by an ECDSA key.
2199
2200 .. attribute:: ECDSA_WITH_SHA384
2201
2202 Corresponds to the dotted string ``"1.2.840.10045.4.3.3"``. This is
2203 a SHA384 digest signed by an ECDSA key.
2204
2205 .. attribute:: ECDSA_WITH_SHA512
2206
2207 Corresponds to the dotted string ``"1.2.840.10045.4.3.4"``. This is
2208 a SHA512 digest signed by an ECDSA key.
2209
2210 .. attribute:: DSA_WITH_SHA1
2211
2212 Corresponds to the dotted string ``"1.2.840.10040.4.3"``. This is
2213 a SHA1 digest signed by a DSA key.
2214
2215 .. attribute:: DSA_WITH_SHA224
2216
2217 Corresponds to the dotted string ``"2.16.840.1.101.3.4.3.1"``. This is
2218 a SHA224 digest signed by a DSA key.
2219
2220 .. attribute:: DSA_WITH_SHA256
Paul Kehrer56da2a52015-02-11 23:35:07 -06002221
Paul Kehrere27f6582015-08-10 18:33:38 -05002222 Corresponds to the dotted string ``"2.16.840.1.101.3.4.3.2"``. This is
2223 a SHA256 digest signed by a DSA key.
Paul Kehrer56da2a52015-02-11 23:35:07 -06002224
Paul Kehrer56da2a52015-02-11 23:35:07 -06002225
Paul Kehrere27f6582015-08-10 18:33:38 -05002226.. class:: ExtendedKeyUsageOID
Paul Kehrer56da2a52015-02-11 23:35:07 -06002227
Paul Kehrere27f6582015-08-10 18:33:38 -05002228 .. versionadded:: 1.0
Paul Kehrer56da2a52015-02-11 23:35:07 -06002229
Paul Kehrere27f6582015-08-10 18:33:38 -05002230 .. attribute:: SERVER_AUTH
Paul Kehrer56da2a52015-02-11 23:35:07 -06002231
Paul Kehrere27f6582015-08-10 18:33:38 -05002232 Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.1"``. This is used
2233 to denote that a certificate may be used for TLS web server
2234 authentication.
Paul Kehrer56da2a52015-02-11 23:35:07 -06002235
Paul Kehrere27f6582015-08-10 18:33:38 -05002236 .. attribute:: CLIENT_AUTH
Paul Kehrer56da2a52015-02-11 23:35:07 -06002237
Paul Kehrere27f6582015-08-10 18:33:38 -05002238 Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.2"``. This is used
2239 to denote that a certificate may be used for TLS web client
2240 authentication.
Paul Kehrerffa2a152015-03-31 08:18:25 -05002241
Paul Kehrere27f6582015-08-10 18:33:38 -05002242 .. attribute:: CODE_SIGNING
Paul Kehrere1513fa2015-03-30 23:08:17 -05002243
Paul Kehrere27f6582015-08-10 18:33:38 -05002244 Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.3"``. This is used
2245 to denote that a certificate may be used for code signing.
Paul Kehrere1513fa2015-03-30 23:08:17 -05002246
Paul Kehrere27f6582015-08-10 18:33:38 -05002247 .. attribute:: EMAIL_PROTECTION
Paul Kehrere1513fa2015-03-30 23:08:17 -05002248
Paul Kehrere27f6582015-08-10 18:33:38 -05002249 Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.4"``. This is used
2250 to denote that a certificate may be used for email protection.
Paul Kehrere1513fa2015-03-30 23:08:17 -05002251
Paul Kehrere27f6582015-08-10 18:33:38 -05002252 .. attribute:: TIME_STAMPING
Paul Kehrere1513fa2015-03-30 23:08:17 -05002253
Paul Kehrere27f6582015-08-10 18:33:38 -05002254 Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.8"``. This is used
2255 to denote that a certificate may be used for time stamping.
Paul Kehrere1513fa2015-03-30 23:08:17 -05002256
Paul Kehrere27f6582015-08-10 18:33:38 -05002257 .. attribute:: OCSP_SIGNING
Paul Kehrere1513fa2015-03-30 23:08:17 -05002258
Paul Kehrere27f6582015-08-10 18:33:38 -05002259 Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.9"``. This is used
2260 to denote that a certificate may be used for signing OCSP responses.
Paul Kehrere1513fa2015-03-30 23:08:17 -05002261
Paul Kehrere1513fa2015-03-30 23:08:17 -05002262
Paul Kehrere27f6582015-08-10 18:33:38 -05002263.. class:: AuthorityInformationAccessOID
Paul Kehrere1513fa2015-03-30 23:08:17 -05002264
Paul Kehrere27f6582015-08-10 18:33:38 -05002265 .. versionadded:: 1.0
Paul Kehrere1513fa2015-03-30 23:08:17 -05002266
Paul Kehrere27f6582015-08-10 18:33:38 -05002267 .. attribute:: OCSP
Paul Kehrere1513fa2015-03-30 23:08:17 -05002268
Paul Kehrere27f6582015-08-10 18:33:38 -05002269 Corresponds to the dotted string ``"1.3.6.1.5.5.7.48.1"``. Used as the
2270 identifier for OCSP data in
2271 :class:`~cryptography.x509.AccessDescription` objects.
Paul Kehrere1513fa2015-03-30 23:08:17 -05002272
Paul Kehrere27f6582015-08-10 18:33:38 -05002273 .. attribute:: CA_ISSUERS
Paul Kehrer3e6d5582015-05-02 21:57:56 -05002274
Paul Kehrere27f6582015-08-10 18:33:38 -05002275 Corresponds to the dotted string ``"1.3.6.1.5.5.7.48.2"``. Used as the
2276 identifier for CA issuer data in
2277 :class:`~cryptography.x509.AccessDescription` objects.
Paul Kehrer3e6d5582015-05-02 21:57:56 -05002278
Paul Kehrer3e6d5582015-05-02 21:57:56 -05002279
Paul Kehrere27f6582015-08-10 18:33:38 -05002280.. class:: CertificatePoliciesOID
Paul Kehrer3e6d5582015-05-02 21:57:56 -05002281
Paul Kehrere27f6582015-08-10 18:33:38 -05002282 .. versionadded:: 1.0
Paul Kehrer3e6d5582015-05-02 21:57:56 -05002283
Paul Kehrere27f6582015-08-10 18:33:38 -05002284 .. attribute:: CPS_QUALIFIER
Paul Kehrer2e879742015-05-02 23:09:56 -05002285
Paul Kehrere27f6582015-08-10 18:33:38 -05002286 Corresponds to the dotted string ``"1.3.6.1.5.5.7.2.1"``.
Paul Kehrer2e879742015-05-02 23:09:56 -05002287
Paul Kehrere27f6582015-08-10 18:33:38 -05002288 .. attribute:: CPS_USER_NOTICE
Paul Kehrer2e879742015-05-02 23:09:56 -05002289
Paul Kehrere27f6582015-08-10 18:33:38 -05002290 Corresponds to the dotted string ``"1.3.6.1.5.5.7.2.2"``.
Paul Kehrer2e879742015-05-02 23:09:56 -05002291
Paul Kehrere27f6582015-08-10 18:33:38 -05002292 .. attribute:: ANY_POLICY
Paul Kehrer2e879742015-05-02 23:09:56 -05002293
Paul Kehrere27f6582015-08-10 18:33:38 -05002294 Corresponds to the dotted string ``"2.5.29.32.0"``.
Paul Kehrer16fae762015-05-01 23:14:20 -05002295
Paul Kehrer16fae762015-05-01 23:14:20 -05002296
Paul Kehrere27f6582015-08-10 18:33:38 -05002297.. class:: ExtensionOID
Paul Kehrer5553d572015-03-23 21:08:01 -05002298
Paul Kehrere27f6582015-08-10 18:33:38 -05002299 .. versionadded:: 1.0
Paul Kehrer2bb94642015-03-21 09:54:17 -05002300
Paul Kehrere27f6582015-08-10 18:33:38 -05002301 .. attribute:: BASIC_CONSTRAINTS
Paul Kehrer2bb94642015-03-21 09:54:17 -05002302
Paul Kehrere27f6582015-08-10 18:33:38 -05002303 Corresponds to the dotted string ``"2.5.29.19"``. The identifier for the
2304 :class:`~cryptography.x509.BasicConstraints` extension type.
Paul Kehrer2bb94642015-03-21 09:54:17 -05002305
Paul Kehrere27f6582015-08-10 18:33:38 -05002306 .. attribute:: KEY_USAGE
Paul Kehrercecbbba2015-03-30 14:58:38 -05002307
Paul Kehrere27f6582015-08-10 18:33:38 -05002308 Corresponds to the dotted string ``"2.5.29.15"``. The identifier for the
2309 :class:`~cryptography.x509.KeyUsage` extension type.
Paul Kehrercecbbba2015-03-30 14:58:38 -05002310
Paul Kehrere27f6582015-08-10 18:33:38 -05002311 .. attribute:: SUBJECT_ALTERNATIVE_NAME
Paul Kehrerd4f632e2015-05-12 08:25:42 -05002312
Paul Kehrere27f6582015-08-10 18:33:38 -05002313 Corresponds to the dotted string ``"2.5.29.17"``. The identifier for the
2314 :class:`~cryptography.x509.SubjectAlternativeName` extension type.
Paul Kehrerd4f632e2015-05-12 08:25:42 -05002315
Paul Kehrere27f6582015-08-10 18:33:38 -05002316 .. attribute:: ISSUER_ALTERNATIVE_NAME
Paul Kehrer99125c92015-06-07 18:37:10 -05002317
Paul Kehrere27f6582015-08-10 18:33:38 -05002318 Corresponds to the dotted string ``"2.5.29.18"``. The identifier for the
2319 :class:`~cryptography.x509.IssuerAlternativeName` extension type.
Paul Kehrer99125c92015-06-07 18:37:10 -05002320
Paul Kehrere27f6582015-08-10 18:33:38 -05002321 .. attribute:: SUBJECT_KEY_IDENTIFIER
Paul Kehrerd4f632e2015-05-12 08:25:42 -05002322
Paul Kehrere27f6582015-08-10 18:33:38 -05002323 Corresponds to the dotted string ``"2.5.29.14"``. The identifier for the
2324 :class:`~cryptography.x509.SubjectKeyIdentifier` extension type.
Paul Kehrerd4f632e2015-05-12 08:25:42 -05002325
Paul Kehrere27f6582015-08-10 18:33:38 -05002326 .. attribute:: NAME_CONSTRAINTS
Paul Kehrere0017be2015-05-17 20:39:40 -06002327
Paul Kehrere27f6582015-08-10 18:33:38 -05002328 Corresponds to the dotted string ``"2.5.29.30"``. The identifier for the
2329 :class:`~cryptography.x509.NameConstraints` extension type.
Paul Kehrere0017be2015-05-17 20:39:40 -06002330
Paul Kehrere27f6582015-08-10 18:33:38 -05002331 .. attribute:: CRL_DISTRIBUTION_POINTS
Paul Kehrerd4f632e2015-05-12 08:25:42 -05002332
Paul Kehrere27f6582015-08-10 18:33:38 -05002333 Corresponds to the dotted string ``"2.5.29.31"``. The identifier for the
2334 :class:`~cryptography.x509.CRLDistributionPoints` extension type.
Paul Kehrerd4f632e2015-05-12 08:25:42 -05002335
Paul Kehrere27f6582015-08-10 18:33:38 -05002336 .. attribute:: CERTIFICATE_POLICIES
Paul Kehrerd4f632e2015-05-12 08:25:42 -05002337
Paul Kehrere27f6582015-08-10 18:33:38 -05002338 Corresponds to the dotted string ``"2.5.29.32"``. The identifier for the
2339 :class:`~cryptography.x509.CertificatePolicies` extension type.
Paul Kehrerd4f632e2015-05-12 08:25:42 -05002340
Paul Kehrere27f6582015-08-10 18:33:38 -05002341 .. attribute:: AUTHORITY_KEY_IDENTIFIER
Paul Kehrerd4f632e2015-05-12 08:25:42 -05002342
Paul Kehrere27f6582015-08-10 18:33:38 -05002343 Corresponds to the dotted string ``"2.5.29.35"``. The identifier for the
2344 :class:`~cryptography.x509.AuthorityKeyIdentifier` extension type.
Paul Kehrerd4f632e2015-05-12 08:25:42 -05002345
Paul Kehrere27f6582015-08-10 18:33:38 -05002346 .. attribute:: EXTENDED_KEY_USAGE
Paul Kehrerd4f632e2015-05-12 08:25:42 -05002347
Paul Kehrere27f6582015-08-10 18:33:38 -05002348 Corresponds to the dotted string ``"2.5.29.37"``. The identifier for the
2349 :class:`~cryptography.x509.ExtendedKeyUsage` extension type.
Paul Kehrerd4f632e2015-05-12 08:25:42 -05002350
Paul Kehrere27f6582015-08-10 18:33:38 -05002351 .. attribute:: AUTHORITY_INFORMATION_ACCESS
Paul Kehrerd4f632e2015-05-12 08:25:42 -05002352
Paul Kehrere27f6582015-08-10 18:33:38 -05002353 Corresponds to the dotted string ``"1.3.6.1.5.5.7.1.1"``. The identifier
2354 for the :class:`~cryptography.x509.AuthorityInformationAccess` extension
2355 type.
Paul Kehrer56da2a52015-02-11 23:35:07 -06002356
Paul Kehrere27f6582015-08-10 18:33:38 -05002357 .. attribute:: INHIBIT_ANY_POLICY
Paul Kehrerb33de932015-08-06 23:41:05 +01002358
Paul Kehrere27f6582015-08-10 18:33:38 -05002359 Corresponds to the dotted string ``"2.5.29.54"``. The identifier
2360 for the :class:`~cryptography.x509.InhibitAnyPolicy` extension type.
Paul Kehrerb33de932015-08-06 23:41:05 +01002361
Paul Kehrere27f6582015-08-10 18:33:38 -05002362 .. attribute:: OCSP_NO_CHECK
Paul Kehrer4a1038e2015-05-18 10:28:31 -07002363
Paul Kehrere27f6582015-08-10 18:33:38 -05002364 Corresponds to the dotted string ``"1.3.6.1.5.5.7.48.1.5"``. The
2365 identifier for the :class:`~cryptography.x509.OCSPNoCheck` extension
2366 type.
Paul Kehrer4a1038e2015-05-18 10:28:31 -07002367
Paul Kehrer51f39cb2015-12-21 21:17:39 -06002368 .. attribute:: CRL_NUMBER
2369
2370 Corresponds to the dotted string ``"2.5.29.20"``. The identifier for
2371 the ``CRLNumber`` extension type. This extension only has meaning
2372 for certificate revocation lists.
2373
Paul Kehrerc6242dc2015-12-25 16:36:46 -06002374.. class:: CRLEntryExtensionOID
2375
2376 .. versionadded:: 1.2
2377
2378 .. attribute:: CERTIFICATE_ISSUER
2379
2380 Corresponds to the dotted string ``"2.5.29.29"``.
2381
2382 .. attribute:: CRL_REASON
2383
2384 Corresponds to the dotted string ``"2.5.29.21"``.
2385
2386 .. attribute:: INVALIDITY_DATE
2387
2388 Corresponds to the dotted string ``"2.5.29.24"``.
2389
Paul Kehrer912d3fb2015-01-29 11:19:22 -06002390Exceptions
2391~~~~~~~~~~
Paul Kehrere27f6582015-08-10 18:33:38 -05002392.. currentmodule:: cryptography.x509
Paul Kehrer912d3fb2015-01-29 11:19:22 -06002393
Paul Kehrere76cd272014-12-14 19:00:51 -06002394.. class:: InvalidVersion
Paul Kehrera68fd332014-11-27 07:08:40 -10002395
2396 This is raised when an X.509 certificate has an invalid version number.
Paul Kehrer016e08a2014-11-26 09:41:18 -10002397
Paul Kehrerd5cccf72014-12-15 17:20:33 -06002398 .. attribute:: parsed_version
2399
Paul Kehrerbbffc402014-12-17 13:33:55 -06002400 :type: int
2401
2402 Returns the raw version that was parsed from the certificate.
Paul Kehrerd5cccf72014-12-15 17:20:33 -06002403
Paul Kehrerfbb7ac82015-03-16 19:26:29 -05002404.. class:: DuplicateExtension
2405
2406 This is raised when more than one X.509 extension of the same type is
2407 found within a certificate.
2408
2409 .. attribute:: oid
2410
2411 :type: :class:`ObjectIdentifier`
2412
2413 Returns the OID.
2414
2415.. class:: UnsupportedExtension
2416
2417 This is raised when a certificate contains an unsupported extension type.
2418
2419 .. attribute:: oid
2420
2421 :type: :class:`ObjectIdentifier`
2422
2423 Returns the OID.
2424
Paul Kehrerfa56a232015-03-17 13:14:03 -05002425.. class:: ExtensionNotFound
2426
2427 This is raised when calling :meth:`Extensions.get_extension_for_oid` with
2428 an extension OID that is not present in the certificate.
2429
2430 .. attribute:: oid
2431
2432 :type: :class:`ObjectIdentifier`
2433
2434 Returns the OID.
2435
Paul Kehrer9089c912015-04-20 22:15:20 -05002436.. class:: UnsupportedGeneralNameType
2437
2438 This is raised when a certificate contains an unsupported general name
2439 type in an extension.
2440
Paul Kehrerbed07352015-04-21 08:31:10 -05002441 .. attribute:: type
2442
Paul Kehrer0a621bf2015-04-22 09:22:56 -05002443 :type: int
2444
2445 The integer value of the unsupported type. The complete list of
2446 types can be found in `RFC 5280 section 4.2.1.6`_.
Paul Kehrerbed07352015-04-21 08:31:10 -05002447
Paul Kehrer016e08a2014-11-26 09:41:18 -10002448
Paul Kehrerc7c9a432015-04-19 09:20:13 -05002449.. _`RFC 5280 section 4.2.1.1`: https://tools.ietf.org/html/rfc5280#section-4.2.1.1
Paul Kehrer0a621bf2015-04-22 09:22:56 -05002450.. _`RFC 5280 section 4.2.1.6`: https://tools.ietf.org/html/rfc5280#section-4.2.1.6