blob: 5f4c5314a0a365054ab4bfd58050b46ca737abdd [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
156 ``-----BEGIN X509 CRL-----``. This format is also known as
157 PKCS#10.
158
159 :param bytes data: The PEM encoded request data.
160
161 :param backend: A backend supporting the
162 :class:`~cryptography.hazmat.backends.interfaces.X509Backend`
163 interface.
164
165 :returns: An instance of
166 :class:`~cryptography.x509.CertificateRevocationList`.
167
168.. function:: load_der_x509_crl(data, backend)
169
170 .. versionadded:: 1.1
171
172 Deserialize a certificate revocation list (CRL) from DER encoded data. DER
173 is a binary format.
174
175 :param bytes data: The DER encoded request data.
176
177 :param backend: A backend supporting the
178 :class:`~cryptography.hazmat.backends.interfaces.X509Backend`
179 interface.
180
181 :returns: An instance of
182 :class:`~cryptography.x509.CertificateRevocationList`.
183
184.. doctest::
185
186 >>> from cryptography import x509
187 >>> from cryptography.hazmat.backends import default_backend
188 >>> from cryptography.hazmat.primitives import hashes
189 >>> crl = x509.load_pem_x509_crl(pem_crl_data, default_backend())
190 >>> isinstance(crl.signature_hash_algorithm, hashes.SHA256)
191 True
192
Paul Kehrera1a1f232015-03-15 15:34:35 -0500193Loading Certificate Signing Requests
194~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600195
Paul Kehrer31e39882015-03-11 11:37:04 -0500196.. function:: load_pem_x509_csr(data, backend)
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600197
198 .. versionadded:: 0.9
199
Paul Kehrera1a1f232015-03-15 15:34:35 -0500200 Deserialize a certificate signing request (CSR) from PEM encoded data. PEM
Paul Kehrer5aadb9c2015-03-11 20:48:42 -0500201 requests are base64 decoded and have delimiters that look like
Paul Kehrerd3dafbd2015-03-15 16:24:18 -0500202 ``-----BEGIN CERTIFICATE REQUEST-----``. This format is also known as
203 PKCS#10.
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600204
205 :param bytes data: The PEM encoded request data.
206
207 :param backend: A backend supporting the
208 :class:`~cryptography.hazmat.backends.interfaces.X509Backend`
209 interface.
210
Paul Kehrera1a1f232015-03-15 15:34:35 -0500211 :returns: An instance of
212 :class:`~cryptography.x509.CertificateSigningRequest`.
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600213
Paul Kehrer1effb6e2015-03-30 15:05:59 -0500214.. function:: load_der_x509_csr(data, backend)
215
216 .. versionadded:: 0.9
217
218 Deserialize a certificate signing request (CSR) from DER encoded data. DER
219 is a binary format and is not commonly used with CSRs.
220
221 :param bytes data: The DER encoded request data.
222
223 :param backend: A backend supporting the
224 :class:`~cryptography.hazmat.backends.interfaces.X509Backend`
225 interface.
226
227 :returns: An instance of
228 :class:`~cryptography.x509.CertificateSigningRequest`.
229
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600230.. doctest::
231
232 >>> from cryptography import x509
233 >>> from cryptography.hazmat.backends import default_backend
234 >>> from cryptography.hazmat.primitives import hashes
Paul Kehrera1a1f232015-03-15 15:34:35 -0500235 >>> csr = x509.load_pem_x509_csr(pem_req_data, default_backend())
236 >>> isinstance(csr.signature_hash_algorithm, hashes.SHA1)
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600237 True
238
Paul Kehrere76cd272014-12-14 19:00:51 -0600239X.509 Certificate Object
240~~~~~~~~~~~~~~~~~~~~~~~~
Paul Kehrerb2de9482014-12-11 14:54:48 -0600241
Paul Kehrere76cd272014-12-14 19:00:51 -0600242.. class:: Certificate
Paul Kehrerb2de9482014-12-11 14:54:48 -0600243
244 .. versionadded:: 0.7
245
246 .. attribute:: version
247
Paul Kehrere76cd272014-12-14 19:00:51 -0600248 :type: :class:`~cryptography.x509.Version`
Paul Kehrerb2de9482014-12-11 14:54:48 -0600249
Paul Kehrere76cd272014-12-14 19:00:51 -0600250 The certificate version as an enumeration. Version 3 certificates are
251 the latest version and also the only type you should see in practice.
Paul Kehrerb2de9482014-12-11 14:54:48 -0600252
Alex Gaynor89c4dc82014-12-16 16:49:33 -0800253 :raises cryptography.x509.InvalidVersion: If the version in the
Alex Gaynor6d7ab4c2014-12-16 16:50:33 -0800254 certificate is not a known
255 :class:`X.509 version <cryptography.x509.Version>`.
Paul Kehrer92aac382014-12-15 16:25:28 -0600256
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600257 .. doctest::
258
259 >>> cert.version
260 <Version.v3: 2>
261
Paul Kehrerb2de9482014-12-11 14:54:48 -0600262 .. method:: fingerprint(algorithm)
263
264 :param algorithm: The
Paul Kehrer601278a2015-02-12 12:51:00 -0600265 :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm`
Paul Kehrerb2de9482014-12-11 14:54:48 -0600266 that will be used to generate the fingerprint.
267
Erik Trauschke2dcce902015-05-14 16:12:24 -0700268 :return bytes: The fingerprint using the supplied hash algorithm, as
Paul Kehrerb2de9482014-12-11 14:54:48 -0600269 bytes.
270
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600271 .. doctest::
272
273 >>> from cryptography.hazmat.primitives import hashes
274 >>> cert.fingerprint(hashes.SHA256())
Paul Kehrer78a81502014-12-16 14:47:52 -0600275 '\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 -0600276
Paul Kehrerb2de9482014-12-11 14:54:48 -0600277 .. attribute:: serial
278
279 :type: int
280
281 The serial as a Python integer.
282
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600283 .. doctest::
284
285 >>> cert.serial
286 2
287
Paul Kehrerb2de9482014-12-11 14:54:48 -0600288 .. method:: public_key()
289
290 :type:
Alex Stapletonf79c2312014-12-30 12:50:14 +0000291 :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey` or
Paul Kehrer45efdbc2015-02-12 10:58:22 -0600292 :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPublicKey` or
293 :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey`
Paul Kehrerb2de9482014-12-11 14:54:48 -0600294
295 The public key associated with the certificate.
296
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600297 .. doctest::
298
Alex Stapletonf79c2312014-12-30 12:50:14 +0000299 >>> from cryptography.hazmat.primitives.asymmetric import rsa
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600300 >>> public_key = cert.public_key()
Alex Stapletonf79c2312014-12-30 12:50:14 +0000301 >>> isinstance(public_key, rsa.RSAPublicKey)
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600302 True
303
Paul Kehrerb2de9482014-12-11 14:54:48 -0600304 .. attribute:: not_valid_before
305
306 :type: :class:`datetime.datetime`
307
Paul Kehrer78a81502014-12-16 14:47:52 -0600308 A naïve datetime representing the beginning of the validity period for
309 the certificate in UTC. This value is inclusive.
Paul Kehrerb2de9482014-12-11 14:54:48 -0600310
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600311 .. doctest::
312
313 >>> cert.not_valid_before
314 datetime.datetime(2010, 1, 1, 8, 30)
315
Paul Kehrerb2de9482014-12-11 14:54:48 -0600316 .. attribute:: not_valid_after
317
318 :type: :class:`datetime.datetime`
319
Paul Kehrer78a81502014-12-16 14:47:52 -0600320 A naïve datetime representing the end of the validity period for the
321 certificate in UTC. This value is inclusive.
Paul Kehrerb2de9482014-12-11 14:54:48 -0600322
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600323 .. doctest::
324
325 >>> cert.not_valid_after
326 datetime.datetime(2030, 12, 31, 8, 30)
327
Paul Kehrer719d5362015-01-01 20:03:52 -0600328 .. attribute:: issuer
329
330 .. versionadded:: 0.8
331
332 :type: :class:`Name`
333
334 The :class:`Name` of the issuer.
335
336 .. attribute:: subject
337
338 .. versionadded:: 0.8
339
340 :type: :class:`Name`
341
342 The :class:`Name` of the subject.
343
Paul Kehrer8802a5b2015-02-13 12:06:57 -0600344 .. attribute:: signature_hash_algorithm
Paul Kehrer56da2a52015-02-11 23:35:07 -0600345
Paul Kehrer8802a5b2015-02-13 12:06:57 -0600346 :type: :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm`
Paul Kehrer56da2a52015-02-11 23:35:07 -0600347
Paul Kehrere612ec72015-02-16 14:33:35 -0600348 Returns the
Paul Kehrer71d40c62015-02-19 08:21:04 -0600349 :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` which
Paul Kehrer1a7ba872015-02-19 18:09:05 -0600350 was used in signing this certificate.
Paul Kehrer56da2a52015-02-11 23:35:07 -0600351
352 .. doctest::
353
Paul Kehrer8802a5b2015-02-13 12:06:57 -0600354 >>> from cryptography.hazmat.primitives import hashes
355 >>> isinstance(cert.signature_hash_algorithm, hashes.SHA256)
356 True
Paul Kehrer719d5362015-01-01 20:03:52 -0600357
Paul Kehrerfbb7ac82015-03-16 19:26:29 -0500358 .. attribute:: extensions
359
360 :type: :class:`Extensions`
361
362 The extensions encoded in the certificate.
363
364 :raises cryptography.x509.DuplicateExtension: If more than one
365 extension of the same type is found within the certificate.
366
Paul Kehrerd8fc0be2015-04-21 08:31:10 -0500367 :raises cryptography.x509.UnsupportedExtension: If the certificate
368 contains an extension that is not supported.
369
Paul Kehrerbed07352015-04-21 08:31:10 -0500370 :raises cryptography.x509.UnsupportedGeneralNameType: If an extension
371 contains a general name that is not supported.
372
Paul Kehrerb8968812015-05-15 09:01:34 -0700373 :raises UnicodeError: If an extension contains IDNA encoding that is
374 invalid or not compliant with IDNA 2008.
375
Paul Kehrerfa56a232015-03-17 13:14:03 -0500376 .. doctest::
377
378 >>> for ext in cert.extensions:
379 ... print(ext)
Paul Kehrerd774de92015-05-03 10:52:25 -0500380 <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 -0400381 <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 -0400382 <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 -0500383 <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 -0500384 <Extension(oid=<ObjectIdentifier(oid=2.5.29.19, name=basicConstraints)>, critical=True, value=<BasicConstraints(ca=True, path_length=None)>)>
385
Andre Carona8aded62015-05-19 20:11:57 -0400386 .. method:: public_bytes(encoding)
387
Alex Gaynord0b376b2015-07-05 13:58:12 -0400388 .. versionadded:: 1.0
389
Andre Carona8aded62015-05-19 20:11:57 -0400390 :param encoding: The
391 :class:`~cryptography.hazmat.primitives.serialization.Encoding`
392 that will be used to serialize the certificate.
393
394 :return bytes: The data that can be written to a file or sent
395 over the network to be verified by clients.
396
Erik Trauschke2dcce902015-05-14 16:12:24 -0700397X.509 CRL (Certificate Revocation List) Object
398~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
399
400.. class:: CertificateRevocationList
401
402 .. versionadded:: 1.0
403
Erik Trauschke3cdabaf2015-10-13 09:42:53 -0700404 A CertificateRevocationList is an object representing a list of revoked
405 certificates. The object is iterable and will yield the RevokedCertificate
406 objects stored in this CRL.
407
408 .. doctest::
Erik Trauschkeb14f7d12015-10-13 09:55:39 -0700409
Erik Trauschke3cdabaf2015-10-13 09:42:53 -0700410 >>> len(crl)
411 1
412 >>> type(crl[0])
413 <class 'cryptography.hazmat.backends.openssl.x509._RevokedCertificate'>
414 >>> for r in crl:
415 ... print(r.serial_number)
416 0
417
Erik Trauschke2dcce902015-05-14 16:12:24 -0700418 .. method:: fingerprint(algorithm)
419
420 :param algorithm: The
421 :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm`
422 that will be used to generate the fingerprint.
423
424 :return bytes: The fingerprint using the supplied hash algorithm, as
425 bytes.
426
Erik Trauschkedc570402015-09-24 20:24:28 -0700427 .. doctest::
428
429 >>> from cryptography.hazmat.primitives import hashes
430 >>> crl.fingerprint(hashes.SHA256())
431 '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'
432
Erik Trauschke2dcce902015-05-14 16:12:24 -0700433 .. attribute:: signature_hash_algorithm
434
435 :type: :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm`
436
437 Returns the
438 :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` which
439 was used in signing this CRL.
440
Erik Trauschkedc570402015-09-24 20:24:28 -0700441 .. doctest::
442
443 >>> from cryptography.hazmat.primitives import hashes
444 >>> isinstance(crl.signature_hash_algorithm, hashes.SHA256)
445 True
446
Erik Trauschke2dcce902015-05-14 16:12:24 -0700447 .. attribute:: issuer
448
449 :type: :class:`Name`
450
451 The :class:`Name` of the issuer.
452
Erik Trauschkedc570402015-09-24 20:24:28 -0700453 .. doctest::
454
455 >>> crl.issuer
456 <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')>])>
457
Erik Trauschke2dcce902015-05-14 16:12:24 -0700458 .. attribute:: next_update
459
460 :type: :class:`datetime.datetime`
461
462 A naïve datetime representing when the next update to this CRL is
463 expected.
464
Erik Trauschkedc570402015-09-24 20:24:28 -0700465 .. doctest::
466
467 >>> crl.next_update
468 datetime.datetime(2016, 1, 1, 0, 0)
469
Erik Trauschke2dcce902015-05-14 16:12:24 -0700470 .. attribute:: last_update
471
472 :type: :class:`datetime.datetime`
473
474 A naïve datetime representing when the this CRL was last updated.
475
Erik Trauschkedc570402015-09-24 20:24:28 -0700476 .. doctest::
477
478 >>> crl.last_update
479 datetime.datetime(2015, 1, 1, 0, 0)
480
Erik Trauschkeabb7b6e2015-05-27 15:07:35 -0700481 .. attribute:: revoked_certificates
Erik Trauschke2dcce902015-05-14 16:12:24 -0700482
483 :type: list of :class:`RevokedCertificate`
484
485 The revoked certificates listed in this CRL.
486
Erik Trauschkedc570402015-09-24 20:24:28 -0700487 .. doctest::
488
489 >>> for r in crl.revoked_certificates:
490 ... print(r.serial_number)
491 0
492
Erik Trauschke2dcce902015-05-14 16:12:24 -0700493 .. attribute:: extensions
494
495 :type: :class:`Extensions`
496
497 The extensions encoded in the CRL.
498
Andre Caron9bbfcea2015-05-18 20:55:29 -0400499X.509 Certificate Builder
500~~~~~~~~~~~~~~~~~~~~~~~~~
501
502.. class:: CertificateBuilder
503
Ian Cordasco1517a4b2015-08-02 22:11:19 -0500504 .. versionadded:: 1.0
505
506 .. doctest::
507
508 >>> from cryptography import x509
509 >>> from cryptography.hazmat.backends import default_backend
510 >>> from cryptography.hazmat.primitives import hashes
511 >>> from cryptography.hazmat.primitives.asymmetric import rsa
Paul Kehrere27f6582015-08-10 18:33:38 -0500512 >>> from cryptography.x509.oid import NameOID
Ian Cordasco1517a4b2015-08-02 22:11:19 -0500513 >>> import datetime
514 >>> import uuid
515 >>> one_day = datetime.timedelta(1, 0, 0)
516 >>> private_key = rsa.generate_private_key(
517 ... public_exponent=65537,
518 ... key_size=2048,
519 ... backend=default_backend()
520 ... )
521 >>> public_key = rsa.generate_private_key(
522 ... public_exponent=65537,
523 ... key_size=2048,
524 ... backend=default_backend()
525 ... ).public_key()
526 >>> builder = x509.CertificateBuilder()
527 >>> builder = builder.subject_name(x509.Name([
Paul Kehrere27f6582015-08-10 18:33:38 -0500528 ... x509.NameAttribute(NameOID.COMMON_NAME, u'cryptography.io'),
Ian Cordasco1517a4b2015-08-02 22:11:19 -0500529 ... ]))
530 >>> builder = builder.issuer_name(x509.Name([
Paul Kehrere27f6582015-08-10 18:33:38 -0500531 ... x509.NameAttribute(NameOID.COMMON_NAME, u'cryptography.io'),
Ian Cordasco1517a4b2015-08-02 22:11:19 -0500532 ... ]))
533 >>> builder = builder.not_valid_before(datetime.datetime.today() - one_day)
534 >>> builder = builder.not_valid_after(datetime.datetime(2018, 8, 2))
535 >>> builder = builder.serial_number(int(uuid.uuid4()))
536 >>> builder = builder.public_key(public_key)
537 >>> builder = builder.add_extension(
538 ... x509.BasicConstraints(ca=False, path_length=None), critical=True,
539 ... )
540 >>> certificate = builder.sign(
541 ... private_key=private_key, algorithm=hashes.SHA256(),
542 ... backend=default_backend()
543 ... )
544 >>> isinstance(certificate, x509.Certificate)
545 True
546
Ian Cordasco0092a0b2015-07-18 21:46:41 -0500547 .. method:: issuer_name(name)
Andre Caron9bbfcea2015-05-18 20:55:29 -0400548
549 Sets the issuer's distinguished name.
550
Ian Cordascoc9682ad2015-08-01 12:11:13 -0500551 :param name: The :class:`~cryptography.x509.Name` that describes the
552 issuer (CA).
Andre Caron9bbfcea2015-05-18 20:55:29 -0400553
Ian Cordasco0092a0b2015-07-18 21:46:41 -0500554 .. method:: subject_name(name)
Andre Caron9bbfcea2015-05-18 20:55:29 -0400555
556 Sets the subject's distinguished name.
557
Ian Cordascoc9682ad2015-08-01 12:11:13 -0500558 :param name: The :class:`~cryptography.x509.Name` that describes the
Ian Cordasco85fc4d52015-08-01 20:29:31 -0500559 subject.
Andre Caron9bbfcea2015-05-18 20:55:29 -0400560
Ian Cordasco0092a0b2015-07-18 21:46:41 -0500561 .. method:: public_key(public_key)
Andre Caron9bbfcea2015-05-18 20:55:29 -0400562
563 Sets the subject's public key.
564
Ian Cordasco8f571422015-08-02 11:31:08 -0500565 :param public_key: The subject's public key. This can be one of
566 :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey`,
567 :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPublicKey` or
568 :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey`
Andre Caron9bbfcea2015-05-18 20:55:29 -0400569
Ian Cordasco0092a0b2015-07-18 21:46:41 -0500570 .. method:: serial_number(serial_number)
Andre Caron9bbfcea2015-05-18 20:55:29 -0400571
572 Sets the certificate's serial number (an integer). The CA's policy
573 determines how it attributes serial numbers to certificates. The only
574 requirement is that this number uniquely identify the certificate given
575 the issuer.
576
577 :param serial_number: Integer number that will be used by the CA to
578 identify this certificate (most notably during certificate
Ian Cordasco17c89002015-08-02 21:13:59 -0500579 revocation checking). Users are encouraged to use a method of
580 generating 20 bytes of entropy, e.g., UUID4. For more information
Ian Cordascob7530a42015-08-02 22:47:06 -0500581 on secure random number generation, see :doc:`/random-numbers`.
Andre Caron9bbfcea2015-05-18 20:55:29 -0400582
Ian Cordasco0092a0b2015-07-18 21:46:41 -0500583 .. method:: not_valid_before(time)
Andre Caron9bbfcea2015-05-18 20:55:29 -0400584
585 Sets the certificate's activation time. This is the time from which
586 clients can start trusting the certificate. It may be different from
587 the time at which the certificate was created.
588
Ian Cordasco17c89002015-08-02 21:13:59 -0500589 :param time: The :class:`datetime.datetime` object (in UTC) that marks the
Andre Caron9bbfcea2015-05-18 20:55:29 -0400590 activation time for the certificate. The certificate may not be
591 trusted clients if it is used before this time.
592
Ian Cordasco0092a0b2015-07-18 21:46:41 -0500593 .. method:: not_valid_after(time)
Andre Caron9bbfcea2015-05-18 20:55:29 -0400594
595 Sets the certificate's expiration time. This is the time from which
596 clients should no longer trust the certificate. The CA's policy will
597 determine how long the certificate should remain in use.
598
Ian Cordasco17c89002015-08-02 21:13:59 -0500599 :param time: The :class:`datetime.datetime` object (in UTC) that marks the
Andre Caron9bbfcea2015-05-18 20:55:29 -0400600 expiration time for the certificate. The certificate may not be
601 trusted clients if it is used after this time.
602
Ian Cordasco17c89002015-08-02 21:13:59 -0500603 .. method:: add_extension(extension, critical)
Andre Caron9bbfcea2015-05-18 20:55:29 -0400604
605 Adds an X.509 extension to the certificate.
606
Ian Cordasco8f571422015-08-02 11:31:08 -0500607 :param extension: The extension to add to the certificate. Can be one
608 of :class:`~cryptography.x509.BasicConstraints` or
609 :class:`~cryptography.x509.SubjectAlternativeName`.
Andre Caron9bbfcea2015-05-18 20:55:29 -0400610
Ian Cordasco17c89002015-08-02 21:13:59 -0500611 :param critical: Set to ``True`` if the extension must be understood and
612 handled by whoever reads the certificate.
613
Paul Kehrer9add80e2015-08-03 17:53:14 +0100614 .. method:: sign(private_key, algorithm, backend)
Andre Caron9bbfcea2015-05-18 20:55:29 -0400615
616 Sign the certificate using the CA's private key.
617
Ian Cordascoc5e1c252015-07-31 23:33:35 -0500618 :param private_key: The
619 :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey`,
620 :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPrivateKey` or
621 :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateKey`
622 that will be used to sign the certificate.
623
Andre Caron9bbfcea2015-05-18 20:55:29 -0400624 :param algorithm: The
625 :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` that
626 will be used to generate the signature.
627
Paul Kehrer9add80e2015-08-03 17:53:14 +0100628 :param backend: Backend that will be used to build the certificate.
629 Must support the
630 :class:`~cryptography.hazmat.backends.interfaces.X509Backend`
631 interface.
632
Andre Caron9bbfcea2015-05-18 20:55:29 -0400633
Paul Kehrer5aadb9c2015-03-11 20:48:42 -0500634X.509 CSR (Certificate Signing Request) Object
635~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600636
Paul Kehrera1a1f232015-03-15 15:34:35 -0500637.. class:: CertificateSigningRequest
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600638
639 .. versionadded:: 0.9
640
641 .. method:: public_key()
642
643 :type:
644 :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey` or
645 :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPublicKey` or
646 :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey`
647
648 The public key associated with the request.
649
650 .. doctest::
651
652 >>> from cryptography.hazmat.primitives.asymmetric import rsa
Paul Kehrera1a1f232015-03-15 15:34:35 -0500653 >>> public_key = csr.public_key()
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600654 >>> isinstance(public_key, rsa.RSAPublicKey)
655 True
656
657 .. attribute:: subject
658
659 :type: :class:`Name`
660
661 The :class:`Name` of the subject.
662
663 .. attribute:: signature_hash_algorithm
664
665 :type: :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm`
666
667 Returns the
668 :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` which
669 was used in signing this request.
670
671 .. doctest::
672
673 >>> from cryptography.hazmat.primitives import hashes
Paul Kehrera1a1f232015-03-15 15:34:35 -0500674 >>> isinstance(csr.signature_hash_algorithm, hashes.SHA1)
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600675 True
676
Paul Kehrerc4e61942015-08-01 21:21:13 +0100677 .. attribute:: extensions
678
679 :type: :class:`Extensions`
680
681 The extensions encoded in the certificate signing request.
682
683 :raises cryptography.x509.DuplicateExtension: If more than one
Paul Kehrer24283d22015-08-01 21:31:19 +0100684 extension of the same type is found within the certificate signing request.
Paul Kehrerc4e61942015-08-01 21:21:13 +0100685
Paul Kehrer24283d22015-08-01 21:31:19 +0100686 :raises cryptography.x509.UnsupportedExtension: If the certificate signing request
Paul Kehrerc4e61942015-08-01 21:21:13 +0100687 contains an extension that is not supported.
688
689 :raises cryptography.x509.UnsupportedGeneralNameType: If an extension
690 contains a general name that is not supported.
691
692 :raises UnicodeError: If an extension contains IDNA encoding that is
693 invalid or not compliant with IDNA 2008.
694
695
Andre Caron476c5df2015-05-18 10:23:28 -0400696 .. method:: public_bytes(encoding)
697
Alex Gaynord0b376b2015-07-05 13:58:12 -0400698 .. versionadded:: 1.0
699
Andre Caron476c5df2015-05-18 10:23:28 -0400700 :param encoding: The
701 :class:`~cryptography.hazmat.primitives.serialization.Encoding`
702 that will be used to serialize the certificate request.
703
704 :return bytes: The data that can be written to a file or sent
705 over the network to be signed by the certificate
706 authority.
707
Erik Trauschke2dcce902015-05-14 16:12:24 -0700708X.509 Revoked Certificate Object
Erik Trauschkec5a8d172015-05-28 10:24:25 -0700709~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Erik Trauschke2dcce902015-05-14 16:12:24 -0700710
711.. class:: RevokedCertificate
712
713 .. versionadded:: 1.0
714
715 .. attribute:: serial_number
716
717 :type: :class:`int`
718
719 An integer representing the serial number of the revoked certificate.
720
Erik Trauschkedc570402015-09-24 20:24:28 -0700721 .. doctest::
722
Erik Trauschke3cdabaf2015-10-13 09:42:53 -0700723 >>> revoked_certificate = crl.revoked_certificates[0]
724 >>> revoked_certificate.serial_number
Erik Trauschkedc570402015-09-24 20:24:28 -0700725 0
726
Erik Trauschke2dcce902015-05-14 16:12:24 -0700727 .. attribute:: revocation_date
728
729 :type: :class:`datetime.datetime`
730
731 A naïve datetime representing the date this certificates was revoked.
732
Erik Trauschkedc570402015-09-24 20:24:28 -0700733 .. doctest::
734
735 >>> crl.revoked_certificates[0].revocation_date
736 datetime.datetime(2015, 1, 1, 0, 0)
737
Erik Trauschke2dcce902015-05-14 16:12:24 -0700738 .. attribute:: extensions
739
740 :type: :class:`Extensions`
741
742 The extensions encoded in the revoked certificate.
Andre Caron476c5df2015-05-18 10:23:28 -0400743
Erik Trauschkedc570402015-09-24 20:24:28 -0700744 .. doctest::
745
746 >>> for ext in crl.revoked_certificates[0].extensions:
747 ... print(ext)
748 <Extension(oid=<ObjectIdentifier(oid=2.5.29.24, name=invalidityDate)>, critical=False, value=2015-01-01 00:00:00)>
749 <Extension(oid=<ObjectIdentifier(oid=2.5.29.21, name=cRLReason)>, critical=False, value=ReasonFlags.key_compromise)>
750
Andre Caron0ef595f2015-05-18 13:53:43 -0400751X.509 CSR (Certificate Signing Request) Builder Object
752~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
753
754.. class:: CertificateSigningRequestBuilder
755
Andre Carond259ee52015-06-02 23:47:11 -0400756 .. versionadded:: 1.0
757
758 .. doctest::
759
760 >>> from cryptography import x509
761 >>> from cryptography.hazmat.backends import default_backend
762 >>> from cryptography.hazmat.primitives import hashes
763 >>> from cryptography.hazmat.primitives.asymmetric import rsa
Paul Kehrere27f6582015-08-10 18:33:38 -0500764 >>> from cryptography.x509.oid import NameOID
Andre Carond259ee52015-06-02 23:47:11 -0400765 >>> private_key = rsa.generate_private_key(
766 ... public_exponent=65537,
767 ... key_size=2048,
768 ... backend=default_backend()
769 ... )
770 >>> builder = x509.CertificateSigningRequestBuilder()
Andre Carona9a51172015-06-06 20:18:44 -0400771 >>> builder = builder.subject_name(x509.Name([
Paul Kehrere27f6582015-08-10 18:33:38 -0500772 ... x509.NameAttribute(NameOID.COMMON_NAME, u'cryptography.io'),
Andre Carond259ee52015-06-02 23:47:11 -0400773 ... ]))
Ian Cordascof06b6be2015-06-21 10:09:18 -0500774 >>> builder = builder.add_extension(
Ian Cordasco0112b022015-06-16 17:51:18 -0500775 ... x509.BasicConstraints(ca=False, path_length=None), critical=True,
Andre Caron472fd692015-06-06 20:04:44 -0400776 ... )
Andre Carond259ee52015-06-02 23:47:11 -0400777 >>> request = builder.sign(
Alex Gaynorde9e5842015-06-26 20:11:23 -0400778 ... private_key, hashes.SHA256(), default_backend()
Andre Carond259ee52015-06-02 23:47:11 -0400779 ... )
780 >>> isinstance(request, x509.CertificateSigningRequest)
781 True
782
Andre Carona9a51172015-06-06 20:18:44 -0400783 .. method:: subject_name(name)
Andre Caron0ef595f2015-05-18 13:53:43 -0400784
Andre Caron341ff852015-06-06 20:14:31 -0400785 :param name: The :class:`~cryptography.x509.Name` of the certificate
786 subject.
787 :returns: A new
788 :class:`~cryptography.x509.CertificateSigningRequestBuilder`.
Andre Caron0ef595f2015-05-18 13:53:43 -0400789
Ian Cordascof06b6be2015-06-21 10:09:18 -0500790 .. method:: add_extension(extension, critical)
Andre Caron0ef595f2015-05-18 13:53:43 -0400791
Andre Caron341ff852015-06-06 20:14:31 -0400792 :param extension: The :class:`~cryptography.x509.Extension` to add to
793 the request.
Andre Caron472fd692015-06-06 20:04:44 -0400794 :param critical: Set to `True` if the extension must be understood and
795 handled by whoever reads the certificate.
Andre Caron341ff852015-06-06 20:14:31 -0400796 :returns: A new
797 :class:`~cryptography.x509.CertificateSigningRequestBuilder`.
Andre Caron0ef595f2015-05-18 13:53:43 -0400798
Alex Gaynorb3b0fbe2015-06-26 19:57:18 -0400799 .. method:: sign(private_key, algorithm, backend)
Andre Caron0ef595f2015-05-18 13:53:43 -0400800
801 :param backend: Backend that will be used to sign the request.
802 Must support the
803 :class:`~cryptography.hazmat.backends.interfaces.X509Backend`
804 interface.
805
806 :param private_key: The
Andre Caron24f9bf42015-06-06 20:14:54 -0400807 :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey`,
808 :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPrivateKey` or
809 :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateKey`
Andre Caron0ef595f2015-05-18 13:53:43 -0400810 that will be used to sign the request. When the request is
811 signed by a certificate authority, the private key's associated
812 public key will be stored in the resulting certificate.
813
814 :param algorithm: The
815 :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm`
816 that will be used to generate the request signature.
817
Andre Caron341ff852015-06-06 20:14:31 -0400818 :returns: A new
819 :class:`~cryptography.x509.CertificateSigningRequest`.
Andre Caron0ef595f2015-05-18 13:53:43 -0400820
821
Paul Kehrer719d5362015-01-01 20:03:52 -0600822.. class:: Name
823
824 .. versionadded:: 0.8
825
Paul Kehrer53d8d492015-02-13 18:47:30 -0600826 An X509 Name is an ordered list of attributes. The object is iterable to
Paul Kehrerd21596e2015-02-14 09:17:26 -0600827 get every attribute or you can use :meth:`Name.get_attributes_for_oid` to
Paul Kehrer719d5362015-01-01 20:03:52 -0600828 obtain the specific type you want. Names are sometimes represented as a
Paul Kehrer53d8d492015-02-13 18:47:30 -0600829 slash or comma delimited string (e.g. ``/CN=mydomain.com/O=My Org/C=US`` or
830 ``CN=mydomain.com, O=My Org, C=US``).
Paul Kehrer719d5362015-01-01 20:03:52 -0600831
Paul Kehrer53d8d492015-02-13 18:47:30 -0600832 .. doctest::
Paul Kehrer719d5362015-01-01 20:03:52 -0600833
Paul Kehrer8b21a4a2015-02-14 07:56:36 -0600834 >>> len(cert.subject)
Paul Kehrer53d8d492015-02-13 18:47:30 -0600835 3
Paul Kehrer8b21a4a2015-02-14 07:56:36 -0600836 >>> for attribute in cert.subject:
837 ... print(attribute)
838 <NameAttribute(oid=<ObjectIdentifier(oid=2.5.4.6, name=countryName)>, value=u'US')>
839 <NameAttribute(oid=<ObjectIdentifier(oid=2.5.4.10, name=organizationName)>, value=u'Test Certificates 2011')>
840 <NameAttribute(oid=<ObjectIdentifier(oid=2.5.4.3, name=commonName)>, value=u'Good CA')>
Paul Kehrer719d5362015-01-01 20:03:52 -0600841
Paul Kehrere901d642015-02-11 18:50:58 -0600842 .. method:: get_attributes_for_oid(oid)
Paul Kehrer719d5362015-01-01 20:03:52 -0600843
Paul Kehrere901d642015-02-11 18:50:58 -0600844 :param oid: An :class:`ObjectIdentifier` instance.
Paul Kehrer719d5362015-01-01 20:03:52 -0600845
Paul Kehrere901d642015-02-11 18:50:58 -0600846 :returns: A list of :class:`NameAttribute` instances that match the
847 OID provided. If nothing matches an empty list will be returned.
Paul Kehrer719d5362015-01-01 20:03:52 -0600848
849 .. doctest::
850
Paul Kehrere27f6582015-08-10 18:33:38 -0500851 >>> cert.subject.get_attributes_for_oid(NameOID.COMMON_NAME)
Paul Kehrere901d642015-02-11 18:50:58 -0600852 [<NameAttribute(oid=<ObjectIdentifier(oid=2.5.4.3, name=commonName)>, value=u'Good CA')>]
Paul Kehrerb2de9482014-12-11 14:54:48 -0600853
Paul Kehrere76cd272014-12-14 19:00:51 -0600854.. class:: Version
Paul Kehrer016e08a2014-11-26 09:41:18 -1000855
856 .. versionadded:: 0.7
857
858 An enumeration for X.509 versions.
859
860 .. attribute:: v1
861
862 For version 1 X.509 certificates.
863
864 .. attribute:: v3
865
866 For version 3 X.509 certificates.
867
Paul Kehrer806bfb22015-02-02 17:05:24 -0600868.. class:: NameAttribute
Paul Kehrer912d3fb2015-01-29 11:19:22 -0600869
870 .. versionadded:: 0.8
871
Paul Kehrer834d22f2015-02-06 11:01:07 -0600872 An X.509 name consists of a list of NameAttribute instances.
Paul Kehrer5b0a8d62015-01-30 20:05:55 -0600873
Paul Kehrer912d3fb2015-01-29 11:19:22 -0600874 .. attribute:: oid
875
876 :type: :class:`ObjectIdentifier`
877
878 The attribute OID.
879
880 .. attribute:: value
881
Paul Kehrerd5852cb2015-01-30 08:25:23 -0600882 :type: :term:`text`
Paul Kehrer912d3fb2015-01-29 11:19:22 -0600883
884 The value of the attribute.
885
886.. class:: ObjectIdentifier
887
888 .. versionadded:: 0.8
889
Paul Kehrer5b0a8d62015-01-30 20:05:55 -0600890 Object identifiers (frequently seen abbreviated as OID) identify the type
Paul Kehrer806bfb22015-02-02 17:05:24 -0600891 of a value (see: :class:`NameAttribute`).
Paul Kehrer5b0a8d62015-01-30 20:05:55 -0600892
Paul Kehrerd44f9a62015-02-04 14:47:34 -0600893 .. attribute:: dotted_string
Paul Kehrer912d3fb2015-01-29 11:19:22 -0600894
895 :type: :class:`str`
896
Paul Kehrerfedf4f42015-02-06 11:22:07 -0600897 The dotted string value of the OID (e.g. ``"2.5.4.3"``)
Paul Kehrer912d3fb2015-01-29 11:19:22 -0600898
Paul Kehrer31bdf792015-03-25 14:11:00 -0500899.. _general_name_classes:
900
901General Name Classes
902~~~~~~~~~~~~~~~~~~~~
903
904.. class:: GeneralName
905
906 .. versionadded:: 0.9
907
908 This is the generic interface that all the following classes are registered
909 against.
910
911.. class:: RFC822Name
912
913 .. versionadded:: 0.9
914
915 This corresponds to an email address. For example, ``user@example.com``.
916
917 .. attribute:: value
918
919 :type: :term:`text`
920
921.. class:: DNSName
922
923 .. versionadded:: 0.9
924
925 This corresponds to a domain name. For example, ``cryptography.io``.
926
927 .. attribute:: value
928
929 :type: :term:`text`
930
931.. class:: DirectoryName
932
933 .. versionadded:: 0.9
934
935 This corresponds to a directory name.
936
937 .. attribute:: value
938
939 :type: :class:`Name`
940
941.. class:: UniformResourceIdentifier
942
943 .. versionadded:: 0.9
944
945 This corresponds to a uniform resource identifier. For example,
Paul Kehrerb8ef82e2015-04-22 16:04:24 -0500946 ``https://cryptography.io``. The URI is parsed and IDNA decoded (see
947 :rfc:`5895`).
948
949 .. note::
950
951 URIs that do not contain ``://`` in them will not be decoded.
Paul Kehrer31bdf792015-03-25 14:11:00 -0500952
953 .. attribute:: value
954
955 :type: :term:`text`
956
957.. class:: IPAddress
958
959 .. versionadded:: 0.9
960
961 This corresponds to an IP address.
962
963 .. attribute:: value
964
Paul Kehrereb177932015-05-17 18:33:33 -0700965 :type: :class:`~ipaddress.IPv4Address`,
966 :class:`~ipaddress.IPv6Address`, :class:`~ipaddress.IPv4Network`,
967 or :class:`~ipaddress.IPv6Network`.
Paul Kehrer31bdf792015-03-25 14:11:00 -0500968
969.. class:: RegisteredID
970
971 .. versionadded:: 0.9
972
973 This corresponds to a registered ID.
974
975 .. attribute:: value
976
977 :type: :class:`ObjectIdentifier`
978
Joshua Tauberer2ee5e3c2015-07-04 20:09:46 +0000979.. class:: OtherName
980
981 .. versionadded:: 1.0
982
Joshua Tauberer18b6fc82015-07-05 21:44:51 +0000983 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 +0000984
985 .. attribute:: type_id
986
987 :type: :class:`ObjectIdentifier`
988
989 .. attribute:: value
990
991 :type: `bytes`
992
Paul Kehrer8cf26422015-03-21 09:50:24 -0500993X.509 Extensions
994~~~~~~~~~~~~~~~~
995
Paul Kehrerfbb7ac82015-03-16 19:26:29 -0500996.. class:: Extensions
997
998 .. versionadded:: 0.9
999
1000 An X.509 Extensions instance is an ordered list of extensions. The object
1001 is iterable to get every extension.
1002
Paul Kehrerfa56a232015-03-17 13:14:03 -05001003 .. method:: get_extension_for_oid(oid)
1004
1005 :param oid: An :class:`ObjectIdentifier` instance.
1006
1007 :returns: An instance of the extension class.
1008
1009 :raises cryptography.x509.ExtensionNotFound: If the certificate does
1010 not have the extension requested.
1011
Paul Kehrerfa56a232015-03-17 13:14:03 -05001012 .. doctest::
1013
Paul Kehrere27f6582015-08-10 18:33:38 -05001014 >>> from cryptography.x509.oid import ExtensionOID
1015 >>> cert.extensions.get_extension_for_oid(ExtensionOID.BASIC_CONSTRAINTS)
Paul Kehrerfa56a232015-03-17 13:14:03 -05001016 <Extension(oid=<ObjectIdentifier(oid=2.5.29.19, name=basicConstraints)>, critical=True, value=<BasicConstraints(ca=True, path_length=None)>)>
1017
Phoebe Queen019b7f82015-08-12 03:52:03 +01001018 .. method:: get_extension_for_class(extclass)
1019
Phoebe Queen6a603eb2015-08-12 14:14:49 +01001020 .. versionadded:: 1.1
1021
Phoebe Queen019b7f82015-08-12 03:52:03 +01001022 :param extclass: An extension class.
1023
1024 :returns: An instance of the extension class.
1025
1026 :raises cryptography.x509.ExtensionNotFound: If the certificate does
1027 not have the extension requested.
1028
1029 .. doctest::
1030
1031 >>> from cryptography import x509
1032 >>> cert.extensions.get_extension_for_class(x509.BasicConstraints)
1033 <Extension(oid=<ObjectIdentifier(oid=2.5.29.19, name=basicConstraints)>, critical=True, value=<BasicConstraints(ca=True, path_length=None)>)>
1034
Paul Kehrer8cf26422015-03-21 09:50:24 -05001035.. class:: Extension
1036
1037 .. versionadded:: 0.9
1038
Paul Kehrer85894662015-03-22 13:19:31 -05001039 .. attribute:: oid
1040
1041 :type: :class:`ObjectIdentifier`
1042
Paul Kehrere27f6582015-08-10 18:33:38 -05001043 One of the :class:`~cryptography.x509.oid.ExtensionOID` OIDs.
Paul Kehrer8cf26422015-03-21 09:50:24 -05001044
1045 .. attribute:: critical
1046
1047 :type: bool
1048
Paul Kehrer58b75692015-03-22 23:24:58 -05001049 Determines whether a given extension is critical or not. :rfc:`5280`
1050 requires that "A certificate-using system MUST reject the certificate
1051 if it encounters a critical extension it does not recognize or a
1052 critical extension that contains information that it cannot process".
Paul Kehrer8cf26422015-03-21 09:50:24 -05001053
Paul Kehrer85894662015-03-22 13:19:31 -05001054 .. attribute:: value
1055
1056 Returns an instance of the extension type corresponding to the OID.
1057
Paul Kehrer14f0bd02015-08-06 11:55:18 +01001058.. class:: ExtensionType
1059
1060 .. versionadded:: 1.0
1061
1062 This is the interface against which all the following extension types are
1063 registered.
1064
Paul Kehrercecbbba2015-03-30 14:58:38 -05001065.. class:: KeyUsage
1066
1067 .. versionadded:: 0.9
1068
1069 The key usage extension defines the purpose of the key contained in the
1070 certificate. The usage restriction might be employed when a key that could
Paul Kehrerb33de932015-08-06 23:41:05 +01001071 be used for more than one operation is to be restricted.
Paul Kehrercecbbba2015-03-30 14:58:38 -05001072
Paul Kehrer822f3d32015-08-06 11:47:32 +01001073 .. attribute:: oid
1074
1075 .. versionadded:: 1.0
1076
1077 :type: :class:`ObjectIdentifier`
1078
Paul Kehrere27f6582015-08-10 18:33:38 -05001079 Returns :attr:`~cryptography.x509.oid.ExtensionOID.KEY_USAGE`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001080
Paul Kehrercecbbba2015-03-30 14:58:38 -05001081 .. attribute:: digital_signature
1082
1083 :type: bool
1084
Paul Kehrer738407b2015-04-01 22:39:02 -05001085 This purpose is set to true when the subject public key is used for verifying
Paul Kehrercecbbba2015-03-30 14:58:38 -05001086 digital signatures, other than signatures on certificates
1087 (``key_cert_sign``) and CRLs (``crl_sign``).
1088
1089 .. attribute:: content_commitment
1090
1091 :type: bool
1092
Paul Kehrer738407b2015-04-01 22:39:02 -05001093 This purpose is set to true when the subject public key is used for verifying
Paul Kehrercecbbba2015-03-30 14:58:38 -05001094 digital signatures, other than signatures on certificates
1095 (``key_cert_sign``) and CRLs (``crl_sign``). It is used to provide a
1096 non-repudiation service that protects against the signing entity
1097 falsely denying some action. In the case of later conflict, a
1098 reliable third party may determine the authenticity of the signed
1099 data. This was called ``non_repudiation`` in older revisions of the
1100 X.509 specification.
1101
1102 .. attribute:: key_encipherment
1103
1104 :type: bool
1105
Paul Kehrer738407b2015-04-01 22:39:02 -05001106 This purpose is set to true when the subject public key is used for
1107 enciphering private or secret keys.
Paul Kehrercecbbba2015-03-30 14:58:38 -05001108
1109 .. attribute:: data_encipherment
1110
1111 :type: bool
1112
Paul Kehrer738407b2015-04-01 22:39:02 -05001113 This purpose is set to true when the subject public key is used for
1114 directly enciphering raw user data without the use of an intermediate
1115 symmetric cipher.
Paul Kehrercecbbba2015-03-30 14:58:38 -05001116
1117 .. attribute:: key_agreement
1118
1119 :type: bool
1120
Paul Kehrer738407b2015-04-01 22:39:02 -05001121 This purpose is set to true when the subject public key is used for key
1122 agreement. For example, when a Diffie-Hellman key is to be used for
1123 key management, then this purpose is set to true.
Paul Kehrercecbbba2015-03-30 14:58:38 -05001124
1125 .. attribute:: key_cert_sign
1126
1127 :type: bool
1128
Paul Kehrer738407b2015-04-01 22:39:02 -05001129 This purpose is set to true when the subject public key is used for
1130 verifying signatures on public key certificates. If this purpose is set
1131 to true then ``ca`` must be true in the :class:`BasicConstraints`
1132 extension.
Paul Kehrercecbbba2015-03-30 14:58:38 -05001133
1134 .. attribute:: crl_sign
1135
1136 :type: bool
1137
Paul Kehrer738407b2015-04-01 22:39:02 -05001138 This purpose is set to true when the subject public key is used for
1139 verifying signatures on certificate revocation lists.
Paul Kehrercecbbba2015-03-30 14:58:38 -05001140
1141 .. attribute:: encipher_only
1142
1143 :type: bool
1144
Paul Kehrer738407b2015-04-01 22:39:02 -05001145 When this purposes is set to true and the ``key_agreement`` purpose is
1146 also set, the subject public key may be used only for enciphering data
1147 while performing key agreement.
Paul Kehrercecbbba2015-03-30 14:58:38 -05001148
1149 :raises ValueError: This is raised if accessed when ``key_agreement``
1150 is false.
1151
1152 .. attribute:: decipher_only
1153
1154 :type: bool
1155
Paul Kehrer738407b2015-04-01 22:39:02 -05001156 When this purposes is set to true and the ``key_agreement`` purpose is
1157 also set, the subject public key may be used only for deciphering data
1158 while performing key agreement.
Paul Kehrercecbbba2015-03-30 14:58:38 -05001159
1160 :raises ValueError: This is raised if accessed when ``key_agreement``
1161 is false.
1162
1163
Paul Kehrer8cf26422015-03-21 09:50:24 -05001164.. class:: BasicConstraints
1165
1166 .. versionadded:: 0.9
1167
Paul Kehrer85894662015-03-22 13:19:31 -05001168 Basic constraints is an X.509 extension type that defines whether a given
Paul Kehrer8cf26422015-03-21 09:50:24 -05001169 certificate is allowed to sign additional certificates and what path
Paul Kehrerb33de932015-08-06 23:41:05 +01001170 length restrictions may exist.
Paul Kehrer8cf26422015-03-21 09:50:24 -05001171
Paul Kehrer822f3d32015-08-06 11:47:32 +01001172 .. attribute:: oid
1173
1174 .. versionadded:: 1.0
1175
1176 :type: :class:`ObjectIdentifier`
1177
Paul Kehrere27f6582015-08-10 18:33:38 -05001178 Returns :attr:`~cryptography.x509.oid.ExtensionOID.BASIC_CONSTRAINTS`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001179
Paul Kehrer8cf26422015-03-21 09:50:24 -05001180 .. attribute:: ca
1181
1182 :type: bool
1183
1184 Whether the certificate can sign certificates.
1185
1186 .. attribute:: path_length
1187
Paul Kehrerfd1444c2015-03-21 19:47:05 -05001188 :type: int or None
Paul Kehrer8cf26422015-03-21 09:50:24 -05001189
1190 The maximum path length for certificates subordinate to this
1191 certificate. This attribute only has meaning if ``ca`` is true.
1192 If ``ca`` is true then a path length of None means there's no
1193 restriction on the number of subordinate CAs in the certificate chain.
Alex Gaynor99c5f152015-05-03 10:01:04 -04001194 If it is zero or greater then it defines the maximum length for a
1195 subordinate CA's certificate chain. For example, a ``path_length`` of 1
1196 means the certificate can sign a subordinate CA, but the subordinate CA
1197 is not allowed to create subordinates with ``ca`` set to true.
Paul Kehrer8cf26422015-03-21 09:50:24 -05001198
Paul Kehrerffa2a152015-03-31 08:18:25 -05001199.. class:: ExtendedKeyUsage
1200
1201 .. versionadded:: 0.9
1202
1203 This extension indicates one or more purposes for which the certified
1204 public key may be used, in addition to or in place of the basic
1205 purposes indicated in the key usage extension. The object is
Paul Kehrere27f6582015-08-10 18:33:38 -05001206 iterable to obtain the list of
1207 :class:`~cryptography.x509.oid.ExtendedKeyUsageOID` OIDs present.
Paul Kehrerffa2a152015-03-31 08:18:25 -05001208
Paul Kehrer822f3d32015-08-06 11:47:32 +01001209 .. attribute:: oid
1210
1211 .. versionadded:: 1.0
1212
1213 :type: :class:`ObjectIdentifier`
1214
Paul Kehrere27f6582015-08-10 18:33:38 -05001215 Returns :attr:`~cryptography.x509.oid.ExtensionOID.EXTENDED_KEY_USAGE`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001216
1217
Paul Kehrer4a1038e2015-05-18 10:28:31 -07001218.. class:: OCSPNoCheck
1219
Paul Kehrer506a2152015-05-26 08:01:18 -05001220 .. versionadded:: 1.0
Paul Kehrer4a1038e2015-05-18 10:28:31 -07001221
1222 This presence of this extension indicates that an OCSP client can trust a
1223 responder for the lifetime of the responder's certificate. CAs issuing
1224 such a certificate should realize that a compromise of the responder's key
1225 is as serious as the compromise of a CA key used to sign CRLs, at least for
1226 the validity period of this certificate. CA's may choose to issue this type
1227 of certificate with a very short lifetime and renew it frequently. This
1228 extension is only relevant when the certificate is an authorized OCSP
1229 responder.
1230
Paul Kehrer822f3d32015-08-06 11:47:32 +01001231 .. attribute:: oid
1232
1233 .. versionadded:: 1.0
1234
1235 :type: :class:`ObjectIdentifier`
1236
Paul Kehrere27f6582015-08-10 18:33:38 -05001237 Returns :attr:`~cryptography.x509.oid.ExtensionOID.OCSP_NO_CHECK`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001238
Paul Kehrere0017be2015-05-17 20:39:40 -06001239.. class:: NameConstraints
1240
1241 .. versionadded:: 1.0
1242
1243 The name constraints extension, which only has meaning in a CA certificate,
1244 defines a name space within which all subject names in certificates issued
1245 beneath the CA certificate must (or must not) be in. For specific details
1246 on the way this extension should be processed see :rfc:`5280`.
1247
Paul Kehrer822f3d32015-08-06 11:47:32 +01001248 .. attribute:: oid
1249
1250 .. versionadded:: 1.0
1251
1252 :type: :class:`ObjectIdentifier`
1253
Paul Kehrere27f6582015-08-10 18:33:38 -05001254 Returns :attr:`~cryptography.x509.oid.ExtensionOID.NAME_CONSTRAINTS`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001255
Paul Kehrere0017be2015-05-17 20:39:40 -06001256 .. attribute:: permitted_subtrees
1257
1258 :type: list of :class:`GeneralName` objects or None
1259
1260 The set of permitted name patterns. If a name matches this and an
1261 element in ``excluded_subtrees`` it is invalid. At least one of
1262 ``permitted_subtrees`` and ``excluded_subtrees`` will be non-None.
1263
1264 .. attribute:: excluded_subtrees
1265
1266 :type: list of :class:`GeneralName` objects or None
1267
1268 Any name matching a restriction in the ``excluded_subtrees`` field is
1269 invalid regardless of information appearing in the
1270 ``permitted_subtrees``. At least one of ``permitted_subtrees`` and
1271 ``excluded_subtrees`` will be non-None.
1272
Paul Kehrer2eb4ed92015-04-11 15:33:45 -04001273.. class:: AuthorityKeyIdentifier
1274
1275 .. versionadded:: 0.9
1276
1277 The authority key identifier extension provides a means of identifying the
1278 public key corresponding to the private key used to sign a certificate.
Paul Kehrer8c8cd722015-04-19 09:15:04 -05001279 This extension is typically used to assist in determining the appropriate
1280 certificate chain. For more information about generation and use of this
1281 extension see `RFC 5280 section 4.2.1.1`_.
Paul Kehrer2eb4ed92015-04-11 15:33:45 -04001282
Paul Kehrer822f3d32015-08-06 11:47:32 +01001283 .. attribute:: oid
1284
1285 .. versionadded:: 1.0
1286
1287 :type: :class:`ObjectIdentifier`
1288
Paul Kehrere27f6582015-08-10 18:33:38 -05001289 Returns
1290 :attr:`~cryptography.x509.oid.ExtensionOID.AUTHORITY_KEY_IDENTIFIER`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001291
Paul Kehrer2eb4ed92015-04-11 15:33:45 -04001292 .. attribute:: key_identifier
1293
1294 :type: bytes
1295
Paul Kehrer9104b1d2015-04-18 09:23:44 -05001296 A value derived from the public key used to verify the certificate's
Paul Kehrer8c8cd722015-04-19 09:15:04 -05001297 signature.
Paul Kehrer9104b1d2015-04-18 09:23:44 -05001298
Paul Kehrer2eb4ed92015-04-11 15:33:45 -04001299 .. attribute:: authority_cert_issuer
1300
1301 :type: :class:`Name` or None
1302
Paul Kehrer9104b1d2015-04-18 09:23:44 -05001303 The :class:`Name` of the issuer's issuer.
1304
Paul Kehrer2eb4ed92015-04-11 15:33:45 -04001305 .. attribute:: authority_cert_serial_number
1306
1307 :type: int or None
1308
Paul Kehrer9104b1d2015-04-18 09:23:44 -05001309 The serial number of the issuer's issuer.
1310
Paul Kehrer253929a2015-08-05 17:30:39 +01001311 .. classmethod:: from_issuer_public_key(public_key)
1312
1313 .. versionadded:: 1.0
1314
1315 Creates a new AuthorityKeyIdentifier instance using the public key
1316 provided to generate the appropriate digest. This should be the
Paul Kehrer26ac47f2015-08-08 15:20:52 -05001317 **issuer's public key**. The resulting object will contain
1318 :attr:`~cryptography.x509.AuthorityKeyIdentifier.key_identifier`, but
1319 :attr:`~cryptography.x509.AuthorityKeyIdentifier.authority_cert_issuer`
1320 and
1321 :attr:`~cryptography.x509.AuthorityKeyIdentifier.authority_cert_serial_number`
1322 will be None.
1323 The generated ``key_identifier`` is the SHA1 hash of the ``subjectPublicKey``
1324 ASN.1 bit string. This is the first recommendation in :rfc:`5280`
Paul Kehrer253929a2015-08-05 17:30:39 +01001325 section 4.2.1.2.
1326
Paul Kehrercc671822015-08-08 15:41:54 -05001327 :param public_key: One of
1328 :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey`
1329 ,
1330 :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPublicKey`
1331 , or
1332 :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey`.
Paul Kehrer253929a2015-08-05 17:30:39 +01001333
1334 .. doctest::
1335
1336 >>> from cryptography import x509
1337 >>> from cryptography.hazmat.backends import default_backend
Paul Kehrercc671822015-08-08 15:41:54 -05001338 >>> issuer_cert = x509.load_pem_x509_certificate(pem_data, default_backend())
1339 >>> x509.AuthorityKeyIdentifier.from_issuer_public_key(issuer_cert.public_key())
Paul Kehrer253929a2015-08-05 17:30:39 +01001340 <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)>
1341
Paul Kehrer1eb82a62015-03-31 20:00:33 -05001342.. class:: SubjectKeyIdentifier
1343
1344 .. versionadded:: 0.9
1345
1346 The subject key identifier extension provides a means of identifying
1347 certificates that contain a particular public key.
1348
Paul Kehrer822f3d32015-08-06 11:47:32 +01001349 .. attribute:: oid
1350
1351 .. versionadded:: 1.0
1352
1353 :type: :class:`ObjectIdentifier`
1354
Paul Kehrere27f6582015-08-10 18:33:38 -05001355 Returns
1356 :attr:`~cryptography.x509.oid.ExtensionOID.SUBJECT_KEY_IDENTIFIER`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001357
Paul Kehrer1eb82a62015-03-31 20:00:33 -05001358 .. attribute:: digest
1359
1360 :type: bytes
1361
1362 The binary value of the identifier.
1363
Paul Kehrerd4a7f062015-08-05 18:32:18 +01001364 .. classmethod:: from_public_key(public_key)
Paul Kehrerf22f6122015-08-05 12:57:13 +01001365
1366 .. versionadded:: 1.0
1367
1368 Creates a new SubjectKeyIdentifier instance using the public key
1369 provided to generate the appropriate digest. This should be the public
Paul Kehrereb9ec002015-08-08 10:03:02 -05001370 key that is in the certificate. The generated digest is the SHA1 hash
1371 of the ``subjectPublicKey`` ASN.1 bit string. This is the first
1372 recommendation in :rfc:`5280` section 4.2.1.2.
Paul Kehrerf22f6122015-08-05 12:57:13 +01001373
1374 :param public_key: One of
1375 :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey`
1376 ,
1377 :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPublicKey`
1378 , or
1379 :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey`.
1380
Paul Kehrer253929a2015-08-05 17:30:39 +01001381 .. doctest::
1382
1383 >>> from cryptography import x509
1384 >>> from cryptography.hazmat.backends import default_backend
Paul Kehrercc671822015-08-08 15:41:54 -05001385 >>> csr = x509.load_pem_x509_csr(pem_req_data, default_backend())
1386 >>> x509.SubjectKeyIdentifier.from_public_key(csr.public_key())
1387 <SubjectKeyIdentifier(digest='\xdb\xaa\xf0\x06\x11\xdbD\xfe\xbf\x93\x03\x8av\x88WP7\xa6\x91\xf7')>
Paul Kehrer253929a2015-08-05 17:30:39 +01001388
Paul Kehrer31bdf792015-03-25 14:11:00 -05001389.. class:: SubjectAlternativeName
1390
1391 .. versionadded:: 0.9
1392
1393 Subject alternative name is an X.509 extension that provides a list of
1394 :ref:`general name <general_name_classes>` instances that provide a set
1395 of identities for which the certificate is valid. The object is iterable to
1396 get every element.
1397
Paul Kehrer822f3d32015-08-06 11:47:32 +01001398 .. attribute:: oid
1399
1400 .. versionadded:: 1.0
1401
1402 :type: :class:`ObjectIdentifier`
1403
Paul Kehrere27f6582015-08-10 18:33:38 -05001404 Returns
1405 :attr:`~cryptography.x509.oid.ExtensionOID.SUBJECT_ALTERNATIVE_NAME`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001406
Paul Kehrer31bdf792015-03-25 14:11:00 -05001407 .. method:: get_values_for_type(type)
1408
1409 :param type: A :class:`GeneralName` provider. This is one of the
1410 :ref:`general name classes <general_name_classes>`.
1411
1412 :returns: A list of values extracted from the matched general names.
Joshua Taubererd2afad32015-07-06 22:37:53 +00001413 The type of the returned values depends on the :class:`GeneralName`.
Paul Kehrer31bdf792015-03-25 14:11:00 -05001414
Paul Kehrer93ae8052015-05-02 23:18:09 -05001415 .. doctest::
1416
1417 >>> from cryptography import x509
1418 >>> from cryptography.hazmat.backends import default_backend
1419 >>> from cryptography.hazmat.primitives import hashes
1420 >>> cert = x509.load_pem_x509_certificate(cryptography_cert_pem, default_backend())
Paul Kehrerd0cd5072015-05-02 23:27:00 -05001421 >>> # Get the subjectAltName extension from the certificate
Paul Kehrere27f6582015-08-10 18:33:38 -05001422 >>> ext = cert.extensions.get_extension_for_oid(ExtensionOID.SUBJECT_ALTERNATIVE_NAME)
Paul Kehrerd0cd5072015-05-02 23:27:00 -05001423 >>> # Get the dNSName entries from the SAN extension
1424 >>> ext.value.get_values_for_type(x509.DNSName)
Paul Kehrer93ae8052015-05-02 23:18:09 -05001425 [u'www.cryptography.io', u'cryptography.io']
1426
Paul Kehrer8cf26422015-03-21 09:50:24 -05001427
Paul Kehrer99125c92015-06-07 18:37:10 -05001428.. class:: IssuerAlternativeName
1429
1430 .. versionadded:: 1.0
1431
1432 Issuer alternative name is an X.509 extension that provides a list of
1433 :ref:`general name <general_name_classes>` instances that provide a set
1434 of identities for the certificate issuer. The object is iterable to
1435 get every element.
1436
Paul Kehrer822f3d32015-08-06 11:47:32 +01001437 .. attribute:: oid
1438
1439 .. versionadded:: 1.0
1440
1441 :type: :class:`ObjectIdentifier`
1442
Paul Kehrere27f6582015-08-10 18:33:38 -05001443 Returns
1444 :attr:`~cryptography.x509.oid.ExtensionOID.ISSUER_ALTERNATIVE_NAME`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001445
Paul Kehrer99125c92015-06-07 18:37:10 -05001446 .. method:: get_values_for_type(type)
1447
1448 :param type: A :class:`GeneralName` provider. This is one of the
1449 :ref:`general name classes <general_name_classes>`.
1450
1451 :returns: A list of values extracted from the matched general names.
1452
1453
Paul Kehrer3e6d5582015-05-02 21:57:56 -05001454.. class:: AuthorityInformationAccess
1455
1456 .. versionadded:: 0.9
1457
1458 The authority information access extension indicates how to access
1459 information and services for the issuer of the certificate in which
1460 the extension appears. Information and services may include online
1461 validation services (such as OCSP) and issuer data. It is an iterable,
Paul Kehrere27f6582015-08-10 18:33:38 -05001462 containing one or more :class:`~cryptography.x509.AccessDescription`
1463 instances.
Paul Kehrer3e6d5582015-05-02 21:57:56 -05001464
Paul Kehrer822f3d32015-08-06 11:47:32 +01001465 .. attribute:: oid
1466
1467 .. versionadded:: 1.0
1468
1469 :type: :class:`ObjectIdentifier`
1470
Paul Kehrere27f6582015-08-10 18:33:38 -05001471 Returns
1472 :attr:`~cryptography.x509.oid.ExtensionOID.AUTHORITY_INFORMATION_ACCESS`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001473
Paul Kehrer3e6d5582015-05-02 21:57:56 -05001474
1475.. class:: AccessDescription
1476
Paul Kehrer5a485522015-05-06 00:29:12 -05001477 .. versionadded:: 0.9
1478
Paul Kehrer3e6d5582015-05-02 21:57:56 -05001479 .. attribute:: access_method
1480
1481 :type: :class:`ObjectIdentifier`
1482
Paul Kehrerf506bca2015-05-02 22:31:47 -05001483 The access method defines what the ``access_location`` means. It must
Paul Kehrere27f6582015-08-10 18:33:38 -05001484 be either
1485 :attr:`~cryptography.x509.oid.AuthorityInformationAccessOID.OCSP` or
1486 :attr:`~cryptography.x509.oid.AuthorityInformationAccessOID.CA_ISSUERS`.
1487 If it is
1488 :attr:`~cryptography.x509.oid.AuthorityInformationAccessOID.OCSP`
1489 the access location will be where to obtain OCSP
1490 information for the certificate. If it is
1491 :attr:`~cryptography.x509.oid.AuthorityInformationAccessOID.CA_ISSUERS`
1492 the access location will provide additional information about the
1493 issuing certificate.
Paul Kehrer3e6d5582015-05-02 21:57:56 -05001494
1495 .. attribute:: access_location
1496
1497 :type: :class:`GeneralName`
1498
Paul Kehrerf506bca2015-05-02 22:31:47 -05001499 Where to access the information defined by the access method.
1500
Paul Kehrer5a485522015-05-06 00:29:12 -05001501.. class:: CRLDistributionPoints
1502
1503 .. versionadded:: 0.9
1504
1505 The CRL distribution points extension identifies how CRL information is
1506 obtained. It is an iterable, containing one or more
1507 :class:`DistributionPoint` instances.
1508
Paul Kehrer822f3d32015-08-06 11:47:32 +01001509 .. attribute:: oid
1510
1511 .. versionadded:: 1.0
1512
1513 :type: :class:`ObjectIdentifier`
1514
Paul Kehrere27f6582015-08-10 18:33:38 -05001515 Returns
1516 :attr:`~cryptography.x509.oid.ExtensionOID.CRL_DISTRIBUTION_POINTS`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001517
Paul Kehrer5a485522015-05-06 00:29:12 -05001518.. class:: DistributionPoint
1519
1520 .. versionadded:: 0.9
1521
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05001522 .. attribute:: full_name
Paul Kehrer5a485522015-05-06 00:29:12 -05001523
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05001524 :type: list of :class:`GeneralName` instances or None
Paul Kehrer5a485522015-05-06 00:29:12 -05001525
Paul Kehrerf2c072b2015-05-09 17:04:28 -05001526 This field describes methods to retrieve the CRL. At most one of
1527 ``full_name`` or ``relative_name`` will be non-None.
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05001528
1529 .. attribute:: relative_name
1530
1531 :type: :class:`Name` or None
1532
1533 This field describes methods to retrieve the CRL relative to the CRL
Paul Kehrerf2c072b2015-05-09 17:04:28 -05001534 issuer. At most one of ``full_name`` or ``relative_name`` will be
1535 non-None.
Paul Kehrer5a485522015-05-06 00:29:12 -05001536
1537 .. attribute:: crl_issuer
1538
1539 :type: list of :class:`GeneralName` instances or None
1540
1541 Information about the issuer of the CRL.
1542
1543 .. attribute:: reasons
1544
Paul Kehrer3fd02602015-05-09 19:46:13 -05001545 :type: frozenset of :class:`ReasonFlags` or None
Paul Kehrer5a485522015-05-06 00:29:12 -05001546
1547 The reasons a given distribution point may be used for when performing
1548 revocation checks.
1549
1550.. class:: ReasonFlags
1551
1552 .. versionadded:: 0.9
1553
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05001554 An enumeration for CRL reasons.
1555
1556 .. attribute:: unspecified
1557
1558 It is unspecified why the certificate was revoked. This reason cannot
1559 be used as a reason flag in a :class:`DistributionPoint`.
Paul Kehrer5a485522015-05-06 00:29:12 -05001560
1561 .. attribute:: key_compromise
1562
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05001563 This reason indicates that the private key was compromised.
Paul Kehrer5a485522015-05-06 00:29:12 -05001564
1565 .. attribute:: ca_compromise
1566
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05001567 This reason indicates that the CA issuing the certificate was
1568 compromised.
Paul Kehrer5a485522015-05-06 00:29:12 -05001569
1570 .. attribute:: affiliation_changed
1571
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05001572 This reason indicates that the subject's name or other information has
1573 changed.
Paul Kehrer5a485522015-05-06 00:29:12 -05001574
1575 .. attribute:: superseded
1576
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05001577 This reason indicates that a certificate has been superseded.
Paul Kehrer5a485522015-05-06 00:29:12 -05001578
1579 .. attribute:: cessation_of_operation
1580
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05001581 This reason indicates that the certificate is no longer required.
Paul Kehrer5a485522015-05-06 00:29:12 -05001582
1583 .. attribute:: certificate_hold
1584
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05001585 This reason indicates that the certificate is on hold.
Paul Kehrer5a485522015-05-06 00:29:12 -05001586
1587 .. attribute:: privilege_withdrawn
1588
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05001589 This reason indicates that the privilege granted by this certificate
1590 have been withdrawn.
Paul Kehrer5a485522015-05-06 00:29:12 -05001591
1592 .. attribute:: aa_compromise
1593
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05001594 When an attribute authority has been compromised.
1595
1596 .. attribute:: remove_from_crl
1597
1598 This reason indicates that the certificate was on hold and should be
1599 removed from the CRL. This reason cannot be used as a reason flag
1600 in a :class:`DistributionPoint`.
Paul Kehrer5a485522015-05-06 00:29:12 -05001601
Paul Kehrer16fae762015-05-01 23:14:20 -05001602.. class:: InhibitAnyPolicy
1603
1604 .. versionadded:: 1.0
1605
1606 The inhibit ``anyPolicy`` extension indicates that the special OID
Paul Kehrere27f6582015-08-10 18:33:38 -05001607 :attr:`~cryptography.x509.oid.CertificatePoliciesOID.ANY_POLICY`, is not
1608 considered an explicit match for other :class:`CertificatePolicies` except
1609 when it appears in an intermediate self-issued CA certificate. The value
1610 indicates the number of additional non-self-issued certificates that may
1611 appear in the path before
1612 :attr:`~cryptography.x509.oid.CertificatePoliciesOID.ANY_POLICY` is no
1613 longer permitted. For example, a value of one indicates that
1614 :attr:`~cryptography.x509.oid.CertificatePoliciesOID.ANY_POLICY` may be
1615 processed in certificates issued by the subject of this certificate, but
1616 not in additional certificates in the path.
Paul Kehrer16fae762015-05-01 23:14:20 -05001617
Paul Kehrer822f3d32015-08-06 11:47:32 +01001618 .. attribute:: oid
1619
1620 .. versionadded:: 1.0
1621
1622 :type: :class:`ObjectIdentifier`
1623
Paul Kehrere27f6582015-08-10 18:33:38 -05001624 Returns
1625 :attr:`~cryptography.x509.oid.ExtensionOID.INHIBIT_ANY_POLICY`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001626
Paul Kehrer16fae762015-05-01 23:14:20 -05001627 .. attribute:: skip_certs
1628
1629 :type: int
1630
Paul Kehrer0d210922015-04-28 17:31:07 -05001631.. class:: CertificatePolicies
1632
1633 .. versionadded:: 0.9
1634
Paul Kehrer2e879742015-05-02 23:09:56 -05001635 The certificate policies extension is an iterable, containing one or more
1636 :class:`PolicyInformation` instances.
Paul Kehrer0d210922015-04-28 17:31:07 -05001637
Paul Kehrer822f3d32015-08-06 11:47:32 +01001638 .. attribute:: oid
1639
1640 .. versionadded:: 1.0
1641
1642 :type: :class:`ObjectIdentifier`
1643
Paul Kehrere27f6582015-08-10 18:33:38 -05001644 Returns
1645 :attr:`~cryptography.x509.oid.ExtensionOID.CERTIFICATE_POLICIES`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001646
Paul Kehrer0d210922015-04-28 17:31:07 -05001647Certificate Policies Classes
1648~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1649
1650These classes may be present within a :class:`CertificatePolicies` instance.
1651
1652.. class:: PolicyInformation
1653
1654 .. versionadded:: 0.9
1655
1656 Contains a policy identifier and an optional list of qualifiers.
1657
1658 .. attribute:: policy_identifier
1659
1660 :type: :class:`ObjectIdentifier`
1661
1662 .. attribute:: policy_qualifiers
1663
1664 :type: list
1665
Paul Kehrerba35b3b2015-05-10 13:07:59 -05001666 A list consisting of :term:`text` and/or :class:`UserNotice` objects.
Paul Kehrer3f8ddeb2015-05-11 00:25:36 -05001667 If the value is text it is a pointer to the practice statement
1668 published by the certificate authority. If it is a user notice it is
1669 meant for display to the relying party when the certificate is
1670 used.
Paul Kehrer2e879742015-05-02 23:09:56 -05001671
Paul Kehrer0d210922015-04-28 17:31:07 -05001672.. class:: UserNotice
1673
1674 .. versionadded:: 0.9
1675
Paul Kehrer2e879742015-05-02 23:09:56 -05001676 User notices are intended for display to a relying party when a certificate
1677 is used. In practice, few if any UIs expose this data and it is a rarely
1678 encoded component.
1679
Paul Kehrer0d210922015-04-28 17:31:07 -05001680 .. attribute:: notice_reference
1681
1682 :type: :class:`NoticeReference` or None
1683
Paul Kehrer2e879742015-05-02 23:09:56 -05001684 The notice reference field names an organization and identifies,
1685 by number, a particular statement prepared by that organization.
1686
Paul Kehrer0d210922015-04-28 17:31:07 -05001687 .. attribute:: explicit_text
1688
Paul Kehrer2e879742015-05-02 23:09:56 -05001689 This field includes an arbitrary textual statement directly in the
1690 certificate.
1691
Paul Kehrer0d210922015-04-28 17:31:07 -05001692 :type: :term:`text`
1693
1694.. class:: NoticeReference
1695
Paul Kehrer2e879742015-05-02 23:09:56 -05001696 Notice reference can name an organization and provide information about
1697 notices related to the certificate. For example, it might identify the
1698 organization name and notice number 1. Application software could
1699 have a notice file containing the current set of notices for the named
1700 organization; the application would then extract the notice text from the
1701 file and display it. In practice this is rarely seen.
1702
Paul Kehrer0d210922015-04-28 17:31:07 -05001703 .. versionadded:: 0.9
1704
1705 .. attribute:: organization
1706
Paul Kehrer66c61702015-05-12 16:39:18 -05001707 :type: :term:`text`
Paul Kehrer0d210922015-04-28 17:31:07 -05001708
Paul Kehrer3f8ddeb2015-05-11 00:25:36 -05001709 .. attribute:: notice_numbers
Paul Kehrer0d210922015-04-28 17:31:07 -05001710
Paul Kehrer66c61702015-05-12 16:39:18 -05001711 :type: list
Paul Kehrer0d210922015-04-28 17:31:07 -05001712
Paul Kehrer66c61702015-05-12 16:39:18 -05001713 A list of integers.
Paul Kehrer0d210922015-04-28 17:31:07 -05001714
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001715Object Identifiers
1716~~~~~~~~~~~~~~~~~~
1717
Paul Kehrer4bb46492015-02-07 16:59:14 -06001718X.509 elements are frequently identified by :class:`ObjectIdentifier`
1719instances. The following common OIDs are available as constants.
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001720
Paul Kehrere27f6582015-08-10 18:33:38 -05001721.. currentmodule:: cryptography.x509.oid
Paul Kehrer56da2a52015-02-11 23:35:07 -06001722
Paul Kehrere27f6582015-08-10 18:33:38 -05001723.. class:: NameOID
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001724
Paul Kehrere27f6582015-08-10 18:33:38 -05001725 These OIDs are typically seen in X.509 names.
Paul Kehrer858b9b72015-02-05 09:50:31 -06001726
Paul Kehrere27f6582015-08-10 18:33:38 -05001727 .. versionadded:: 1.0
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001728
Paul Kehrere27f6582015-08-10 18:33:38 -05001729 .. attribute:: COMMON_NAME
Paul Kehrer858b9b72015-02-05 09:50:31 -06001730
Paul Kehrere27f6582015-08-10 18:33:38 -05001731 Corresponds to the dotted string ``"2.5.4.3"``. Historically the domain
1732 name would be encoded here for server certificates. :rfc:`2818`
1733 deprecates this practice and names of that type should now be located
1734 in a :class:`~cryptography.x509.SubjectAlternativeName` extension.
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001735
Paul Kehrere27f6582015-08-10 18:33:38 -05001736 .. attribute:: COUNTRY_NAME
Paul Kehrer858b9b72015-02-05 09:50:31 -06001737
Paul Kehrere27f6582015-08-10 18:33:38 -05001738 Corresponds to the dotted string ``"2.5.4.6"``.
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001739
Paul Kehrere27f6582015-08-10 18:33:38 -05001740 .. attribute:: LOCALITY_NAME
Paul Kehrer858b9b72015-02-05 09:50:31 -06001741
Paul Kehrere27f6582015-08-10 18:33:38 -05001742 Corresponds to the dotted string ``"2.5.4.7"``.
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001743
Paul Kehrere27f6582015-08-10 18:33:38 -05001744 .. attribute:: STATE_OR_PROVINCE_NAME
Paul Kehrer858b9b72015-02-05 09:50:31 -06001745
Paul Kehrere27f6582015-08-10 18:33:38 -05001746 Corresponds to the dotted string ``"2.5.4.8"``.
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001747
Paul Kehrere27f6582015-08-10 18:33:38 -05001748 .. attribute:: ORGANIZATION_NAME
Paul Kehrer858b9b72015-02-05 09:50:31 -06001749
Paul Kehrere27f6582015-08-10 18:33:38 -05001750 Corresponds to the dotted string ``"2.5.4.10"``.
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001751
Paul Kehrere27f6582015-08-10 18:33:38 -05001752 .. attribute:: ORGANIZATIONAL_UNIT_NAME
Paul Kehrer858b9b72015-02-05 09:50:31 -06001753
Paul Kehrere27f6582015-08-10 18:33:38 -05001754 Corresponds to the dotted string ``"2.5.4.11"``.
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001755
Paul Kehrere27f6582015-08-10 18:33:38 -05001756 .. attribute:: SERIAL_NUMBER
Paul Kehrer858b9b72015-02-05 09:50:31 -06001757
Paul Kehrere27f6582015-08-10 18:33:38 -05001758 Corresponds to the dotted string ``"2.5.4.5"``. This is distinct from
1759 the serial number of the certificate itself (which can be obtained with
1760 :func:`~cryptography.x509.Certificate.serial`).
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001761
Paul Kehrere27f6582015-08-10 18:33:38 -05001762 .. attribute:: SURNAME
Paul Kehrer858b9b72015-02-05 09:50:31 -06001763
Paul Kehrere27f6582015-08-10 18:33:38 -05001764 Corresponds to the dotted string ``"2.5.4.4"``.
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001765
Paul Kehrere27f6582015-08-10 18:33:38 -05001766 .. attribute:: GIVEN_NAME
Paul Kehrer858b9b72015-02-05 09:50:31 -06001767
Paul Kehrere27f6582015-08-10 18:33:38 -05001768 Corresponds to the dotted string ``"2.5.4.42"``.
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001769
Paul Kehrere27f6582015-08-10 18:33:38 -05001770 .. attribute:: TITLE
Paul Kehrer858b9b72015-02-05 09:50:31 -06001771
Paul Kehrere27f6582015-08-10 18:33:38 -05001772 Corresponds to the dotted string ``"2.5.4.12"``.
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001773
Paul Kehrere27f6582015-08-10 18:33:38 -05001774 .. attribute:: GENERATION_QUALIFIER
Paul Kehrer858b9b72015-02-05 09:50:31 -06001775
Paul Kehrere27f6582015-08-10 18:33:38 -05001776 Corresponds to the dotted string ``"2.5.4.44"``.
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001777
Paul Kehrere27f6582015-08-10 18:33:38 -05001778 .. attribute:: DN_QUALIFIER
Paul Kehrer858b9b72015-02-05 09:50:31 -06001779
Paul Kehrere27f6582015-08-10 18:33:38 -05001780 Corresponds to the dotted string ``"2.5.4.46"``. This specifies
1781 disambiguating information to add to the relative distinguished name of an
1782 entry. See :rfc:`2256`.
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001783
Paul Kehrere27f6582015-08-10 18:33:38 -05001784 .. attribute:: PSEUDONYM
Paul Kehrer858b9b72015-02-05 09:50:31 -06001785
Paul Kehrere27f6582015-08-10 18:33:38 -05001786 Corresponds to the dotted string ``"2.5.4.65"``.
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001787
Paul Kehrere27f6582015-08-10 18:33:38 -05001788 .. attribute:: DOMAIN_COMPONENT
Paul Kehrer858b9b72015-02-05 09:50:31 -06001789
Paul Kehrere27f6582015-08-10 18:33:38 -05001790 Corresponds to the dotted string ``"0.9.2342.19200300.100.1.25"``. A string
1791 holding one component of a domain name. See :rfc:`4519`.
Paul Kehrer56da2a52015-02-11 23:35:07 -06001792
Paul Kehrere27f6582015-08-10 18:33:38 -05001793 .. attribute:: EMAIL_ADDRESS
Paul Kehrer56da2a52015-02-11 23:35:07 -06001794
Paul Kehrere27f6582015-08-10 18:33:38 -05001795 Corresponds to the dotted string ``"1.2.840.113549.1.9.1"``.
Paul Kehrer56da2a52015-02-11 23:35:07 -06001796
Paul Kehrer56da2a52015-02-11 23:35:07 -06001797
Paul Kehrere27f6582015-08-10 18:33:38 -05001798.. class:: SignatureAlgorithmOID
Paul Kehrer56da2a52015-02-11 23:35:07 -06001799
Paul Kehrere27f6582015-08-10 18:33:38 -05001800 .. versionadded:: 1.0
Paul Kehrer56da2a52015-02-11 23:35:07 -06001801
Paul Kehrere27f6582015-08-10 18:33:38 -05001802 .. attribute:: RSA_WITH_MD5
Paul Kehrer56da2a52015-02-11 23:35:07 -06001803
Paul Kehrere27f6582015-08-10 18:33:38 -05001804 Corresponds to the dotted string ``"1.2.840.113549.1.1.4"``. This is
1805 an MD5 digest signed by an RSA key.
Paul Kehrer56da2a52015-02-11 23:35:07 -06001806
Paul Kehrere27f6582015-08-10 18:33:38 -05001807 .. attribute:: RSA_WITH_SHA1
Paul Kehrer56da2a52015-02-11 23:35:07 -06001808
Paul Kehrere27f6582015-08-10 18:33:38 -05001809 Corresponds to the dotted string ``"1.2.840.113549.1.1.5"``. This is
1810 a SHA1 digest signed by an RSA key.
Paul Kehrer56da2a52015-02-11 23:35:07 -06001811
Paul Kehrere27f6582015-08-10 18:33:38 -05001812 .. attribute:: RSA_WITH_SHA224
Paul Kehrer56da2a52015-02-11 23:35:07 -06001813
Paul Kehrere27f6582015-08-10 18:33:38 -05001814 Corresponds to the dotted string ``"1.2.840.113549.1.1.14"``. This is
1815 a SHA224 digest signed by an RSA key.
Paul Kehrer56da2a52015-02-11 23:35:07 -06001816
Paul Kehrere27f6582015-08-10 18:33:38 -05001817 .. attribute:: RSA_WITH_SHA256
Paul Kehrer56da2a52015-02-11 23:35:07 -06001818
Paul Kehrere27f6582015-08-10 18:33:38 -05001819 Corresponds to the dotted string ``"1.2.840.113549.1.1.11"``. This is
1820 a SHA256 digest signed by an RSA key.
Alex Gaynor3aadabf2015-06-23 22:06:21 -04001821
Paul Kehrere27f6582015-08-10 18:33:38 -05001822 .. attribute:: RSA_WITH_SHA384
Alex Gaynor3aadabf2015-06-23 22:06:21 -04001823
Paul Kehrere27f6582015-08-10 18:33:38 -05001824 Corresponds to the dotted string ``"1.2.840.113549.1.1.12"``. This is
1825 a SHA384 digest signed by an RSA key.
Paul Kehrer56da2a52015-02-11 23:35:07 -06001826
Paul Kehrere27f6582015-08-10 18:33:38 -05001827 .. attribute:: RSA_WITH_SHA512
Paul Kehrer56da2a52015-02-11 23:35:07 -06001828
Paul Kehrere27f6582015-08-10 18:33:38 -05001829 Corresponds to the dotted string ``"1.2.840.113549.1.1.13"``. This is
1830 a SHA512 digest signed by an RSA key.
Paul Kehrer56da2a52015-02-11 23:35:07 -06001831
Paul Kehrere27f6582015-08-10 18:33:38 -05001832 .. attribute:: ECDSA_WITH_SHA1
Paul Kehrer56da2a52015-02-11 23:35:07 -06001833
Paul Kehrere27f6582015-08-10 18:33:38 -05001834 Corresponds to the dotted string ``"1.2.840.10045.4.1"``. This is a SHA1
1835 digest signed by an ECDSA key.
Paul Kehrer56da2a52015-02-11 23:35:07 -06001836
Paul Kehrere27f6582015-08-10 18:33:38 -05001837 .. attribute:: ECDSA_WITH_SHA224
Paul Kehrer56da2a52015-02-11 23:35:07 -06001838
Paul Kehrere27f6582015-08-10 18:33:38 -05001839 Corresponds to the dotted string ``"1.2.840.10045.4.3.1"``. This is
1840 a SHA224 digest signed by an ECDSA key.
1841
1842 .. attribute:: ECDSA_WITH_SHA256
1843
1844 Corresponds to the dotted string ``"1.2.840.10045.4.3.2"``. This is
1845 a SHA256 digest signed by an ECDSA key.
1846
1847 .. attribute:: ECDSA_WITH_SHA384
1848
1849 Corresponds to the dotted string ``"1.2.840.10045.4.3.3"``. This is
1850 a SHA384 digest signed by an ECDSA key.
1851
1852 .. attribute:: ECDSA_WITH_SHA512
1853
1854 Corresponds to the dotted string ``"1.2.840.10045.4.3.4"``. This is
1855 a SHA512 digest signed by an ECDSA key.
1856
1857 .. attribute:: DSA_WITH_SHA1
1858
1859 Corresponds to the dotted string ``"1.2.840.10040.4.3"``. This is
1860 a SHA1 digest signed by a DSA key.
1861
1862 .. attribute:: DSA_WITH_SHA224
1863
1864 Corresponds to the dotted string ``"2.16.840.1.101.3.4.3.1"``. This is
1865 a SHA224 digest signed by a DSA key.
1866
1867 .. attribute:: DSA_WITH_SHA256
Paul Kehrer56da2a52015-02-11 23:35:07 -06001868
Paul Kehrere27f6582015-08-10 18:33:38 -05001869 Corresponds to the dotted string ``"2.16.840.1.101.3.4.3.2"``. This is
1870 a SHA256 digest signed by a DSA key.
Paul Kehrer56da2a52015-02-11 23:35:07 -06001871
Paul Kehrer56da2a52015-02-11 23:35:07 -06001872
Paul Kehrere27f6582015-08-10 18:33:38 -05001873.. class:: ExtendedKeyUsageOID
Paul Kehrer56da2a52015-02-11 23:35:07 -06001874
Paul Kehrere27f6582015-08-10 18:33:38 -05001875 .. versionadded:: 1.0
Paul Kehrer56da2a52015-02-11 23:35:07 -06001876
Paul Kehrere27f6582015-08-10 18:33:38 -05001877 .. attribute:: SERVER_AUTH
Paul Kehrer56da2a52015-02-11 23:35:07 -06001878
Paul Kehrere27f6582015-08-10 18:33:38 -05001879 Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.1"``. This is used
1880 to denote that a certificate may be used for TLS web server
1881 authentication.
Paul Kehrer56da2a52015-02-11 23:35:07 -06001882
Paul Kehrere27f6582015-08-10 18:33:38 -05001883 .. attribute:: CLIENT_AUTH
Paul Kehrer56da2a52015-02-11 23:35:07 -06001884
Paul Kehrere27f6582015-08-10 18:33:38 -05001885 Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.2"``. This is used
1886 to denote that a certificate may be used for TLS web client
1887 authentication.
Paul Kehrerffa2a152015-03-31 08:18:25 -05001888
Paul Kehrere27f6582015-08-10 18:33:38 -05001889 .. attribute:: CODE_SIGNING
Paul Kehrere1513fa2015-03-30 23:08:17 -05001890
Paul Kehrere27f6582015-08-10 18:33:38 -05001891 Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.3"``. This is used
1892 to denote that a certificate may be used for code signing.
Paul Kehrere1513fa2015-03-30 23:08:17 -05001893
Paul Kehrere27f6582015-08-10 18:33:38 -05001894 .. attribute:: EMAIL_PROTECTION
Paul Kehrere1513fa2015-03-30 23:08:17 -05001895
Paul Kehrere27f6582015-08-10 18:33:38 -05001896 Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.4"``. This is used
1897 to denote that a certificate may be used for email protection.
Paul Kehrere1513fa2015-03-30 23:08:17 -05001898
Paul Kehrere27f6582015-08-10 18:33:38 -05001899 .. attribute:: TIME_STAMPING
Paul Kehrere1513fa2015-03-30 23:08:17 -05001900
Paul Kehrere27f6582015-08-10 18:33:38 -05001901 Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.8"``. This is used
1902 to denote that a certificate may be used for time stamping.
Paul Kehrere1513fa2015-03-30 23:08:17 -05001903
Paul Kehrere27f6582015-08-10 18:33:38 -05001904 .. attribute:: OCSP_SIGNING
Paul Kehrere1513fa2015-03-30 23:08:17 -05001905
Paul Kehrere27f6582015-08-10 18:33:38 -05001906 Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.9"``. This is used
1907 to denote that a certificate may be used for signing OCSP responses.
Paul Kehrere1513fa2015-03-30 23:08:17 -05001908
Paul Kehrere1513fa2015-03-30 23:08:17 -05001909
Paul Kehrere27f6582015-08-10 18:33:38 -05001910.. class:: AuthorityInformationAccessOID
Paul Kehrere1513fa2015-03-30 23:08:17 -05001911
Paul Kehrere27f6582015-08-10 18:33:38 -05001912 .. versionadded:: 1.0
Paul Kehrere1513fa2015-03-30 23:08:17 -05001913
Paul Kehrere27f6582015-08-10 18:33:38 -05001914 .. attribute:: OCSP
Paul Kehrere1513fa2015-03-30 23:08:17 -05001915
Paul Kehrere27f6582015-08-10 18:33:38 -05001916 Corresponds to the dotted string ``"1.3.6.1.5.5.7.48.1"``. Used as the
1917 identifier for OCSP data in
1918 :class:`~cryptography.x509.AccessDescription` objects.
Paul Kehrere1513fa2015-03-30 23:08:17 -05001919
Paul Kehrere27f6582015-08-10 18:33:38 -05001920 .. attribute:: CA_ISSUERS
Paul Kehrer3e6d5582015-05-02 21:57:56 -05001921
Paul Kehrere27f6582015-08-10 18:33:38 -05001922 Corresponds to the dotted string ``"1.3.6.1.5.5.7.48.2"``. Used as the
1923 identifier for CA issuer data in
1924 :class:`~cryptography.x509.AccessDescription` objects.
Paul Kehrer3e6d5582015-05-02 21:57:56 -05001925
Paul Kehrer3e6d5582015-05-02 21:57:56 -05001926
Paul Kehrere27f6582015-08-10 18:33:38 -05001927.. class:: CertificatePoliciesOID
Paul Kehrer3e6d5582015-05-02 21:57:56 -05001928
Paul Kehrere27f6582015-08-10 18:33:38 -05001929 .. versionadded:: 1.0
Paul Kehrer3e6d5582015-05-02 21:57:56 -05001930
Paul Kehrere27f6582015-08-10 18:33:38 -05001931 .. attribute:: CPS_QUALIFIER
Paul Kehrer2e879742015-05-02 23:09:56 -05001932
Paul Kehrere27f6582015-08-10 18:33:38 -05001933 Corresponds to the dotted string ``"1.3.6.1.5.5.7.2.1"``.
Paul Kehrer2e879742015-05-02 23:09:56 -05001934
Paul Kehrere27f6582015-08-10 18:33:38 -05001935 .. attribute:: CPS_USER_NOTICE
Paul Kehrer2e879742015-05-02 23:09:56 -05001936
Paul Kehrere27f6582015-08-10 18:33:38 -05001937 Corresponds to the dotted string ``"1.3.6.1.5.5.7.2.2"``.
Paul Kehrer2e879742015-05-02 23:09:56 -05001938
Paul Kehrere27f6582015-08-10 18:33:38 -05001939 .. attribute:: ANY_POLICY
Paul Kehrer2e879742015-05-02 23:09:56 -05001940
Paul Kehrere27f6582015-08-10 18:33:38 -05001941 Corresponds to the dotted string ``"2.5.29.32.0"``.
Paul Kehrer16fae762015-05-01 23:14:20 -05001942
Paul Kehrer16fae762015-05-01 23:14:20 -05001943
Paul Kehrere27f6582015-08-10 18:33:38 -05001944.. class:: ExtensionOID
Paul Kehrer5553d572015-03-23 21:08:01 -05001945
Paul Kehrere27f6582015-08-10 18:33:38 -05001946 .. versionadded:: 1.0
Paul Kehrer2bb94642015-03-21 09:54:17 -05001947
Paul Kehrere27f6582015-08-10 18:33:38 -05001948 .. attribute:: BASIC_CONSTRAINTS
Paul Kehrer2bb94642015-03-21 09:54:17 -05001949
Paul Kehrere27f6582015-08-10 18:33:38 -05001950 Corresponds to the dotted string ``"2.5.29.19"``. The identifier for the
1951 :class:`~cryptography.x509.BasicConstraints` extension type.
Paul Kehrer2bb94642015-03-21 09:54:17 -05001952
Paul Kehrere27f6582015-08-10 18:33:38 -05001953 .. attribute:: KEY_USAGE
Paul Kehrercecbbba2015-03-30 14:58:38 -05001954
Paul Kehrere27f6582015-08-10 18:33:38 -05001955 Corresponds to the dotted string ``"2.5.29.15"``. The identifier for the
1956 :class:`~cryptography.x509.KeyUsage` extension type.
Paul Kehrercecbbba2015-03-30 14:58:38 -05001957
Paul Kehrere27f6582015-08-10 18:33:38 -05001958 .. attribute:: SUBJECT_ALTERNATIVE_NAME
Paul Kehrerd4f632e2015-05-12 08:25:42 -05001959
Paul Kehrere27f6582015-08-10 18:33:38 -05001960 Corresponds to the dotted string ``"2.5.29.17"``. The identifier for the
1961 :class:`~cryptography.x509.SubjectAlternativeName` extension type.
Paul Kehrerd4f632e2015-05-12 08:25:42 -05001962
Paul Kehrere27f6582015-08-10 18:33:38 -05001963 .. attribute:: ISSUER_ALTERNATIVE_NAME
Paul Kehrer99125c92015-06-07 18:37:10 -05001964
Paul Kehrere27f6582015-08-10 18:33:38 -05001965 Corresponds to the dotted string ``"2.5.29.18"``. The identifier for the
1966 :class:`~cryptography.x509.IssuerAlternativeName` extension type.
Paul Kehrer99125c92015-06-07 18:37:10 -05001967
Paul Kehrere27f6582015-08-10 18:33:38 -05001968 .. attribute:: SUBJECT_KEY_IDENTIFIER
Paul Kehrerd4f632e2015-05-12 08:25:42 -05001969
Paul Kehrere27f6582015-08-10 18:33:38 -05001970 Corresponds to the dotted string ``"2.5.29.14"``. The identifier for the
1971 :class:`~cryptography.x509.SubjectKeyIdentifier` extension type.
Paul Kehrerd4f632e2015-05-12 08:25:42 -05001972
Paul Kehrere27f6582015-08-10 18:33:38 -05001973 .. attribute:: NAME_CONSTRAINTS
Paul Kehrere0017be2015-05-17 20:39:40 -06001974
Paul Kehrere27f6582015-08-10 18:33:38 -05001975 Corresponds to the dotted string ``"2.5.29.30"``. The identifier for the
1976 :class:`~cryptography.x509.NameConstraints` extension type.
Paul Kehrere0017be2015-05-17 20:39:40 -06001977
Paul Kehrere27f6582015-08-10 18:33:38 -05001978 .. attribute:: CRL_DISTRIBUTION_POINTS
Paul Kehrerd4f632e2015-05-12 08:25:42 -05001979
Paul Kehrere27f6582015-08-10 18:33:38 -05001980 Corresponds to the dotted string ``"2.5.29.31"``. The identifier for the
1981 :class:`~cryptography.x509.CRLDistributionPoints` extension type.
Paul Kehrerd4f632e2015-05-12 08:25:42 -05001982
Paul Kehrere27f6582015-08-10 18:33:38 -05001983 .. attribute:: CERTIFICATE_POLICIES
Paul Kehrerd4f632e2015-05-12 08:25:42 -05001984
Paul Kehrere27f6582015-08-10 18:33:38 -05001985 Corresponds to the dotted string ``"2.5.29.32"``. The identifier for the
1986 :class:`~cryptography.x509.CertificatePolicies` extension type.
Paul Kehrerd4f632e2015-05-12 08:25:42 -05001987
Paul Kehrere27f6582015-08-10 18:33:38 -05001988 .. attribute:: AUTHORITY_KEY_IDENTIFIER
Paul Kehrerd4f632e2015-05-12 08:25:42 -05001989
Paul Kehrere27f6582015-08-10 18:33:38 -05001990 Corresponds to the dotted string ``"2.5.29.35"``. The identifier for the
1991 :class:`~cryptography.x509.AuthorityKeyIdentifier` extension type.
Paul Kehrerd4f632e2015-05-12 08:25:42 -05001992
Paul Kehrere27f6582015-08-10 18:33:38 -05001993 .. attribute:: EXTENDED_KEY_USAGE
Paul Kehrerd4f632e2015-05-12 08:25:42 -05001994
Paul Kehrere27f6582015-08-10 18:33:38 -05001995 Corresponds to the dotted string ``"2.5.29.37"``. The identifier for the
1996 :class:`~cryptography.x509.ExtendedKeyUsage` extension type.
Paul Kehrerd4f632e2015-05-12 08:25:42 -05001997
Paul Kehrere27f6582015-08-10 18:33:38 -05001998 .. attribute:: AUTHORITY_INFORMATION_ACCESS
Paul Kehrerd4f632e2015-05-12 08:25:42 -05001999
Paul Kehrere27f6582015-08-10 18:33:38 -05002000 Corresponds to the dotted string ``"1.3.6.1.5.5.7.1.1"``. The identifier
2001 for the :class:`~cryptography.x509.AuthorityInformationAccess` extension
2002 type.
Paul Kehrer56da2a52015-02-11 23:35:07 -06002003
Paul Kehrere27f6582015-08-10 18:33:38 -05002004 .. attribute:: INHIBIT_ANY_POLICY
Paul Kehrerb33de932015-08-06 23:41:05 +01002005
Paul Kehrere27f6582015-08-10 18:33:38 -05002006 Corresponds to the dotted string ``"2.5.29.54"``. The identifier
2007 for the :class:`~cryptography.x509.InhibitAnyPolicy` extension type.
Paul Kehrerb33de932015-08-06 23:41:05 +01002008
Paul Kehrere27f6582015-08-10 18:33:38 -05002009 .. attribute:: OCSP_NO_CHECK
Paul Kehrer4a1038e2015-05-18 10:28:31 -07002010
Paul Kehrere27f6582015-08-10 18:33:38 -05002011 Corresponds to the dotted string ``"1.3.6.1.5.5.7.48.1.5"``. The
2012 identifier for the :class:`~cryptography.x509.OCSPNoCheck` extension
2013 type.
Paul Kehrer4a1038e2015-05-18 10:28:31 -07002014
Paul Kehrer912d3fb2015-01-29 11:19:22 -06002015Exceptions
2016~~~~~~~~~~
Paul Kehrere27f6582015-08-10 18:33:38 -05002017.. currentmodule:: cryptography.x509
Paul Kehrer912d3fb2015-01-29 11:19:22 -06002018
Paul Kehrere76cd272014-12-14 19:00:51 -06002019.. class:: InvalidVersion
Paul Kehrera68fd332014-11-27 07:08:40 -10002020
2021 This is raised when an X.509 certificate has an invalid version number.
Paul Kehrer016e08a2014-11-26 09:41:18 -10002022
Paul Kehrerd5cccf72014-12-15 17:20:33 -06002023 .. attribute:: parsed_version
2024
Paul Kehrerbbffc402014-12-17 13:33:55 -06002025 :type: int
2026
2027 Returns the raw version that was parsed from the certificate.
Paul Kehrerd5cccf72014-12-15 17:20:33 -06002028
Paul Kehrerfbb7ac82015-03-16 19:26:29 -05002029.. class:: DuplicateExtension
2030
2031 This is raised when more than one X.509 extension of the same type is
2032 found within a certificate.
2033
2034 .. attribute:: oid
2035
2036 :type: :class:`ObjectIdentifier`
2037
2038 Returns the OID.
2039
2040.. class:: UnsupportedExtension
2041
2042 This is raised when a certificate contains an unsupported extension type.
2043
2044 .. attribute:: oid
2045
2046 :type: :class:`ObjectIdentifier`
2047
2048 Returns the OID.
2049
Paul Kehrerfa56a232015-03-17 13:14:03 -05002050.. class:: ExtensionNotFound
2051
2052 This is raised when calling :meth:`Extensions.get_extension_for_oid` with
2053 an extension OID that is not present in the certificate.
2054
2055 .. attribute:: oid
2056
2057 :type: :class:`ObjectIdentifier`
2058
2059 Returns the OID.
2060
Paul Kehrer9089c912015-04-20 22:15:20 -05002061.. class:: UnsupportedGeneralNameType
2062
2063 This is raised when a certificate contains an unsupported general name
2064 type in an extension.
2065
Paul Kehrerbed07352015-04-21 08:31:10 -05002066 .. attribute:: type
2067
Paul Kehrer0a621bf2015-04-22 09:22:56 -05002068 :type: int
2069
2070 The integer value of the unsupported type. The complete list of
2071 types can be found in `RFC 5280 section 4.2.1.6`_.
Paul Kehrerbed07352015-04-21 08:31:10 -05002072
Paul Kehrer016e08a2014-11-26 09:41:18 -10002073
Paul Kehrerc7c9a432015-04-19 09:20:13 -05002074.. _`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 -05002075.. _`RFC 5280 section 4.2.1.6`: https://tools.ietf.org/html/rfc5280#section-4.2.1.6