blob: e7e02de3d00e80daaa3b14522e42dafb4fd47f60 [file] [log] [blame]
Alex Gaynor4af5b372015-07-12 10:30:59 -05001X.509 Reference
2===============
Paul Kehrer016e08a2014-11-26 09:41:18 -10003
Paul Kehrera9d78c12014-11-26 10:59:03 -10004.. currentmodule:: cryptography.x509
Paul Kehrer016e08a2014-11-26 09:41:18 -10005
Paul Kehrerd26c4db2015-03-15 15:36:24 -05006.. testsetup::
7
Erik Trauschkedc570402015-09-24 20:24:28 -07008 pem_crl_data = b"""
9 -----BEGIN X509 CRL-----
10 MIIBtDCBnQIBAjANBgkqhkiG9w0BAQsFADAnMQswCQYDVQQGEwJVUzEYMBYGA1UE
11 AwwPY3J5cHRvZ3JhcGh5LmlvGA8yMDE1MDEwMTAwMDAwMFoYDzIwMTYwMTAxMDAw
12 MDAwWjA+MDwCAQAYDzIwMTUwMTAxMDAwMDAwWjAmMBgGA1UdGAQRGA8yMDE1MDEw
13 MTAwMDAwMFowCgYDVR0VBAMKAQEwDQYJKoZIhvcNAQELBQADggEBABRA4ww50Lz5
14 zk1j2+aluC4HPHqb7o06h4pTDcCGeXUKXIGeP5ntGGmIoxa26sNoLeOr8+5b43Gf
15 yWraHertllOwaOpNFEe+YZFaE9femtoDbf+GLMvRx/0wDfd3KxPoXnXKMXb2d1w4
16 RCLgmkYx6JyvS+5ciuLQVIKC+l7jwIUeZFLJMUJ8msM4pFYoGameeZmtjMbd/TNg
17 cVBfmZxNMHuLladJxvSo2esARo0TYPhYsgrREKoHwhpzSxdynjn4bOVkILfguwsN
18 qtEEMZFEv5Kb0GqRp2+Iagv2S6dg9JGvxVdsoGjaB6EbYSZ3Psx4aODasIn11uwo
19 X4B9vUQNXqc=
20 -----END X509 CRL-----
21 """.strip()
22
Paul Kehrerd26c4db2015-03-15 15:36:24 -050023 pem_req_data = b"""
24 -----BEGIN CERTIFICATE REQUEST-----
25 MIIC0zCCAbsCAQAwWTELMAkGA1UEBhMCVVMxETAPBgNVBAgMCElsbGlub2lzMRAw
26 DgYDVQQHDAdDaGljYWdvMREwDwYDVQQKDAhyNTA5IExMQzESMBAGA1UEAwwJaGVs
27 bG8uY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqhZx+Mo9VRd9
28 vsnWWa6NBCws21rZ0+1B/JGgB4hDsZS7iDE4Bj5z4idheFRtl8bBbdjPknq7BfoF
29 8v15Zq/Zv7i2xMSDL+LUrTBZezRd4bRTGqCm6YJ5EYkhqdcqeZleHCFImguHoq1J
30 Fh0+kObQrTHXw3ZP57a3o1IvyIUA3nNoCBL0QQhwBXaDXOojMKNR+bqB5ve8GS1y
31 Elr0AM/+cJsfaIahNQUgFKx3Eu3GeEOMKYOAG1lycgdQdmTUybLrT3U7vkClTseM
32 xHg1r5En7ALjONIhqRuq3rddYahrP8HXozb3zUy3cJ7P6IeaosuvNzvMXOX9P6HD
33 Ha9urDAJ1wIDAQABoDUwMwYJKoZIhvcNAQkOMSYwJDAiBgNVHREEGzAZggl3b3Js
34 ZC5jb22CDHdoYXRldmVyLmNvbTANBgkqhkiG9w0BAQUFAAOCAQEAS4Ro6h+z52SK
35 YSLCYARpnEu/rmh4jdqndt8naqcNb6uLx9mlKZ2W9on9XDjnSdQD9q+ZP5aZfESw
36 R0+rJhW9ZrNa/g1pt6M24ihclHYDAxYMWxT1z/TXXGM3TmZZ6gfYlNE1kkBuODHa
37 UYsR/1Ht1E1EsmmUimt2n+zQR2K8T9Coa+boaUW/GsTEuz1aaJAkj5ZvTDiIhRG4
38 AOCqFZOLAQmCCNgJnnspD9hDz/Ons085LF5wnYjN4/Nsk5tS6AGs3xjZ3jPoOGGn
39 82WQ9m4dBGoVDZXsobVTaN592JEYwN5iu72zRn7Einb4V4H5y3yD2dD4yWPlt4pk
40 5wFkeYsZEA==
41 -----END CERTIFICATE REQUEST-----
42 """.strip()
43
Paul Kehrerd3dafbd2015-03-15 16:24:18 -050044 pem_data = b"""
45 -----BEGIN CERTIFICATE-----
46 MIIDfDCCAmSgAwIBAgIBAjANBgkqhkiG9w0BAQsFADBFMQswCQYDVQQGEwJVUzEf
47 MB0GA1UEChMWVGVzdCBDZXJ0aWZpY2F0ZXMgMjAxMTEVMBMGA1UEAxMMVHJ1c3Qg
48 QW5jaG9yMB4XDTEwMDEwMTA4MzAwMFoXDTMwMTIzMTA4MzAwMFowQDELMAkGA1UE
49 BhMCVVMxHzAdBgNVBAoTFlRlc3QgQ2VydGlmaWNhdGVzIDIwMTExEDAOBgNVBAMT
50 B0dvb2QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCQWJpHYo37
51 Xfb7oJSPe+WvfTlzIG21WQ7MyMbGtK/m8mejCzR6c+f/pJhEH/OcDSMsXq8h5kXa
52 BGqWK+vSwD/Pzp5OYGptXmGPcthDtAwlrafkGOS4GqIJ8+k9XGKs+vQUXJKsOk47
53 RuzD6PZupq4s16xaLVqYbUC26UcY08GpnoLNHJZS/EmXw1ZZ3d4YZjNlpIpWFNHn
54 UGmdiGKXUPX/9H0fVjIAaQwjnGAbpgyCumWgzIwPpX+ElFOUr3z7BoVnFKhIXze+
55 VmQGSWxZxvWDUN90Ul0tLEpLgk3OVxUB4VUGuf15OJOpgo1xibINPmWt14Vda2N9
56 yrNKloJGZNqLAgMBAAGjfDB6MB8GA1UdIwQYMBaAFOR9X9FclYYILAWuvnW2ZafZ
57 XahmMB0GA1UdDgQWBBRYAYQkG7wrUpRKPaUQchRR9a86yTAOBgNVHQ8BAf8EBAMC
58 AQYwFwYDVR0gBBAwDjAMBgpghkgBZQMCATABMA8GA1UdEwEB/wQFMAMBAf8wDQYJ
59 KoZIhvcNAQELBQADggEBADWHlxbmdTXNwBL/llwhQqwnazK7CC2WsXBBqgNPWj7m
60 tvQ+aLG8/50Qc2Sun7o2VnwF9D18UUe8Gj3uPUYH+oSI1vDdyKcjmMbKRU4rk0eo
61 3UHNDXwqIVc9CQS9smyV+x1HCwL4TTrq+LXLKx/qVij0Yqk+UJfAtrg2jnYKXsCu
62 FMBQQnWCGrwa1g1TphRp/RmYHnMynYFmZrXtzFz+U9XEA7C+gPq4kqDI/iVfIT1s
63 6lBtdB50lrDVwl2oYfAvW/6sC2se2QleZidUmrziVNP4oEeXINokU6T6p//HM1FG
64 QYw2jOvpKcKtWCSAnegEbgsGYzATKjmPJPJ0npHFqzM=
65 -----END CERTIFICATE-----
66 """.strip()
67
Paul Kehrer93ae8052015-05-02 23:18:09 -050068 cryptography_cert_pem = b"""
69 -----BEGIN CERTIFICATE-----
70 MIIFvTCCBKWgAwIBAgICPyAwDQYJKoZIhvcNAQELBQAwRzELMAkGA1UEBhMCVVMx
71 FjAUBgNVBAoTDUdlb1RydXN0IEluYy4xIDAeBgNVBAMTF1JhcGlkU1NMIFNIQTI1
72 NiBDQSAtIEczMB4XDTE0MTAxNTEyMDkzMloXDTE4MTExNjAxMTUwM1owgZcxEzAR
73 BgNVBAsTCkdUNDg3NDI5NjUxMTAvBgNVBAsTKFNlZSB3d3cucmFwaWRzc2wuY29t
74 L3Jlc291cmNlcy9jcHMgKGMpMTQxLzAtBgNVBAsTJkRvbWFpbiBDb250cm9sIFZh
75 bGlkYXRlZCAtIFJhcGlkU1NMKFIpMRwwGgYDVQQDExN3d3cuY3J5cHRvZ3JhcGh5
76 LmlvMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAom/FebKJIot7Sp3s
77 itG1sicpe3thCssjI+g1JDAS7I3GLVNmbms1DOdIIqwf01gZkzzXBN2+9sOnyRaR
78 PPfCe1jTr3dk2y6rPE559vPa1nZQkhlzlhMhlPyjaT+S7g4Tio4qV2sCBZU01DZJ
79 CaksfohN+5BNVWoJzTbOcrHOEJ+M8B484KlBCiSxqf9cyNQKru4W3bHaCVNVJ8eu
80 6i6KyhzLa0L7yK3LXwwXVs583C0/vwFhccGWsFODqD/9xHUzsBIshE8HKjdjDi7Y
81 3BFQzVUQFjBB50NSZfAA/jcdt1blxJouc7z9T8Oklh+V5DDBowgAsrT4b6Z2Fq6/
82 r7D1GqivLK/ypUQmxq2WXWAUBb/Q6xHgxASxI4Br+CByIUQJsm8L2jzc7k+mF4hW
83 ltAIUkbo8fGiVnat0505YJgxWEDKOLc4Gda6d/7GVd5AvKrz242bUqeaWo6e4MTx
84 diku2Ma3rhdcr044Qvfh9hGyjqNjvhWY/I+VRWgihU7JrYvgwFdJqsQ5eiKT4OHi
85 gsejvWwkZzDtiQ+aQTrzM1FsY2swJBJsLSX4ofohlVRlIJCn/ME+XErj553431Lu
86 YQ5SzMd3nXzN78Vj6qzTfMUUY72UoT1/AcFiUMobgIqrrmwuNxfrkbVE2b6Bga74
87 FsJX63prvrJ41kuHK/16RQBM7fcCAwEAAaOCAWAwggFcMB8GA1UdIwQYMBaAFMOc
88 8/zTRgg0u85Gf6B8W/PiCMtZMFcGCCsGAQUFBwEBBEswSTAfBggrBgEFBQcwAYYT
89 aHR0cDovL2d2LnN5bWNkLmNvbTAmBggrBgEFBQcwAoYaaHR0cDovL2d2LnN5bWNi
90 LmNvbS9ndi5jcnQwDgYDVR0PAQH/BAQDAgWgMB0GA1UdJQQWMBQGCCsGAQUFBwMB
91 BggrBgEFBQcDAjAvBgNVHREEKDAmghN3d3cuY3J5cHRvZ3JhcGh5Lmlvgg9jcnlw
92 dG9ncmFwaHkuaW8wKwYDVR0fBCQwIjAgoB6gHIYaaHR0cDovL2d2LnN5bWNiLmNv
93 bS9ndi5jcmwwDAYDVR0TAQH/BAIwADBFBgNVHSAEPjA8MDoGCmCGSAGG+EUBBzYw
94 LDAqBggrBgEFBQcCARYeaHR0cHM6Ly93d3cucmFwaWRzc2wuY29tL2xlZ2FsMA0G
95 CSqGSIb3DQEBCwUAA4IBAQAzIYO2jx7h17FBT74tJ2zbV9OKqGb7QF8y3wUtP4xc
96 dH80vprI/Cfji8s86kr77aAvAqjDjaVjHn7UzebhSUivvRPmfzRgyWBacomnXTSt
97 Xlt2dp2nDQuwGyK2vB7dMfKnQAkxwq1sYUXznB8i0IhhCAoXp01QGPKq51YoIlnF
98 7DRMk6iEaL1SJbkIrLsCQyZFDf0xtfW9DqXugMMLoxeCsBhZJQzNyS2ryirrv9LH
99 aK3+6IZjrcyy9bkpz/gzJucyhU+75c4My/mnRCrtItRbCQuiI5pd5poDowm+HH9i
100 GVI9+0lAFwxOUnOnwsoI40iOoxjLMGB+CgFLKCGUcWxP
101 -----END CERTIFICATE-----
102 """.strip()
103
Paul Kehrerb2de9482014-12-11 14:54:48 -0600104Loading Certificates
105~~~~~~~~~~~~~~~~~~~~
Paul Kehrer016e08a2014-11-26 09:41:18 -1000106
107.. function:: load_pem_x509_certificate(data, backend)
108
109 .. versionadded:: 0.7
110
Paul Kehrere76cd272014-12-14 19:00:51 -0600111 Deserialize a certificate from PEM encoded data. PEM certificates are
112 base64 decoded and have delimiters that look like
113 ``-----BEGIN CERTIFICATE-----``.
Paul Kehrer016e08a2014-11-26 09:41:18 -1000114
115 :param bytes data: The PEM encoded certificate data.
116
117 :param backend: A backend supporting the
118 :class:`~cryptography.hazmat.backends.interfaces.X509Backend`
119 interface.
120
Paul Kehrere76cd272014-12-14 19:00:51 -0600121 :returns: An instance of :class:`~cryptography.x509.Certificate`.
Paul Kehrer016e08a2014-11-26 09:41:18 -1000122
123.. function:: load_der_x509_certificate(data, backend)
124
125 .. versionadded:: 0.7
126
Paul Kehrere76cd272014-12-14 19:00:51 -0600127 Deserialize a certificate from DER encoded data. DER is a binary format
Paul Kehrer92aac382014-12-15 16:25:28 -0600128 and is commonly found in files with the ``.cer`` extension (although file
129 extensions are not a guarantee of encoding type).
Paul Kehrer016e08a2014-11-26 09:41:18 -1000130
131 :param bytes data: The DER encoded certificate data.
132
133 :param backend: A backend supporting the
134 :class:`~cryptography.hazmat.backends.interfaces.X509Backend`
135 interface.
136
Paul Kehrere76cd272014-12-14 19:00:51 -0600137 :returns: An instance of :class:`~cryptography.x509.Certificate`.
Paul Kehrer016e08a2014-11-26 09:41:18 -1000138
Paul Kehrer016e08a2014-11-26 09:41:18 -1000139.. doctest::
140
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600141 >>> from cryptography import x509
Paul Kehrer016e08a2014-11-26 09:41:18 -1000142 >>> from cryptography.hazmat.backends import default_backend
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600143 >>> cert = x509.load_pem_x509_certificate(pem_data, default_backend())
Paul Kehrer016e08a2014-11-26 09:41:18 -1000144 >>> cert.serial
145 2
146
Erik Trauschkedc570402015-09-24 20:24:28 -0700147Loading Certificate Revocation Lists
148~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
149
150.. function:: load_pem_x509_crl(data, backend)
151
152 .. versionadded:: 1.1
153
154 Deserialize a certificate revocation list (CRL) from PEM encoded data. PEM
155 requests are base64 decoded and have delimiters that look like
Erik Trauschke32bbfe02015-10-21 08:04:55 -0700156 ``-----BEGIN X509 CRL-----``.
Erik Trauschkedc570402015-09-24 20:24:28 -0700157
158 :param bytes data: The PEM encoded request data.
159
160 :param backend: A backend supporting the
161 :class:`~cryptography.hazmat.backends.interfaces.X509Backend`
162 interface.
163
164 :returns: An instance of
165 :class:`~cryptography.x509.CertificateRevocationList`.
166
167.. function:: load_der_x509_crl(data, backend)
168
169 .. versionadded:: 1.1
170
171 Deserialize a certificate revocation list (CRL) from DER encoded data. DER
172 is a binary format.
173
174 :param bytes data: The DER encoded request data.
175
176 :param backend: A backend supporting the
177 :class:`~cryptography.hazmat.backends.interfaces.X509Backend`
178 interface.
179
180 :returns: An instance of
181 :class:`~cryptography.x509.CertificateRevocationList`.
182
183.. doctest::
184
185 >>> from cryptography import x509
186 >>> from cryptography.hazmat.backends import default_backend
187 >>> from cryptography.hazmat.primitives import hashes
188 >>> crl = x509.load_pem_x509_crl(pem_crl_data, default_backend())
189 >>> isinstance(crl.signature_hash_algorithm, hashes.SHA256)
190 True
191
Paul Kehrera1a1f232015-03-15 15:34:35 -0500192Loading Certificate Signing Requests
193~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600194
Paul Kehrer31e39882015-03-11 11:37:04 -0500195.. function:: load_pem_x509_csr(data, backend)
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600196
197 .. versionadded:: 0.9
198
Paul Kehrera1a1f232015-03-15 15:34:35 -0500199 Deserialize a certificate signing request (CSR) from PEM encoded data. PEM
Paul Kehrer5aadb9c2015-03-11 20:48:42 -0500200 requests are base64 decoded and have delimiters that look like
Paul Kehrerd3dafbd2015-03-15 16:24:18 -0500201 ``-----BEGIN CERTIFICATE REQUEST-----``. This format is also known as
202 PKCS#10.
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600203
204 :param bytes data: The PEM encoded request data.
205
206 :param backend: A backend supporting the
207 :class:`~cryptography.hazmat.backends.interfaces.X509Backend`
208 interface.
209
Paul Kehrera1a1f232015-03-15 15:34:35 -0500210 :returns: An instance of
211 :class:`~cryptography.x509.CertificateSigningRequest`.
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600212
Paul Kehrer1effb6e2015-03-30 15:05:59 -0500213.. function:: load_der_x509_csr(data, backend)
214
215 .. versionadded:: 0.9
216
217 Deserialize a certificate signing request (CSR) from DER encoded data. DER
218 is a binary format and is not commonly used with CSRs.
219
220 :param bytes data: The DER encoded request data.
221
222 :param backend: A backend supporting the
223 :class:`~cryptography.hazmat.backends.interfaces.X509Backend`
224 interface.
225
226 :returns: An instance of
227 :class:`~cryptography.x509.CertificateSigningRequest`.
228
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600229.. doctest::
230
231 >>> from cryptography import x509
232 >>> from cryptography.hazmat.backends import default_backend
233 >>> from cryptography.hazmat.primitives import hashes
Paul Kehrera1a1f232015-03-15 15:34:35 -0500234 >>> csr = x509.load_pem_x509_csr(pem_req_data, default_backend())
235 >>> isinstance(csr.signature_hash_algorithm, hashes.SHA1)
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600236 True
237
Paul Kehrere76cd272014-12-14 19:00:51 -0600238X.509 Certificate Object
239~~~~~~~~~~~~~~~~~~~~~~~~
Paul Kehrerb2de9482014-12-11 14:54:48 -0600240
Paul Kehrere76cd272014-12-14 19:00:51 -0600241.. class:: Certificate
Paul Kehrerb2de9482014-12-11 14:54:48 -0600242
243 .. versionadded:: 0.7
244
245 .. attribute:: version
246
Paul Kehrere76cd272014-12-14 19:00:51 -0600247 :type: :class:`~cryptography.x509.Version`
Paul Kehrerb2de9482014-12-11 14:54:48 -0600248
Paul Kehrere76cd272014-12-14 19:00:51 -0600249 The certificate version as an enumeration. Version 3 certificates are
250 the latest version and also the only type you should see in practice.
Paul Kehrerb2de9482014-12-11 14:54:48 -0600251
Alex Gaynor89c4dc82014-12-16 16:49:33 -0800252 :raises cryptography.x509.InvalidVersion: If the version in the
Alex Gaynor6d7ab4c2014-12-16 16:50:33 -0800253 certificate is not a known
254 :class:`X.509 version <cryptography.x509.Version>`.
Paul Kehrer92aac382014-12-15 16:25:28 -0600255
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600256 .. doctest::
257
258 >>> cert.version
259 <Version.v3: 2>
260
Paul Kehrerb2de9482014-12-11 14:54:48 -0600261 .. method:: fingerprint(algorithm)
262
263 :param algorithm: The
Paul Kehrer601278a2015-02-12 12:51:00 -0600264 :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm`
Paul Kehrerb2de9482014-12-11 14:54:48 -0600265 that will be used to generate the fingerprint.
266
Erik Trauschke2dcce902015-05-14 16:12:24 -0700267 :return bytes: The fingerprint using the supplied hash algorithm, as
Paul Kehrerb2de9482014-12-11 14:54:48 -0600268 bytes.
269
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600270 .. doctest::
271
272 >>> from cryptography.hazmat.primitives import hashes
273 >>> cert.fingerprint(hashes.SHA256())
Paul Kehrer78a81502014-12-16 14:47:52 -0600274 '\x86\xd2\x187Gc\xfc\xe7}[+E9\x8d\xb4\x8f\x10\xe5S\xda\x18u\xbe}a\x03\x08[\xac\xa04?'
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600275
Paul Kehrerb2de9482014-12-11 14:54:48 -0600276 .. attribute:: serial
277
278 :type: int
279
280 The serial as a Python integer.
281
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600282 .. doctest::
283
284 >>> cert.serial
285 2
286
Paul Kehrerb2de9482014-12-11 14:54:48 -0600287 .. method:: public_key()
288
Alex Gaynor4c2561a2015-10-12 23:53:39 -0400289 The public key associated with the certificate.
290
291 :returns:
Alex Stapletonf79c2312014-12-30 12:50:14 +0000292 :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey` or
Paul Kehrer45efdbc2015-02-12 10:58:22 -0600293 :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPublicKey` or
294 :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey`
Paul Kehrerb2de9482014-12-11 14:54:48 -0600295
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600296 .. doctest::
297
Alex Stapletonf79c2312014-12-30 12:50:14 +0000298 >>> from cryptography.hazmat.primitives.asymmetric import rsa
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600299 >>> public_key = cert.public_key()
Alex Stapletonf79c2312014-12-30 12:50:14 +0000300 >>> isinstance(public_key, rsa.RSAPublicKey)
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600301 True
302
Paul Kehrerb2de9482014-12-11 14:54:48 -0600303 .. attribute:: not_valid_before
304
305 :type: :class:`datetime.datetime`
306
Paul Kehrer78a81502014-12-16 14:47:52 -0600307 A naïve datetime representing the beginning of the validity period for
308 the certificate in UTC. This value is inclusive.
Paul Kehrerb2de9482014-12-11 14:54:48 -0600309
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600310 .. doctest::
311
312 >>> cert.not_valid_before
313 datetime.datetime(2010, 1, 1, 8, 30)
314
Paul Kehrerb2de9482014-12-11 14:54:48 -0600315 .. attribute:: not_valid_after
316
317 :type: :class:`datetime.datetime`
318
Paul Kehrer78a81502014-12-16 14:47:52 -0600319 A naïve datetime representing the end of the validity period for the
320 certificate in UTC. This value is inclusive.
Paul Kehrerb2de9482014-12-11 14:54:48 -0600321
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600322 .. doctest::
323
324 >>> cert.not_valid_after
325 datetime.datetime(2030, 12, 31, 8, 30)
326
Paul Kehrer719d5362015-01-01 20:03:52 -0600327 .. attribute:: issuer
328
329 .. versionadded:: 0.8
330
331 :type: :class:`Name`
332
333 The :class:`Name` of the issuer.
334
335 .. attribute:: subject
336
337 .. versionadded:: 0.8
338
339 :type: :class:`Name`
340
341 The :class:`Name` of the subject.
342
Paul Kehrer8802a5b2015-02-13 12:06:57 -0600343 .. attribute:: signature_hash_algorithm
Paul Kehrer56da2a52015-02-11 23:35:07 -0600344
Paul Kehrer8802a5b2015-02-13 12:06:57 -0600345 :type: :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm`
Paul Kehrer56da2a52015-02-11 23:35:07 -0600346
Paul Kehrere612ec72015-02-16 14:33:35 -0600347 Returns the
Paul Kehrer71d40c62015-02-19 08:21:04 -0600348 :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` which
Paul Kehrer1a7ba872015-02-19 18:09:05 -0600349 was used in signing this certificate.
Paul Kehrer56da2a52015-02-11 23:35:07 -0600350
351 .. doctest::
352
Paul Kehrer8802a5b2015-02-13 12:06:57 -0600353 >>> from cryptography.hazmat.primitives import hashes
354 >>> isinstance(cert.signature_hash_algorithm, hashes.SHA256)
355 True
Paul Kehrer719d5362015-01-01 20:03:52 -0600356
Paul Kehrerfbb7ac82015-03-16 19:26:29 -0500357 .. attribute:: extensions
358
359 :type: :class:`Extensions`
360
361 The extensions encoded in the certificate.
362
363 :raises cryptography.x509.DuplicateExtension: If more than one
364 extension of the same type is found within the certificate.
365
Paul Kehrerd8fc0be2015-04-21 08:31:10 -0500366 :raises cryptography.x509.UnsupportedExtension: If the certificate
367 contains an extension that is not supported.
368
Paul Kehrerbed07352015-04-21 08:31:10 -0500369 :raises cryptography.x509.UnsupportedGeneralNameType: If an extension
370 contains a general name that is not supported.
371
Paul Kehrerb8968812015-05-15 09:01:34 -0700372 :raises UnicodeError: If an extension contains IDNA encoding that is
373 invalid or not compliant with IDNA 2008.
374
Paul Kehrerfa56a232015-03-17 13:14:03 -0500375 .. doctest::
376
377 >>> for ext in cert.extensions:
378 ... print(ext)
Paul Kehrerd774de92015-05-03 10:52:25 -0500379 <Extension(oid=<ObjectIdentifier(oid=2.5.29.35, name=authorityKeyIdentifier)>, critical=False, value=<AuthorityKeyIdentifier(key_identifier='\xe4}_\xd1\\\x95\x86\x08,\x05\xae\xbeu\xb6e\xa7\xd9]\xa8f', authority_cert_issuer=None, authority_cert_serial_number=None)>)>
Paul Kehrercbfb1012015-04-10 20:57:20 -0400380 <Extension(oid=<ObjectIdentifier(oid=2.5.29.14, name=subjectKeyIdentifier)>, critical=False, value=<SubjectKeyIdentifier(digest='X\x01\x84$\x1b\xbc+R\x94J=\xa5\x10r\x14Q\xf5\xaf:\xc9')>)>
Paul Kehrerb511ba82015-04-15 11:22:48 -0400381 <Extension(oid=<ObjectIdentifier(oid=2.5.29.15, name=keyUsage)>, critical=True, value=<KeyUsage(digital_signature=False, content_commitment=False, key_encipherment=False, data_encipherment=False, key_agreement=False, key_cert_sign=True, crl_sign=True, encipher_only=None, decipher_only=None)>)>
Paul Kehrer2008d9c2015-05-12 22:19:56 -0500382 <Extension(oid=<ObjectIdentifier(oid=2.5.29.32, name=certificatePolicies)>, critical=False, value=<CertificatePolicies([<PolicyInformation(policy_identifier=<ObjectIdentifier(oid=2.16.840.1.101.3.2.1.48.1, name=Unknown OID)>, policy_qualifiers=None)>])>)>
Paul Kehrerfa56a232015-03-17 13:14:03 -0500383 <Extension(oid=<ObjectIdentifier(oid=2.5.29.19, name=basicConstraints)>, critical=True, value=<BasicConstraints(ca=True, path_length=None)>)>
384
Andre Carona8aded62015-05-19 20:11:57 -0400385 .. method:: public_bytes(encoding)
386
Alex Gaynord0b376b2015-07-05 13:58:12 -0400387 .. versionadded:: 1.0
388
Andre Carona8aded62015-05-19 20:11:57 -0400389 :param encoding: The
390 :class:`~cryptography.hazmat.primitives.serialization.Encoding`
391 that will be used to serialize the certificate.
392
393 :return bytes: The data that can be written to a file or sent
394 over the network to be verified by clients.
395
Erik Trauschke2dcce902015-05-14 16:12:24 -0700396X.509 CRL (Certificate Revocation List) Object
397~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
398
399.. class:: CertificateRevocationList
400
401 .. versionadded:: 1.0
402
Erik Trauschke3cdabaf2015-10-13 09:42:53 -0700403 A CertificateRevocationList is an object representing a list of revoked
404 certificates. The object is iterable and will yield the RevokedCertificate
405 objects stored in this CRL.
406
407 .. doctest::
Erik Trauschkeb14f7d12015-10-13 09:55:39 -0700408
Erik Trauschke3cdabaf2015-10-13 09:42:53 -0700409 >>> len(crl)
410 1
Paul Kehrerdcdf9672015-10-21 20:27:28 -0500411 >>> revoked_certificate = crl[0]
412 >>> type(revoked_certificate)
Erik Trauschke3cdabaf2015-10-13 09:42:53 -0700413 <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::
Erik Trauschke2dcce902015-05-14 16:12:24 -0700477
Erik Trauschkedc570402015-09-24 20:24:28 -0700478 >>> crl.last_update
479 datetime.datetime(2015, 1, 1, 0, 0)
Erik Trauschke2dcce902015-05-14 16:12:24 -0700480
481 .. attribute:: extensions
482
483 :type: :class:`Extensions`
484
485 The extensions encoded in the CRL.
486
Andre Caron9bbfcea2015-05-18 20:55:29 -0400487X.509 Certificate Builder
488~~~~~~~~~~~~~~~~~~~~~~~~~
489
490.. class:: CertificateBuilder
491
Ian Cordasco1517a4b2015-08-02 22:11:19 -0500492 .. versionadded:: 1.0
493
494 .. doctest::
495
496 >>> from cryptography import x509
497 >>> from cryptography.hazmat.backends import default_backend
498 >>> from cryptography.hazmat.primitives import hashes
499 >>> from cryptography.hazmat.primitives.asymmetric import rsa
Paul Kehrere27f6582015-08-10 18:33:38 -0500500 >>> from cryptography.x509.oid import NameOID
Ian Cordasco1517a4b2015-08-02 22:11:19 -0500501 >>> import datetime
502 >>> import uuid
503 >>> one_day = datetime.timedelta(1, 0, 0)
504 >>> private_key = rsa.generate_private_key(
505 ... public_exponent=65537,
506 ... key_size=2048,
507 ... backend=default_backend()
508 ... )
509 >>> public_key = rsa.generate_private_key(
510 ... public_exponent=65537,
511 ... key_size=2048,
512 ... backend=default_backend()
513 ... ).public_key()
514 >>> builder = x509.CertificateBuilder()
515 >>> builder = builder.subject_name(x509.Name([
Paul Kehrere27f6582015-08-10 18:33:38 -0500516 ... x509.NameAttribute(NameOID.COMMON_NAME, u'cryptography.io'),
Ian Cordasco1517a4b2015-08-02 22:11:19 -0500517 ... ]))
518 >>> builder = builder.issuer_name(x509.Name([
Paul Kehrere27f6582015-08-10 18:33:38 -0500519 ... x509.NameAttribute(NameOID.COMMON_NAME, u'cryptography.io'),
Ian Cordasco1517a4b2015-08-02 22:11:19 -0500520 ... ]))
521 >>> builder = builder.not_valid_before(datetime.datetime.today() - one_day)
522 >>> builder = builder.not_valid_after(datetime.datetime(2018, 8, 2))
523 >>> builder = builder.serial_number(int(uuid.uuid4()))
524 >>> builder = builder.public_key(public_key)
525 >>> builder = builder.add_extension(
526 ... x509.BasicConstraints(ca=False, path_length=None), critical=True,
527 ... )
528 >>> certificate = builder.sign(
529 ... private_key=private_key, algorithm=hashes.SHA256(),
530 ... backend=default_backend()
531 ... )
532 >>> isinstance(certificate, x509.Certificate)
533 True
534
Ian Cordasco0092a0b2015-07-18 21:46:41 -0500535 .. method:: issuer_name(name)
Andre Caron9bbfcea2015-05-18 20:55:29 -0400536
537 Sets the issuer's distinguished name.
538
Ian Cordascoc9682ad2015-08-01 12:11:13 -0500539 :param name: The :class:`~cryptography.x509.Name` that describes the
540 issuer (CA).
Andre Caron9bbfcea2015-05-18 20:55:29 -0400541
Ian Cordasco0092a0b2015-07-18 21:46:41 -0500542 .. method:: subject_name(name)
Andre Caron9bbfcea2015-05-18 20:55:29 -0400543
544 Sets the subject's distinguished name.
545
Ian Cordascoc9682ad2015-08-01 12:11:13 -0500546 :param name: The :class:`~cryptography.x509.Name` that describes the
Ian Cordasco85fc4d52015-08-01 20:29:31 -0500547 subject.
Andre Caron9bbfcea2015-05-18 20:55:29 -0400548
Ian Cordasco0092a0b2015-07-18 21:46:41 -0500549 .. method:: public_key(public_key)
Andre Caron9bbfcea2015-05-18 20:55:29 -0400550
551 Sets the subject's public key.
552
Ian Cordasco8f571422015-08-02 11:31:08 -0500553 :param public_key: The subject's public key. This can be one of
554 :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey`,
555 :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPublicKey` or
556 :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey`
Andre Caron9bbfcea2015-05-18 20:55:29 -0400557
Ian Cordasco0092a0b2015-07-18 21:46:41 -0500558 .. method:: serial_number(serial_number)
Andre Caron9bbfcea2015-05-18 20:55:29 -0400559
560 Sets the certificate's serial number (an integer). The CA's policy
561 determines how it attributes serial numbers to certificates. The only
562 requirement is that this number uniquely identify the certificate given
563 the issuer.
564
565 :param serial_number: Integer number that will be used by the CA to
566 identify this certificate (most notably during certificate
Ian Cordasco17c89002015-08-02 21:13:59 -0500567 revocation checking). Users are encouraged to use a method of
568 generating 20 bytes of entropy, e.g., UUID4. For more information
Ian Cordascob7530a42015-08-02 22:47:06 -0500569 on secure random number generation, see :doc:`/random-numbers`.
Andre Caron9bbfcea2015-05-18 20:55:29 -0400570
Ian Cordasco0092a0b2015-07-18 21:46:41 -0500571 .. method:: not_valid_before(time)
Andre Caron9bbfcea2015-05-18 20:55:29 -0400572
573 Sets the certificate's activation time. This is the time from which
574 clients can start trusting the certificate. It may be different from
575 the time at which the certificate was created.
576
Ian Cordasco17c89002015-08-02 21:13:59 -0500577 :param time: The :class:`datetime.datetime` object (in UTC) that marks the
Andre Caron9bbfcea2015-05-18 20:55:29 -0400578 activation time for the certificate. The certificate may not be
579 trusted clients if it is used before this time.
580
Ian Cordasco0092a0b2015-07-18 21:46:41 -0500581 .. method:: not_valid_after(time)
Andre Caron9bbfcea2015-05-18 20:55:29 -0400582
583 Sets the certificate's expiration time. This is the time from which
584 clients should no longer trust the certificate. The CA's policy will
585 determine how long the certificate should remain in use.
586
Ian Cordasco17c89002015-08-02 21:13:59 -0500587 :param time: The :class:`datetime.datetime` object (in UTC) that marks the
Andre Caron9bbfcea2015-05-18 20:55:29 -0400588 expiration time for the certificate. The certificate may not be
589 trusted clients if it is used after this time.
590
Ian Cordasco17c89002015-08-02 21:13:59 -0500591 .. method:: add_extension(extension, critical)
Andre Caron9bbfcea2015-05-18 20:55:29 -0400592
593 Adds an X.509 extension to the certificate.
594
Paul Kehrer2c145cc2015-10-02 11:27:21 -0500595 :param extension: An extension conforming to the
596 :class:`~cryptography.x509.ExtensionType` interface.
Andre Caron9bbfcea2015-05-18 20:55:29 -0400597
Ian Cordasco17c89002015-08-02 21:13:59 -0500598 :param critical: Set to ``True`` if the extension must be understood and
599 handled by whoever reads the certificate.
600
Paul Kehrer9add80e2015-08-03 17:53:14 +0100601 .. method:: sign(private_key, algorithm, backend)
Andre Caron9bbfcea2015-05-18 20:55:29 -0400602
603 Sign the certificate using the CA's private key.
604
Ian Cordascoc5e1c252015-07-31 23:33:35 -0500605 :param private_key: The
606 :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey`,
607 :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPrivateKey` or
608 :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateKey`
609 that will be used to sign the certificate.
610
Andre Caron9bbfcea2015-05-18 20:55:29 -0400611 :param algorithm: The
612 :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` that
613 will be used to generate the signature.
614
Paul Kehrer9add80e2015-08-03 17:53:14 +0100615 :param backend: Backend that will be used to build the certificate.
616 Must support the
617 :class:`~cryptography.hazmat.backends.interfaces.X509Backend`
618 interface.
619
Benjamin Peterson9ed312b2015-10-12 20:51:34 -0700620 :returns: :class:`~cryptography.x509.Certificate`
Andre Caron9bbfcea2015-05-18 20:55:29 -0400621
622
Paul Kehrer5aadb9c2015-03-11 20:48:42 -0500623X.509 CSR (Certificate Signing Request) Object
624~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600625
Paul Kehrera1a1f232015-03-15 15:34:35 -0500626.. class:: CertificateSigningRequest
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600627
628 .. versionadded:: 0.9
629
630 .. method:: public_key()
631
Alex Gaynor4c2561a2015-10-12 23:53:39 -0400632 The public key associated with the request.
633
634 :returns:
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600635 :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey` or
636 :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPublicKey` or
637 :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey`
638
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600639 .. doctest::
640
641 >>> from cryptography.hazmat.primitives.asymmetric import rsa
Paul Kehrera1a1f232015-03-15 15:34:35 -0500642 >>> public_key = csr.public_key()
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600643 >>> isinstance(public_key, rsa.RSAPublicKey)
644 True
645
646 .. attribute:: subject
647
648 :type: :class:`Name`
649
650 The :class:`Name` of the subject.
651
652 .. attribute:: signature_hash_algorithm
653
654 :type: :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm`
655
656 Returns the
657 :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` which
658 was used in signing this request.
659
660 .. doctest::
661
662 >>> from cryptography.hazmat.primitives import hashes
Paul Kehrera1a1f232015-03-15 15:34:35 -0500663 >>> isinstance(csr.signature_hash_algorithm, hashes.SHA1)
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600664 True
665
Paul Kehrerc4e61942015-08-01 21:21:13 +0100666 .. attribute:: extensions
667
668 :type: :class:`Extensions`
669
670 The extensions encoded in the certificate signing request.
671
672 :raises cryptography.x509.DuplicateExtension: If more than one
Paul Kehrer24283d22015-08-01 21:31:19 +0100673 extension of the same type is found within the certificate signing request.
Paul Kehrerc4e61942015-08-01 21:21:13 +0100674
Paul Kehrer24283d22015-08-01 21:31:19 +0100675 :raises cryptography.x509.UnsupportedExtension: If the certificate signing request
Paul Kehrerc4e61942015-08-01 21:21:13 +0100676 contains an extension that is not supported.
677
678 :raises cryptography.x509.UnsupportedGeneralNameType: If an extension
679 contains a general name that is not supported.
680
681 :raises UnicodeError: If an extension contains IDNA encoding that is
682 invalid or not compliant with IDNA 2008.
683
684
Andre Caron476c5df2015-05-18 10:23:28 -0400685 .. method:: public_bytes(encoding)
686
Alex Gaynord0b376b2015-07-05 13:58:12 -0400687 .. versionadded:: 1.0
688
Andre Caron476c5df2015-05-18 10:23:28 -0400689 :param encoding: The
690 :class:`~cryptography.hazmat.primitives.serialization.Encoding`
691 that will be used to serialize the certificate request.
692
693 :return bytes: The data that can be written to a file or sent
694 over the network to be signed by the certificate
695 authority.
696
Erik Trauschke2dcce902015-05-14 16:12:24 -0700697X.509 Revoked Certificate Object
Erik Trauschkec5a8d172015-05-28 10:24:25 -0700698~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Erik Trauschke2dcce902015-05-14 16:12:24 -0700699
700.. class:: RevokedCertificate
701
702 .. versionadded:: 1.0
703
704 .. attribute:: serial_number
705
706 :type: :class:`int`
707
708 An integer representing the serial number of the revoked certificate.
709
Erik Trauschkedc570402015-09-24 20:24:28 -0700710 .. doctest::
711
Erik Trauschke3cdabaf2015-10-13 09:42:53 -0700712 >>> revoked_certificate.serial_number
Erik Trauschkedc570402015-09-24 20:24:28 -0700713 0
714
Erik Trauschke2dcce902015-05-14 16:12:24 -0700715 .. attribute:: revocation_date
716
717 :type: :class:`datetime.datetime`
718
719 A naïve datetime representing the date this certificates was revoked.
720
Erik Trauschkedc570402015-09-24 20:24:28 -0700721 .. doctest::
722
Erik Trauschke77f5a252015-10-14 08:06:38 -0700723 >>> revoked_certificate.revocation_date
Erik Trauschkedc570402015-09-24 20:24:28 -0700724 datetime.datetime(2015, 1, 1, 0, 0)
725
Erik Trauschke2dcce902015-05-14 16:12:24 -0700726 .. attribute:: extensions
727
728 :type: :class:`Extensions`
729
730 The extensions encoded in the revoked certificate.
Andre Caron476c5df2015-05-18 10:23:28 -0400731
Erik Trauschkedc570402015-09-24 20:24:28 -0700732 .. doctest::
733
Erik Trauschke77f5a252015-10-14 08:06:38 -0700734 >>> for ext in revoked_certificate.extensions:
Erik Trauschkedc570402015-09-24 20:24:28 -0700735 ... print(ext)
736 <Extension(oid=<ObjectIdentifier(oid=2.5.29.24, name=invalidityDate)>, critical=False, value=2015-01-01 00:00:00)>
737 <Extension(oid=<ObjectIdentifier(oid=2.5.29.21, name=cRLReason)>, critical=False, value=ReasonFlags.key_compromise)>
738
Andre Caron0ef595f2015-05-18 13:53:43 -0400739X.509 CSR (Certificate Signing Request) Builder Object
740~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
741
742.. class:: CertificateSigningRequestBuilder
743
Andre Carond259ee52015-06-02 23:47:11 -0400744 .. versionadded:: 1.0
745
746 .. doctest::
747
748 >>> from cryptography import x509
749 >>> from cryptography.hazmat.backends import default_backend
750 >>> from cryptography.hazmat.primitives import hashes
751 >>> from cryptography.hazmat.primitives.asymmetric import rsa
Paul Kehrere27f6582015-08-10 18:33:38 -0500752 >>> from cryptography.x509.oid import NameOID
Andre Carond259ee52015-06-02 23:47:11 -0400753 >>> private_key = rsa.generate_private_key(
754 ... public_exponent=65537,
755 ... key_size=2048,
756 ... backend=default_backend()
757 ... )
758 >>> builder = x509.CertificateSigningRequestBuilder()
Andre Carona9a51172015-06-06 20:18:44 -0400759 >>> builder = builder.subject_name(x509.Name([
Paul Kehrere27f6582015-08-10 18:33:38 -0500760 ... x509.NameAttribute(NameOID.COMMON_NAME, u'cryptography.io'),
Andre Carond259ee52015-06-02 23:47:11 -0400761 ... ]))
Ian Cordascof06b6be2015-06-21 10:09:18 -0500762 >>> builder = builder.add_extension(
Ian Cordasco0112b022015-06-16 17:51:18 -0500763 ... x509.BasicConstraints(ca=False, path_length=None), critical=True,
Andre Caron472fd692015-06-06 20:04:44 -0400764 ... )
Andre Carond259ee52015-06-02 23:47:11 -0400765 >>> request = builder.sign(
Alex Gaynorde9e5842015-06-26 20:11:23 -0400766 ... private_key, hashes.SHA256(), default_backend()
Andre Carond259ee52015-06-02 23:47:11 -0400767 ... )
768 >>> isinstance(request, x509.CertificateSigningRequest)
769 True
770
Andre Carona9a51172015-06-06 20:18:44 -0400771 .. method:: subject_name(name)
Andre Caron0ef595f2015-05-18 13:53:43 -0400772
Andre Caron341ff852015-06-06 20:14:31 -0400773 :param name: The :class:`~cryptography.x509.Name` of the certificate
774 subject.
775 :returns: A new
776 :class:`~cryptography.x509.CertificateSigningRequestBuilder`.
Andre Caron0ef595f2015-05-18 13:53:43 -0400777
Ian Cordascof06b6be2015-06-21 10:09:18 -0500778 .. method:: add_extension(extension, critical)
Andre Caron0ef595f2015-05-18 13:53:43 -0400779
Paul Kehrer2c145cc2015-10-02 11:27:21 -0500780 :param extension: An extension conforming to the
781 :class:`~cryptography.x509.ExtensionType` interface.
Andre Caron472fd692015-06-06 20:04:44 -0400782 :param critical: Set to `True` if the extension must be understood and
783 handled by whoever reads the certificate.
Andre Caron341ff852015-06-06 20:14:31 -0400784 :returns: A new
785 :class:`~cryptography.x509.CertificateSigningRequestBuilder`.
Andre Caron0ef595f2015-05-18 13:53:43 -0400786
Alex Gaynorb3b0fbe2015-06-26 19:57:18 -0400787 .. method:: sign(private_key, algorithm, backend)
Andre Caron0ef595f2015-05-18 13:53:43 -0400788
789 :param backend: Backend that will be used to sign the request.
790 Must support the
791 :class:`~cryptography.hazmat.backends.interfaces.X509Backend`
792 interface.
793
794 :param private_key: The
Andre Caron24f9bf42015-06-06 20:14:54 -0400795 :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey`,
796 :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPrivateKey` or
797 :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateKey`
Andre Caron0ef595f2015-05-18 13:53:43 -0400798 that will be used to sign the request. When the request is
799 signed by a certificate authority, the private key's associated
800 public key will be stored in the resulting certificate.
801
802 :param algorithm: The
803 :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm`
804 that will be used to generate the request signature.
805
Andre Caron341ff852015-06-06 20:14:31 -0400806 :returns: A new
807 :class:`~cryptography.x509.CertificateSigningRequest`.
Andre Caron0ef595f2015-05-18 13:53:43 -0400808
809
Paul Kehrer719d5362015-01-01 20:03:52 -0600810.. class:: Name
811
812 .. versionadded:: 0.8
813
Paul Kehrer53d8d492015-02-13 18:47:30 -0600814 An X509 Name is an ordered list of attributes. The object is iterable to
Paul Kehrerd21596e2015-02-14 09:17:26 -0600815 get every attribute or you can use :meth:`Name.get_attributes_for_oid` to
Paul Kehrer719d5362015-01-01 20:03:52 -0600816 obtain the specific type you want. Names are sometimes represented as a
Paul Kehrer53d8d492015-02-13 18:47:30 -0600817 slash or comma delimited string (e.g. ``/CN=mydomain.com/O=My Org/C=US`` or
818 ``CN=mydomain.com, O=My Org, C=US``).
Paul Kehrer719d5362015-01-01 20:03:52 -0600819
Paul Kehrer53d8d492015-02-13 18:47:30 -0600820 .. doctest::
Paul Kehrer719d5362015-01-01 20:03:52 -0600821
Paul Kehrer8b21a4a2015-02-14 07:56:36 -0600822 >>> len(cert.subject)
Paul Kehrer53d8d492015-02-13 18:47:30 -0600823 3
Paul Kehrer8b21a4a2015-02-14 07:56:36 -0600824 >>> for attribute in cert.subject:
825 ... print(attribute)
826 <NameAttribute(oid=<ObjectIdentifier(oid=2.5.4.6, name=countryName)>, value=u'US')>
827 <NameAttribute(oid=<ObjectIdentifier(oid=2.5.4.10, name=organizationName)>, value=u'Test Certificates 2011')>
828 <NameAttribute(oid=<ObjectIdentifier(oid=2.5.4.3, name=commonName)>, value=u'Good CA')>
Paul Kehrer719d5362015-01-01 20:03:52 -0600829
Paul Kehrere901d642015-02-11 18:50:58 -0600830 .. method:: get_attributes_for_oid(oid)
Paul Kehrer719d5362015-01-01 20:03:52 -0600831
Paul Kehrere901d642015-02-11 18:50:58 -0600832 :param oid: An :class:`ObjectIdentifier` instance.
Paul Kehrer719d5362015-01-01 20:03:52 -0600833
Paul Kehrere901d642015-02-11 18:50:58 -0600834 :returns: A list of :class:`NameAttribute` instances that match the
835 OID provided. If nothing matches an empty list will be returned.
Paul Kehrer719d5362015-01-01 20:03:52 -0600836
837 .. doctest::
838
Paul Kehrere27f6582015-08-10 18:33:38 -0500839 >>> cert.subject.get_attributes_for_oid(NameOID.COMMON_NAME)
Paul Kehrere901d642015-02-11 18:50:58 -0600840 [<NameAttribute(oid=<ObjectIdentifier(oid=2.5.4.3, name=commonName)>, value=u'Good CA')>]
Paul Kehrerb2de9482014-12-11 14:54:48 -0600841
Paul Kehrere76cd272014-12-14 19:00:51 -0600842.. class:: Version
Paul Kehrer016e08a2014-11-26 09:41:18 -1000843
844 .. versionadded:: 0.7
845
846 An enumeration for X.509 versions.
847
848 .. attribute:: v1
849
850 For version 1 X.509 certificates.
851
852 .. attribute:: v3
853
854 For version 3 X.509 certificates.
855
Paul Kehrer806bfb22015-02-02 17:05:24 -0600856.. class:: NameAttribute
Paul Kehrer912d3fb2015-01-29 11:19:22 -0600857
858 .. versionadded:: 0.8
859
Paul Kehrer834d22f2015-02-06 11:01:07 -0600860 An X.509 name consists of a list of NameAttribute instances.
Paul Kehrer5b0a8d62015-01-30 20:05:55 -0600861
Paul Kehrer912d3fb2015-01-29 11:19:22 -0600862 .. attribute:: oid
863
864 :type: :class:`ObjectIdentifier`
865
866 The attribute OID.
867
868 .. attribute:: value
869
Paul Kehrerd5852cb2015-01-30 08:25:23 -0600870 :type: :term:`text`
Paul Kehrer912d3fb2015-01-29 11:19:22 -0600871
872 The value of the attribute.
873
874.. class:: ObjectIdentifier
875
876 .. versionadded:: 0.8
877
Paul Kehrer5b0a8d62015-01-30 20:05:55 -0600878 Object identifiers (frequently seen abbreviated as OID) identify the type
Paul Kehrer806bfb22015-02-02 17:05:24 -0600879 of a value (see: :class:`NameAttribute`).
Paul Kehrer5b0a8d62015-01-30 20:05:55 -0600880
Paul Kehrerd44f9a62015-02-04 14:47:34 -0600881 .. attribute:: dotted_string
Paul Kehrer912d3fb2015-01-29 11:19:22 -0600882
883 :type: :class:`str`
884
Paul Kehrerfedf4f42015-02-06 11:22:07 -0600885 The dotted string value of the OID (e.g. ``"2.5.4.3"``)
Paul Kehrer912d3fb2015-01-29 11:19:22 -0600886
Paul Kehrer31bdf792015-03-25 14:11:00 -0500887.. _general_name_classes:
888
889General Name Classes
890~~~~~~~~~~~~~~~~~~~~
891
892.. class:: GeneralName
893
894 .. versionadded:: 0.9
895
896 This is the generic interface that all the following classes are registered
897 against.
898
899.. class:: RFC822Name
900
901 .. versionadded:: 0.9
902
903 This corresponds to an email address. For example, ``user@example.com``.
904
905 .. attribute:: value
906
907 :type: :term:`text`
908
909.. class:: DNSName
910
911 .. versionadded:: 0.9
912
913 This corresponds to a domain name. For example, ``cryptography.io``.
914
915 .. attribute:: value
916
917 :type: :term:`text`
918
919.. class:: DirectoryName
920
921 .. versionadded:: 0.9
922
923 This corresponds to a directory name.
924
925 .. attribute:: value
926
927 :type: :class:`Name`
928
929.. class:: UniformResourceIdentifier
930
931 .. versionadded:: 0.9
932
933 This corresponds to a uniform resource identifier. For example,
Paul Kehrerb8ef82e2015-04-22 16:04:24 -0500934 ``https://cryptography.io``. The URI is parsed and IDNA decoded (see
935 :rfc:`5895`).
936
937 .. note::
938
939 URIs that do not contain ``://`` in them will not be decoded.
Paul Kehrer31bdf792015-03-25 14:11:00 -0500940
941 .. attribute:: value
942
943 :type: :term:`text`
944
945.. class:: IPAddress
946
947 .. versionadded:: 0.9
948
949 This corresponds to an IP address.
950
951 .. attribute:: value
952
Paul Kehrereb177932015-05-17 18:33:33 -0700953 :type: :class:`~ipaddress.IPv4Address`,
954 :class:`~ipaddress.IPv6Address`, :class:`~ipaddress.IPv4Network`,
955 or :class:`~ipaddress.IPv6Network`.
Paul Kehrer31bdf792015-03-25 14:11:00 -0500956
957.. class:: RegisteredID
958
959 .. versionadded:: 0.9
960
961 This corresponds to a registered ID.
962
963 .. attribute:: value
964
965 :type: :class:`ObjectIdentifier`
966
Joshua Tauberer2ee5e3c2015-07-04 20:09:46 +0000967.. class:: OtherName
968
969 .. versionadded:: 1.0
970
Joshua Tauberer18b6fc82015-07-05 21:44:51 +0000971 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 +0000972
973 .. attribute:: type_id
974
975 :type: :class:`ObjectIdentifier`
976
977 .. attribute:: value
978
979 :type: `bytes`
980
Paul Kehrer8cf26422015-03-21 09:50:24 -0500981X.509 Extensions
982~~~~~~~~~~~~~~~~
983
Paul Kehrerfbb7ac82015-03-16 19:26:29 -0500984.. class:: Extensions
985
986 .. versionadded:: 0.9
987
988 An X.509 Extensions instance is an ordered list of extensions. The object
989 is iterable to get every extension.
990
Paul Kehrerfa56a232015-03-17 13:14:03 -0500991 .. method:: get_extension_for_oid(oid)
992
993 :param oid: An :class:`ObjectIdentifier` instance.
994
995 :returns: An instance of the extension class.
996
997 :raises cryptography.x509.ExtensionNotFound: If the certificate does
998 not have the extension requested.
999
Paul Kehrerfa56a232015-03-17 13:14:03 -05001000 .. doctest::
1001
Paul Kehrere27f6582015-08-10 18:33:38 -05001002 >>> from cryptography.x509.oid import ExtensionOID
1003 >>> cert.extensions.get_extension_for_oid(ExtensionOID.BASIC_CONSTRAINTS)
Paul Kehrerfa56a232015-03-17 13:14:03 -05001004 <Extension(oid=<ObjectIdentifier(oid=2.5.29.19, name=basicConstraints)>, critical=True, value=<BasicConstraints(ca=True, path_length=None)>)>
1005
Phoebe Queen019b7f82015-08-12 03:52:03 +01001006 .. method:: get_extension_for_class(extclass)
1007
Phoebe Queen6a603eb2015-08-12 14:14:49 +01001008 .. versionadded:: 1.1
1009
Phoebe Queen019b7f82015-08-12 03:52:03 +01001010 :param extclass: An extension class.
1011
1012 :returns: An instance of the extension class.
1013
1014 :raises cryptography.x509.ExtensionNotFound: If the certificate does
1015 not have the extension requested.
1016
1017 .. doctest::
1018
1019 >>> from cryptography import x509
1020 >>> cert.extensions.get_extension_for_class(x509.BasicConstraints)
1021 <Extension(oid=<ObjectIdentifier(oid=2.5.29.19, name=basicConstraints)>, critical=True, value=<BasicConstraints(ca=True, path_length=None)>)>
1022
Paul Kehrer8cf26422015-03-21 09:50:24 -05001023.. class:: Extension
1024
1025 .. versionadded:: 0.9
1026
Paul Kehrer85894662015-03-22 13:19:31 -05001027 .. attribute:: oid
1028
1029 :type: :class:`ObjectIdentifier`
1030
Paul Kehrere27f6582015-08-10 18:33:38 -05001031 One of the :class:`~cryptography.x509.oid.ExtensionOID` OIDs.
Paul Kehrer8cf26422015-03-21 09:50:24 -05001032
1033 .. attribute:: critical
1034
1035 :type: bool
1036
Paul Kehrer58b75692015-03-22 23:24:58 -05001037 Determines whether a given extension is critical or not. :rfc:`5280`
1038 requires that "A certificate-using system MUST reject the certificate
1039 if it encounters a critical extension it does not recognize or a
1040 critical extension that contains information that it cannot process".
Paul Kehrer8cf26422015-03-21 09:50:24 -05001041
Paul Kehrer85894662015-03-22 13:19:31 -05001042 .. attribute:: value
1043
1044 Returns an instance of the extension type corresponding to the OID.
1045
Paul Kehrer14f0bd02015-08-06 11:55:18 +01001046.. class:: ExtensionType
1047
1048 .. versionadded:: 1.0
1049
1050 This is the interface against which all the following extension types are
1051 registered.
1052
Paul Kehrercecbbba2015-03-30 14:58:38 -05001053.. class:: KeyUsage
1054
1055 .. versionadded:: 0.9
1056
1057 The key usage extension defines the purpose of the key contained in the
1058 certificate. The usage restriction might be employed when a key that could
Paul Kehrerb33de932015-08-06 23:41:05 +01001059 be used for more than one operation is to be restricted.
Paul Kehrercecbbba2015-03-30 14:58:38 -05001060
Paul Kehrer822f3d32015-08-06 11:47:32 +01001061 .. attribute:: oid
1062
1063 .. versionadded:: 1.0
1064
1065 :type: :class:`ObjectIdentifier`
1066
Paul Kehrere27f6582015-08-10 18:33:38 -05001067 Returns :attr:`~cryptography.x509.oid.ExtensionOID.KEY_USAGE`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001068
Paul Kehrercecbbba2015-03-30 14:58:38 -05001069 .. attribute:: digital_signature
1070
1071 :type: bool
1072
Paul Kehrer738407b2015-04-01 22:39:02 -05001073 This purpose is set to true when the subject public key is used for verifying
Paul Kehrercecbbba2015-03-30 14:58:38 -05001074 digital signatures, other than signatures on certificates
1075 (``key_cert_sign``) and CRLs (``crl_sign``).
1076
1077 .. attribute:: content_commitment
1078
1079 :type: bool
1080
Paul Kehrer738407b2015-04-01 22:39:02 -05001081 This purpose is set to true when the subject public key is used for verifying
Paul Kehrercecbbba2015-03-30 14:58:38 -05001082 digital signatures, other than signatures on certificates
1083 (``key_cert_sign``) and CRLs (``crl_sign``). It is used to provide a
1084 non-repudiation service that protects against the signing entity
1085 falsely denying some action. In the case of later conflict, a
1086 reliable third party may determine the authenticity of the signed
1087 data. This was called ``non_repudiation`` in older revisions of the
1088 X.509 specification.
1089
1090 .. attribute:: key_encipherment
1091
1092 :type: bool
1093
Paul Kehrer738407b2015-04-01 22:39:02 -05001094 This purpose is set to true when the subject public key is used for
1095 enciphering private or secret keys.
Paul Kehrercecbbba2015-03-30 14:58:38 -05001096
1097 .. attribute:: data_encipherment
1098
1099 :type: bool
1100
Paul Kehrer738407b2015-04-01 22:39:02 -05001101 This purpose is set to true when the subject public key is used for
1102 directly enciphering raw user data without the use of an intermediate
1103 symmetric cipher.
Paul Kehrercecbbba2015-03-30 14:58:38 -05001104
1105 .. attribute:: key_agreement
1106
1107 :type: bool
1108
Paul Kehrer738407b2015-04-01 22:39:02 -05001109 This purpose is set to true when the subject public key is used for key
1110 agreement. For example, when a Diffie-Hellman key is to be used for
1111 key management, then this purpose is set to true.
Paul Kehrercecbbba2015-03-30 14:58:38 -05001112
1113 .. attribute:: key_cert_sign
1114
1115 :type: bool
1116
Paul Kehrer738407b2015-04-01 22:39:02 -05001117 This purpose is set to true when the subject public key is used for
1118 verifying signatures on public key certificates. If this purpose is set
1119 to true then ``ca`` must be true in the :class:`BasicConstraints`
1120 extension.
Paul Kehrercecbbba2015-03-30 14:58:38 -05001121
1122 .. attribute:: crl_sign
1123
1124 :type: bool
1125
Paul Kehrer738407b2015-04-01 22:39:02 -05001126 This purpose is set to true when the subject public key is used for
1127 verifying signatures on certificate revocation lists.
Paul Kehrercecbbba2015-03-30 14:58:38 -05001128
1129 .. attribute:: encipher_only
1130
1131 :type: bool
1132
Paul Kehrer738407b2015-04-01 22:39:02 -05001133 When this purposes is set to true and the ``key_agreement`` purpose is
1134 also set, the subject public key may be used only for enciphering data
1135 while performing key agreement.
Paul Kehrercecbbba2015-03-30 14:58:38 -05001136
1137 :raises ValueError: This is raised if accessed when ``key_agreement``
1138 is false.
1139
1140 .. attribute:: decipher_only
1141
1142 :type: bool
1143
Paul Kehrer738407b2015-04-01 22:39:02 -05001144 When this purposes is set to true and the ``key_agreement`` purpose is
1145 also set, the subject public key may be used only for deciphering data
1146 while performing key agreement.
Paul Kehrercecbbba2015-03-30 14:58:38 -05001147
1148 :raises ValueError: This is raised if accessed when ``key_agreement``
1149 is false.
1150
1151
Paul Kehrer8cf26422015-03-21 09:50:24 -05001152.. class:: BasicConstraints
1153
1154 .. versionadded:: 0.9
1155
Paul Kehrer85894662015-03-22 13:19:31 -05001156 Basic constraints is an X.509 extension type that defines whether a given
Paul Kehrer8cf26422015-03-21 09:50:24 -05001157 certificate is allowed to sign additional certificates and what path
Paul Kehrerb33de932015-08-06 23:41:05 +01001158 length restrictions may exist.
Paul Kehrer8cf26422015-03-21 09:50:24 -05001159
Paul Kehrer822f3d32015-08-06 11:47:32 +01001160 .. attribute:: oid
1161
1162 .. versionadded:: 1.0
1163
1164 :type: :class:`ObjectIdentifier`
1165
Paul Kehrere27f6582015-08-10 18:33:38 -05001166 Returns :attr:`~cryptography.x509.oid.ExtensionOID.BASIC_CONSTRAINTS`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001167
Paul Kehrer8cf26422015-03-21 09:50:24 -05001168 .. attribute:: ca
1169
1170 :type: bool
1171
1172 Whether the certificate can sign certificates.
1173
1174 .. attribute:: path_length
1175
Paul Kehrerfd1444c2015-03-21 19:47:05 -05001176 :type: int or None
Paul Kehrer8cf26422015-03-21 09:50:24 -05001177
1178 The maximum path length for certificates subordinate to this
1179 certificate. This attribute only has meaning if ``ca`` is true.
1180 If ``ca`` is true then a path length of None means there's no
1181 restriction on the number of subordinate CAs in the certificate chain.
Alex Gaynor99c5f152015-05-03 10:01:04 -04001182 If it is zero or greater then it defines the maximum length for a
1183 subordinate CA's certificate chain. For example, a ``path_length`` of 1
1184 means the certificate can sign a subordinate CA, but the subordinate CA
1185 is not allowed to create subordinates with ``ca`` set to true.
Paul Kehrer8cf26422015-03-21 09:50:24 -05001186
Paul Kehrerffa2a152015-03-31 08:18:25 -05001187.. class:: ExtendedKeyUsage
1188
1189 .. versionadded:: 0.9
1190
1191 This extension indicates one or more purposes for which the certified
1192 public key may be used, in addition to or in place of the basic
1193 purposes indicated in the key usage extension. The object is
Paul Kehrere27f6582015-08-10 18:33:38 -05001194 iterable to obtain the list of
1195 :class:`~cryptography.x509.oid.ExtendedKeyUsageOID` OIDs present.
Paul Kehrerffa2a152015-03-31 08:18:25 -05001196
Paul Kehrer822f3d32015-08-06 11:47:32 +01001197 .. attribute:: oid
1198
1199 .. versionadded:: 1.0
1200
1201 :type: :class:`ObjectIdentifier`
1202
Paul Kehrere27f6582015-08-10 18:33:38 -05001203 Returns :attr:`~cryptography.x509.oid.ExtensionOID.EXTENDED_KEY_USAGE`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001204
1205
Paul Kehrer4a1038e2015-05-18 10:28:31 -07001206.. class:: OCSPNoCheck
1207
Paul Kehrer506a2152015-05-26 08:01:18 -05001208 .. versionadded:: 1.0
Paul Kehrer4a1038e2015-05-18 10:28:31 -07001209
1210 This presence of this extension indicates that an OCSP client can trust a
1211 responder for the lifetime of the responder's certificate. CAs issuing
1212 such a certificate should realize that a compromise of the responder's key
1213 is as serious as the compromise of a CA key used to sign CRLs, at least for
1214 the validity period of this certificate. CA's may choose to issue this type
1215 of certificate with a very short lifetime and renew it frequently. This
1216 extension is only relevant when the certificate is an authorized OCSP
1217 responder.
1218
Paul Kehrer822f3d32015-08-06 11:47:32 +01001219 .. attribute:: oid
1220
1221 .. versionadded:: 1.0
1222
1223 :type: :class:`ObjectIdentifier`
1224
Paul Kehrere27f6582015-08-10 18:33:38 -05001225 Returns :attr:`~cryptography.x509.oid.ExtensionOID.OCSP_NO_CHECK`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001226
Paul Kehrere0017be2015-05-17 20:39:40 -06001227.. class:: NameConstraints
1228
1229 .. versionadded:: 1.0
1230
1231 The name constraints extension, which only has meaning in a CA certificate,
1232 defines a name space within which all subject names in certificates issued
1233 beneath the CA certificate must (or must not) be in. For specific details
1234 on the way this extension should be processed see :rfc:`5280`.
1235
Paul Kehrer822f3d32015-08-06 11:47:32 +01001236 .. attribute:: oid
1237
1238 .. versionadded:: 1.0
1239
1240 :type: :class:`ObjectIdentifier`
1241
Paul Kehrere27f6582015-08-10 18:33:38 -05001242 Returns :attr:`~cryptography.x509.oid.ExtensionOID.NAME_CONSTRAINTS`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001243
Paul Kehrere0017be2015-05-17 20:39:40 -06001244 .. attribute:: permitted_subtrees
1245
1246 :type: list of :class:`GeneralName` objects or None
1247
1248 The set of permitted name patterns. If a name matches this and an
1249 element in ``excluded_subtrees`` it is invalid. At least one of
1250 ``permitted_subtrees`` and ``excluded_subtrees`` will be non-None.
1251
1252 .. attribute:: excluded_subtrees
1253
1254 :type: list of :class:`GeneralName` objects or None
1255
1256 Any name matching a restriction in the ``excluded_subtrees`` field is
1257 invalid regardless of information appearing in the
1258 ``permitted_subtrees``. At least one of ``permitted_subtrees`` and
1259 ``excluded_subtrees`` will be non-None.
1260
Paul Kehrer2eb4ed92015-04-11 15:33:45 -04001261.. class:: AuthorityKeyIdentifier
1262
1263 .. versionadded:: 0.9
1264
1265 The authority key identifier extension provides a means of identifying the
1266 public key corresponding to the private key used to sign a certificate.
Paul Kehrer8c8cd722015-04-19 09:15:04 -05001267 This extension is typically used to assist in determining the appropriate
1268 certificate chain. For more information about generation and use of this
1269 extension see `RFC 5280 section 4.2.1.1`_.
Paul Kehrer2eb4ed92015-04-11 15:33:45 -04001270
Paul Kehrer822f3d32015-08-06 11:47:32 +01001271 .. attribute:: oid
1272
1273 .. versionadded:: 1.0
1274
1275 :type: :class:`ObjectIdentifier`
1276
Paul Kehrere27f6582015-08-10 18:33:38 -05001277 Returns
1278 :attr:`~cryptography.x509.oid.ExtensionOID.AUTHORITY_KEY_IDENTIFIER`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001279
Paul Kehrer2eb4ed92015-04-11 15:33:45 -04001280 .. attribute:: key_identifier
1281
1282 :type: bytes
1283
Paul Kehrer9104b1d2015-04-18 09:23:44 -05001284 A value derived from the public key used to verify the certificate's
Paul Kehrer8c8cd722015-04-19 09:15:04 -05001285 signature.
Paul Kehrer9104b1d2015-04-18 09:23:44 -05001286
Paul Kehrer2eb4ed92015-04-11 15:33:45 -04001287 .. attribute:: authority_cert_issuer
1288
1289 :type: :class:`Name` or None
1290
Paul Kehrer9104b1d2015-04-18 09:23:44 -05001291 The :class:`Name` of the issuer's issuer.
1292
Paul Kehrer2eb4ed92015-04-11 15:33:45 -04001293 .. attribute:: authority_cert_serial_number
1294
1295 :type: int or None
1296
Paul Kehrer9104b1d2015-04-18 09:23:44 -05001297 The serial number of the issuer's issuer.
1298
Paul Kehrer253929a2015-08-05 17:30:39 +01001299 .. classmethod:: from_issuer_public_key(public_key)
1300
1301 .. versionadded:: 1.0
1302
1303 Creates a new AuthorityKeyIdentifier instance using the public key
1304 provided to generate the appropriate digest. This should be the
Paul Kehrer26ac47f2015-08-08 15:20:52 -05001305 **issuer's public key**. The resulting object will contain
1306 :attr:`~cryptography.x509.AuthorityKeyIdentifier.key_identifier`, but
1307 :attr:`~cryptography.x509.AuthorityKeyIdentifier.authority_cert_issuer`
1308 and
1309 :attr:`~cryptography.x509.AuthorityKeyIdentifier.authority_cert_serial_number`
1310 will be None.
1311 The generated ``key_identifier`` is the SHA1 hash of the ``subjectPublicKey``
1312 ASN.1 bit string. This is the first recommendation in :rfc:`5280`
Paul Kehrer253929a2015-08-05 17:30:39 +01001313 section 4.2.1.2.
1314
Paul Kehrercc671822015-08-08 15:41:54 -05001315 :param public_key: One of
1316 :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey`
1317 ,
1318 :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPublicKey`
1319 , or
1320 :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey`.
Paul Kehrer253929a2015-08-05 17:30:39 +01001321
1322 .. doctest::
1323
1324 >>> from cryptography import x509
1325 >>> from cryptography.hazmat.backends import default_backend
Paul Kehrercc671822015-08-08 15:41:54 -05001326 >>> issuer_cert = x509.load_pem_x509_certificate(pem_data, default_backend())
1327 >>> x509.AuthorityKeyIdentifier.from_issuer_public_key(issuer_cert.public_key())
Paul Kehrer253929a2015-08-05 17:30:39 +01001328 <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)>
1329
Paul Kehrer1eb82a62015-03-31 20:00:33 -05001330.. class:: SubjectKeyIdentifier
1331
1332 .. versionadded:: 0.9
1333
1334 The subject key identifier extension provides a means of identifying
1335 certificates that contain a particular public key.
1336
Paul Kehrer822f3d32015-08-06 11:47:32 +01001337 .. attribute:: oid
1338
1339 .. versionadded:: 1.0
1340
1341 :type: :class:`ObjectIdentifier`
1342
Paul Kehrere27f6582015-08-10 18:33:38 -05001343 Returns
1344 :attr:`~cryptography.x509.oid.ExtensionOID.SUBJECT_KEY_IDENTIFIER`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001345
Paul Kehrer1eb82a62015-03-31 20:00:33 -05001346 .. attribute:: digest
1347
1348 :type: bytes
1349
1350 The binary value of the identifier.
1351
Paul Kehrerd4a7f062015-08-05 18:32:18 +01001352 .. classmethod:: from_public_key(public_key)
Paul Kehrerf22f6122015-08-05 12:57:13 +01001353
1354 .. versionadded:: 1.0
1355
1356 Creates a new SubjectKeyIdentifier instance using the public key
1357 provided to generate the appropriate digest. This should be the public
Paul Kehrereb9ec002015-08-08 10:03:02 -05001358 key that is in the certificate. The generated digest is the SHA1 hash
1359 of the ``subjectPublicKey`` ASN.1 bit string. This is the first
1360 recommendation in :rfc:`5280` section 4.2.1.2.
Paul Kehrerf22f6122015-08-05 12:57:13 +01001361
1362 :param public_key: One of
1363 :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey`
1364 ,
1365 :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPublicKey`
1366 , or
1367 :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey`.
1368
Paul Kehrer253929a2015-08-05 17:30:39 +01001369 .. doctest::
1370
1371 >>> from cryptography import x509
1372 >>> from cryptography.hazmat.backends import default_backend
Paul Kehrercc671822015-08-08 15:41:54 -05001373 >>> csr = x509.load_pem_x509_csr(pem_req_data, default_backend())
1374 >>> x509.SubjectKeyIdentifier.from_public_key(csr.public_key())
1375 <SubjectKeyIdentifier(digest='\xdb\xaa\xf0\x06\x11\xdbD\xfe\xbf\x93\x03\x8av\x88WP7\xa6\x91\xf7')>
Paul Kehrer253929a2015-08-05 17:30:39 +01001376
Paul Kehrer31bdf792015-03-25 14:11:00 -05001377.. class:: SubjectAlternativeName
1378
1379 .. versionadded:: 0.9
1380
1381 Subject alternative name is an X.509 extension that provides a list of
1382 :ref:`general name <general_name_classes>` instances that provide a set
1383 of identities for which the certificate is valid. The object is iterable to
1384 get every element.
1385
Paul Kehrer822f3d32015-08-06 11:47:32 +01001386 .. attribute:: oid
1387
1388 .. versionadded:: 1.0
1389
1390 :type: :class:`ObjectIdentifier`
1391
Paul Kehrere27f6582015-08-10 18:33:38 -05001392 Returns
1393 :attr:`~cryptography.x509.oid.ExtensionOID.SUBJECT_ALTERNATIVE_NAME`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001394
Paul Kehrer31bdf792015-03-25 14:11:00 -05001395 .. method:: get_values_for_type(type)
1396
1397 :param type: A :class:`GeneralName` provider. This is one of the
1398 :ref:`general name classes <general_name_classes>`.
1399
1400 :returns: A list of values extracted from the matched general names.
Joshua Taubererd2afad32015-07-06 22:37:53 +00001401 The type of the returned values depends on the :class:`GeneralName`.
Paul Kehrer31bdf792015-03-25 14:11:00 -05001402
Paul Kehrer93ae8052015-05-02 23:18:09 -05001403 .. doctest::
1404
1405 >>> from cryptography import x509
1406 >>> from cryptography.hazmat.backends import default_backend
1407 >>> from cryptography.hazmat.primitives import hashes
1408 >>> cert = x509.load_pem_x509_certificate(cryptography_cert_pem, default_backend())
Paul Kehrerd0cd5072015-05-02 23:27:00 -05001409 >>> # Get the subjectAltName extension from the certificate
Paul Kehrere27f6582015-08-10 18:33:38 -05001410 >>> ext = cert.extensions.get_extension_for_oid(ExtensionOID.SUBJECT_ALTERNATIVE_NAME)
Paul Kehrerd0cd5072015-05-02 23:27:00 -05001411 >>> # Get the dNSName entries from the SAN extension
1412 >>> ext.value.get_values_for_type(x509.DNSName)
Paul Kehrer93ae8052015-05-02 23:18:09 -05001413 [u'www.cryptography.io', u'cryptography.io']
1414
Paul Kehrer8cf26422015-03-21 09:50:24 -05001415
Paul Kehrer99125c92015-06-07 18:37:10 -05001416.. class:: IssuerAlternativeName
1417
1418 .. versionadded:: 1.0
1419
1420 Issuer alternative name is an X.509 extension that provides a list of
1421 :ref:`general name <general_name_classes>` instances that provide a set
1422 of identities for the certificate issuer. The object is iterable to
1423 get every element.
1424
Paul Kehrer822f3d32015-08-06 11:47:32 +01001425 .. attribute:: oid
1426
1427 .. versionadded:: 1.0
1428
1429 :type: :class:`ObjectIdentifier`
1430
Paul Kehrere27f6582015-08-10 18:33:38 -05001431 Returns
1432 :attr:`~cryptography.x509.oid.ExtensionOID.ISSUER_ALTERNATIVE_NAME`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001433
Paul Kehrer99125c92015-06-07 18:37:10 -05001434 .. method:: get_values_for_type(type)
1435
1436 :param type: A :class:`GeneralName` provider. This is one of the
1437 :ref:`general name classes <general_name_classes>`.
1438
1439 :returns: A list of values extracted from the matched general names.
1440
1441
Paul Kehrer3e6d5582015-05-02 21:57:56 -05001442.. class:: AuthorityInformationAccess
1443
1444 .. versionadded:: 0.9
1445
1446 The authority information access extension indicates how to access
1447 information and services for the issuer of the certificate in which
1448 the extension appears. Information and services may include online
1449 validation services (such as OCSP) and issuer data. It is an iterable,
Paul Kehrere27f6582015-08-10 18:33:38 -05001450 containing one or more :class:`~cryptography.x509.AccessDescription`
1451 instances.
Paul Kehrer3e6d5582015-05-02 21:57:56 -05001452
Paul Kehrer822f3d32015-08-06 11:47:32 +01001453 .. attribute:: oid
1454
1455 .. versionadded:: 1.0
1456
1457 :type: :class:`ObjectIdentifier`
1458
Paul Kehrere27f6582015-08-10 18:33:38 -05001459 Returns
1460 :attr:`~cryptography.x509.oid.ExtensionOID.AUTHORITY_INFORMATION_ACCESS`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001461
Paul Kehrer3e6d5582015-05-02 21:57:56 -05001462
1463.. class:: AccessDescription
1464
Paul Kehrer5a485522015-05-06 00:29:12 -05001465 .. versionadded:: 0.9
1466
Paul Kehrer3e6d5582015-05-02 21:57:56 -05001467 .. attribute:: access_method
1468
1469 :type: :class:`ObjectIdentifier`
1470
Paul Kehrerf506bca2015-05-02 22:31:47 -05001471 The access method defines what the ``access_location`` means. It must
Paul Kehrere27f6582015-08-10 18:33:38 -05001472 be either
1473 :attr:`~cryptography.x509.oid.AuthorityInformationAccessOID.OCSP` or
1474 :attr:`~cryptography.x509.oid.AuthorityInformationAccessOID.CA_ISSUERS`.
1475 If it is
1476 :attr:`~cryptography.x509.oid.AuthorityInformationAccessOID.OCSP`
1477 the access location will be where to obtain OCSP
1478 information for the certificate. If it is
1479 :attr:`~cryptography.x509.oid.AuthorityInformationAccessOID.CA_ISSUERS`
1480 the access location will provide additional information about the
1481 issuing certificate.
Paul Kehrer3e6d5582015-05-02 21:57:56 -05001482
1483 .. attribute:: access_location
1484
1485 :type: :class:`GeneralName`
1486
Paul Kehrerf506bca2015-05-02 22:31:47 -05001487 Where to access the information defined by the access method.
1488
Paul Kehrer5a485522015-05-06 00:29:12 -05001489.. class:: CRLDistributionPoints
1490
1491 .. versionadded:: 0.9
1492
1493 The CRL distribution points extension identifies how CRL information is
1494 obtained. It is an iterable, containing one or more
1495 :class:`DistributionPoint` instances.
1496
Paul Kehrer822f3d32015-08-06 11:47:32 +01001497 .. attribute:: oid
1498
1499 .. versionadded:: 1.0
1500
1501 :type: :class:`ObjectIdentifier`
1502
Paul Kehrere27f6582015-08-10 18:33:38 -05001503 Returns
1504 :attr:`~cryptography.x509.oid.ExtensionOID.CRL_DISTRIBUTION_POINTS`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001505
Paul Kehrer5a485522015-05-06 00:29:12 -05001506.. class:: DistributionPoint
1507
1508 .. versionadded:: 0.9
1509
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05001510 .. attribute:: full_name
Paul Kehrer5a485522015-05-06 00:29:12 -05001511
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05001512 :type: list of :class:`GeneralName` instances or None
Paul Kehrer5a485522015-05-06 00:29:12 -05001513
Paul Kehrerf2c072b2015-05-09 17:04:28 -05001514 This field describes methods to retrieve the CRL. At most one of
1515 ``full_name`` or ``relative_name`` will be non-None.
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05001516
1517 .. attribute:: relative_name
1518
1519 :type: :class:`Name` or None
1520
1521 This field describes methods to retrieve the CRL relative to the CRL
Paul Kehrerf2c072b2015-05-09 17:04:28 -05001522 issuer. At most one of ``full_name`` or ``relative_name`` will be
1523 non-None.
Paul Kehrer5a485522015-05-06 00:29:12 -05001524
1525 .. attribute:: crl_issuer
1526
1527 :type: list of :class:`GeneralName` instances or None
1528
1529 Information about the issuer of the CRL.
1530
1531 .. attribute:: reasons
1532
Paul Kehrer3fd02602015-05-09 19:46:13 -05001533 :type: frozenset of :class:`ReasonFlags` or None
Paul Kehrer5a485522015-05-06 00:29:12 -05001534
1535 The reasons a given distribution point may be used for when performing
1536 revocation checks.
1537
1538.. class:: ReasonFlags
1539
1540 .. versionadded:: 0.9
1541
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05001542 An enumeration for CRL reasons.
1543
1544 .. attribute:: unspecified
1545
1546 It is unspecified why the certificate was revoked. This reason cannot
1547 be used as a reason flag in a :class:`DistributionPoint`.
Paul Kehrer5a485522015-05-06 00:29:12 -05001548
1549 .. attribute:: key_compromise
1550
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05001551 This reason indicates that the private key was compromised.
Paul Kehrer5a485522015-05-06 00:29:12 -05001552
1553 .. attribute:: ca_compromise
1554
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05001555 This reason indicates that the CA issuing the certificate was
1556 compromised.
Paul Kehrer5a485522015-05-06 00:29:12 -05001557
1558 .. attribute:: affiliation_changed
1559
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05001560 This reason indicates that the subject's name or other information has
1561 changed.
Paul Kehrer5a485522015-05-06 00:29:12 -05001562
1563 .. attribute:: superseded
1564
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05001565 This reason indicates that a certificate has been superseded.
Paul Kehrer5a485522015-05-06 00:29:12 -05001566
1567 .. attribute:: cessation_of_operation
1568
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05001569 This reason indicates that the certificate is no longer required.
Paul Kehrer5a485522015-05-06 00:29:12 -05001570
1571 .. attribute:: certificate_hold
1572
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05001573 This reason indicates that the certificate is on hold.
Paul Kehrer5a485522015-05-06 00:29:12 -05001574
1575 .. attribute:: privilege_withdrawn
1576
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05001577 This reason indicates that the privilege granted by this certificate
1578 have been withdrawn.
Paul Kehrer5a485522015-05-06 00:29:12 -05001579
1580 .. attribute:: aa_compromise
1581
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05001582 When an attribute authority has been compromised.
1583
1584 .. attribute:: remove_from_crl
1585
1586 This reason indicates that the certificate was on hold and should be
1587 removed from the CRL. This reason cannot be used as a reason flag
1588 in a :class:`DistributionPoint`.
Paul Kehrer5a485522015-05-06 00:29:12 -05001589
Paul Kehrer16fae762015-05-01 23:14:20 -05001590.. class:: InhibitAnyPolicy
1591
1592 .. versionadded:: 1.0
1593
1594 The inhibit ``anyPolicy`` extension indicates that the special OID
Paul Kehrere27f6582015-08-10 18:33:38 -05001595 :attr:`~cryptography.x509.oid.CertificatePoliciesOID.ANY_POLICY`, is not
1596 considered an explicit match for other :class:`CertificatePolicies` except
1597 when it appears in an intermediate self-issued CA certificate. The value
1598 indicates the number of additional non-self-issued certificates that may
1599 appear in the path before
1600 :attr:`~cryptography.x509.oid.CertificatePoliciesOID.ANY_POLICY` is no
1601 longer permitted. For example, a value of one indicates that
1602 :attr:`~cryptography.x509.oid.CertificatePoliciesOID.ANY_POLICY` may be
1603 processed in certificates issued by the subject of this certificate, but
1604 not in additional certificates in the path.
Paul Kehrer16fae762015-05-01 23:14:20 -05001605
Paul Kehrer822f3d32015-08-06 11:47:32 +01001606 .. attribute:: oid
1607
1608 .. versionadded:: 1.0
1609
1610 :type: :class:`ObjectIdentifier`
1611
Paul Kehrere27f6582015-08-10 18:33:38 -05001612 Returns
1613 :attr:`~cryptography.x509.oid.ExtensionOID.INHIBIT_ANY_POLICY`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001614
Paul Kehrer16fae762015-05-01 23:14:20 -05001615 .. attribute:: skip_certs
1616
1617 :type: int
1618
Paul Kehrer0d210922015-04-28 17:31:07 -05001619.. class:: CertificatePolicies
1620
1621 .. versionadded:: 0.9
1622
Paul Kehrer2e879742015-05-02 23:09:56 -05001623 The certificate policies extension is an iterable, containing one or more
1624 :class:`PolicyInformation` instances.
Paul Kehrer0d210922015-04-28 17:31:07 -05001625
Paul Kehrer822f3d32015-08-06 11:47:32 +01001626 .. attribute:: oid
1627
1628 .. versionadded:: 1.0
1629
1630 :type: :class:`ObjectIdentifier`
1631
Paul Kehrere27f6582015-08-10 18:33:38 -05001632 Returns
1633 :attr:`~cryptography.x509.oid.ExtensionOID.CERTIFICATE_POLICIES`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001634
Paul Kehrer0d210922015-04-28 17:31:07 -05001635Certificate Policies Classes
1636~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1637
1638These classes may be present within a :class:`CertificatePolicies` instance.
1639
1640.. class:: PolicyInformation
1641
1642 .. versionadded:: 0.9
1643
1644 Contains a policy identifier and an optional list of qualifiers.
1645
1646 .. attribute:: policy_identifier
1647
1648 :type: :class:`ObjectIdentifier`
1649
1650 .. attribute:: policy_qualifiers
1651
1652 :type: list
1653
Paul Kehrerba35b3b2015-05-10 13:07:59 -05001654 A list consisting of :term:`text` and/or :class:`UserNotice` objects.
Paul Kehrer3f8ddeb2015-05-11 00:25:36 -05001655 If the value is text it is a pointer to the practice statement
1656 published by the certificate authority. If it is a user notice it is
1657 meant for display to the relying party when the certificate is
1658 used.
Paul Kehrer2e879742015-05-02 23:09:56 -05001659
Paul Kehrer0d210922015-04-28 17:31:07 -05001660.. class:: UserNotice
1661
1662 .. versionadded:: 0.9
1663
Paul Kehrer2e879742015-05-02 23:09:56 -05001664 User notices are intended for display to a relying party when a certificate
1665 is used. In practice, few if any UIs expose this data and it is a rarely
1666 encoded component.
1667
Paul Kehrer0d210922015-04-28 17:31:07 -05001668 .. attribute:: notice_reference
1669
1670 :type: :class:`NoticeReference` or None
1671
Paul Kehrer2e879742015-05-02 23:09:56 -05001672 The notice reference field names an organization and identifies,
1673 by number, a particular statement prepared by that organization.
1674
Paul Kehrer0d210922015-04-28 17:31:07 -05001675 .. attribute:: explicit_text
1676
Paul Kehrer2e879742015-05-02 23:09:56 -05001677 This field includes an arbitrary textual statement directly in the
1678 certificate.
1679
Paul Kehrer0d210922015-04-28 17:31:07 -05001680 :type: :term:`text`
1681
1682.. class:: NoticeReference
1683
Paul Kehrer2e879742015-05-02 23:09:56 -05001684 Notice reference can name an organization and provide information about
1685 notices related to the certificate. For example, it might identify the
1686 organization name and notice number 1. Application software could
1687 have a notice file containing the current set of notices for the named
1688 organization; the application would then extract the notice text from the
1689 file and display it. In practice this is rarely seen.
1690
Paul Kehrer0d210922015-04-28 17:31:07 -05001691 .. versionadded:: 0.9
1692
1693 .. attribute:: organization
1694
Paul Kehrer66c61702015-05-12 16:39:18 -05001695 :type: :term:`text`
Paul Kehrer0d210922015-04-28 17:31:07 -05001696
Paul Kehrer3f8ddeb2015-05-11 00:25:36 -05001697 .. attribute:: notice_numbers
Paul Kehrer0d210922015-04-28 17:31:07 -05001698
Paul Kehrer66c61702015-05-12 16:39:18 -05001699 :type: list
Paul Kehrer0d210922015-04-28 17:31:07 -05001700
Paul Kehrer66c61702015-05-12 16:39:18 -05001701 A list of integers.
Paul Kehrer0d210922015-04-28 17:31:07 -05001702
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001703Object Identifiers
1704~~~~~~~~~~~~~~~~~~
1705
Paul Kehrer4bb46492015-02-07 16:59:14 -06001706X.509 elements are frequently identified by :class:`ObjectIdentifier`
1707instances. The following common OIDs are available as constants.
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001708
Paul Kehrere27f6582015-08-10 18:33:38 -05001709.. currentmodule:: cryptography.x509.oid
Paul Kehrer56da2a52015-02-11 23:35:07 -06001710
Paul Kehrere27f6582015-08-10 18:33:38 -05001711.. class:: NameOID
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001712
Paul Kehrere27f6582015-08-10 18:33:38 -05001713 These OIDs are typically seen in X.509 names.
Paul Kehrer858b9b72015-02-05 09:50:31 -06001714
Paul Kehrere27f6582015-08-10 18:33:38 -05001715 .. versionadded:: 1.0
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001716
Paul Kehrere27f6582015-08-10 18:33:38 -05001717 .. attribute:: COMMON_NAME
Paul Kehrer858b9b72015-02-05 09:50:31 -06001718
Paul Kehrere27f6582015-08-10 18:33:38 -05001719 Corresponds to the dotted string ``"2.5.4.3"``. Historically the domain
1720 name would be encoded here for server certificates. :rfc:`2818`
1721 deprecates this practice and names of that type should now be located
1722 in a :class:`~cryptography.x509.SubjectAlternativeName` extension.
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001723
Paul Kehrere27f6582015-08-10 18:33:38 -05001724 .. attribute:: COUNTRY_NAME
Paul Kehrer858b9b72015-02-05 09:50:31 -06001725
Paul Kehrere27f6582015-08-10 18:33:38 -05001726 Corresponds to the dotted string ``"2.5.4.6"``.
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001727
Paul Kehrere27f6582015-08-10 18:33:38 -05001728 .. attribute:: LOCALITY_NAME
Paul Kehrer858b9b72015-02-05 09:50:31 -06001729
Paul Kehrere27f6582015-08-10 18:33:38 -05001730 Corresponds to the dotted string ``"2.5.4.7"``.
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001731
Paul Kehrere27f6582015-08-10 18:33:38 -05001732 .. attribute:: STATE_OR_PROVINCE_NAME
Paul Kehrer858b9b72015-02-05 09:50:31 -06001733
Paul Kehrere27f6582015-08-10 18:33:38 -05001734 Corresponds to the dotted string ``"2.5.4.8"``.
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001735
Paul Kehrere27f6582015-08-10 18:33:38 -05001736 .. attribute:: ORGANIZATION_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.10"``.
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001739
Paul Kehrere27f6582015-08-10 18:33:38 -05001740 .. attribute:: ORGANIZATIONAL_UNIT_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.11"``.
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001743
Paul Kehrere27f6582015-08-10 18:33:38 -05001744 .. attribute:: SERIAL_NUMBER
Paul Kehrer858b9b72015-02-05 09:50:31 -06001745
Paul Kehrere27f6582015-08-10 18:33:38 -05001746 Corresponds to the dotted string ``"2.5.4.5"``. This is distinct from
1747 the serial number of the certificate itself (which can be obtained with
1748 :func:`~cryptography.x509.Certificate.serial`).
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001749
Paul Kehrere27f6582015-08-10 18:33:38 -05001750 .. attribute:: SURNAME
Paul Kehrer858b9b72015-02-05 09:50:31 -06001751
Paul Kehrere27f6582015-08-10 18:33:38 -05001752 Corresponds to the dotted string ``"2.5.4.4"``.
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001753
Paul Kehrere27f6582015-08-10 18:33:38 -05001754 .. attribute:: GIVEN_NAME
Paul Kehrer858b9b72015-02-05 09:50:31 -06001755
Paul Kehrere27f6582015-08-10 18:33:38 -05001756 Corresponds to the dotted string ``"2.5.4.42"``.
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001757
Paul Kehrere27f6582015-08-10 18:33:38 -05001758 .. attribute:: TITLE
Paul Kehrer858b9b72015-02-05 09:50:31 -06001759
Paul Kehrere27f6582015-08-10 18:33:38 -05001760 Corresponds to the dotted string ``"2.5.4.12"``.
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001761
Paul Kehrere27f6582015-08-10 18:33:38 -05001762 .. attribute:: GENERATION_QUALIFIER
Paul Kehrer858b9b72015-02-05 09:50:31 -06001763
Paul Kehrere27f6582015-08-10 18:33:38 -05001764 Corresponds to the dotted string ``"2.5.4.44"``.
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001765
Paul Kehrere27f6582015-08-10 18:33:38 -05001766 .. attribute:: DN_QUALIFIER
Paul Kehrer858b9b72015-02-05 09:50:31 -06001767
Paul Kehrere27f6582015-08-10 18:33:38 -05001768 Corresponds to the dotted string ``"2.5.4.46"``. This specifies
1769 disambiguating information to add to the relative distinguished name of an
1770 entry. See :rfc:`2256`.
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001771
Paul Kehrere27f6582015-08-10 18:33:38 -05001772 .. attribute:: PSEUDONYM
Paul Kehrer858b9b72015-02-05 09:50:31 -06001773
Paul Kehrere27f6582015-08-10 18:33:38 -05001774 Corresponds to the dotted string ``"2.5.4.65"``.
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001775
Paul Kehrere27f6582015-08-10 18:33:38 -05001776 .. attribute:: DOMAIN_COMPONENT
Paul Kehrer858b9b72015-02-05 09:50:31 -06001777
Paul Kehrere27f6582015-08-10 18:33:38 -05001778 Corresponds to the dotted string ``"0.9.2342.19200300.100.1.25"``. A string
1779 holding one component of a domain name. See :rfc:`4519`.
Paul Kehrer56da2a52015-02-11 23:35:07 -06001780
Paul Kehrere27f6582015-08-10 18:33:38 -05001781 .. attribute:: EMAIL_ADDRESS
Paul Kehrer56da2a52015-02-11 23:35:07 -06001782
Paul Kehrere27f6582015-08-10 18:33:38 -05001783 Corresponds to the dotted string ``"1.2.840.113549.1.9.1"``.
Paul Kehrer56da2a52015-02-11 23:35:07 -06001784
Paul Kehrer56da2a52015-02-11 23:35:07 -06001785
Paul Kehrere27f6582015-08-10 18:33:38 -05001786.. class:: SignatureAlgorithmOID
Paul Kehrer56da2a52015-02-11 23:35:07 -06001787
Paul Kehrere27f6582015-08-10 18:33:38 -05001788 .. versionadded:: 1.0
Paul Kehrer56da2a52015-02-11 23:35:07 -06001789
Paul Kehrere27f6582015-08-10 18:33:38 -05001790 .. attribute:: RSA_WITH_MD5
Paul Kehrer56da2a52015-02-11 23:35:07 -06001791
Paul Kehrere27f6582015-08-10 18:33:38 -05001792 Corresponds to the dotted string ``"1.2.840.113549.1.1.4"``. This is
1793 an MD5 digest signed by an RSA key.
Paul Kehrer56da2a52015-02-11 23:35:07 -06001794
Paul Kehrere27f6582015-08-10 18:33:38 -05001795 .. attribute:: RSA_WITH_SHA1
Paul Kehrer56da2a52015-02-11 23:35:07 -06001796
Paul Kehrere27f6582015-08-10 18:33:38 -05001797 Corresponds to the dotted string ``"1.2.840.113549.1.1.5"``. This is
1798 a SHA1 digest signed by an RSA key.
Paul Kehrer56da2a52015-02-11 23:35:07 -06001799
Paul Kehrere27f6582015-08-10 18:33:38 -05001800 .. attribute:: RSA_WITH_SHA224
Paul Kehrer56da2a52015-02-11 23:35:07 -06001801
Paul Kehrere27f6582015-08-10 18:33:38 -05001802 Corresponds to the dotted string ``"1.2.840.113549.1.1.14"``. This is
1803 a SHA224 digest signed by an RSA key.
Paul Kehrer56da2a52015-02-11 23:35:07 -06001804
Paul Kehrere27f6582015-08-10 18:33:38 -05001805 .. attribute:: RSA_WITH_SHA256
Paul Kehrer56da2a52015-02-11 23:35:07 -06001806
Paul Kehrere27f6582015-08-10 18:33:38 -05001807 Corresponds to the dotted string ``"1.2.840.113549.1.1.11"``. This is
1808 a SHA256 digest signed by an RSA key.
Alex Gaynor3aadabf2015-06-23 22:06:21 -04001809
Paul Kehrere27f6582015-08-10 18:33:38 -05001810 .. attribute:: RSA_WITH_SHA384
Alex Gaynor3aadabf2015-06-23 22:06:21 -04001811
Paul Kehrere27f6582015-08-10 18:33:38 -05001812 Corresponds to the dotted string ``"1.2.840.113549.1.1.12"``. This is
1813 a SHA384 digest signed by an RSA key.
Paul Kehrer56da2a52015-02-11 23:35:07 -06001814
Paul Kehrere27f6582015-08-10 18:33:38 -05001815 .. attribute:: RSA_WITH_SHA512
Paul Kehrer56da2a52015-02-11 23:35:07 -06001816
Paul Kehrere27f6582015-08-10 18:33:38 -05001817 Corresponds to the dotted string ``"1.2.840.113549.1.1.13"``. This is
1818 a SHA512 digest signed by an RSA key.
Paul Kehrer56da2a52015-02-11 23:35:07 -06001819
Paul Kehrere27f6582015-08-10 18:33:38 -05001820 .. attribute:: ECDSA_WITH_SHA1
Paul Kehrer56da2a52015-02-11 23:35:07 -06001821
Paul Kehrere27f6582015-08-10 18:33:38 -05001822 Corresponds to the dotted string ``"1.2.840.10045.4.1"``. This is a SHA1
1823 digest signed by an ECDSA key.
Paul Kehrer56da2a52015-02-11 23:35:07 -06001824
Paul Kehrere27f6582015-08-10 18:33:38 -05001825 .. attribute:: ECDSA_WITH_SHA224
Paul Kehrer56da2a52015-02-11 23:35:07 -06001826
Paul Kehrere27f6582015-08-10 18:33:38 -05001827 Corresponds to the dotted string ``"1.2.840.10045.4.3.1"``. This is
1828 a SHA224 digest signed by an ECDSA key.
1829
1830 .. attribute:: ECDSA_WITH_SHA256
1831
1832 Corresponds to the dotted string ``"1.2.840.10045.4.3.2"``. This is
1833 a SHA256 digest signed by an ECDSA key.
1834
1835 .. attribute:: ECDSA_WITH_SHA384
1836
1837 Corresponds to the dotted string ``"1.2.840.10045.4.3.3"``. This is
1838 a SHA384 digest signed by an ECDSA key.
1839
1840 .. attribute:: ECDSA_WITH_SHA512
1841
1842 Corresponds to the dotted string ``"1.2.840.10045.4.3.4"``. This is
1843 a SHA512 digest signed by an ECDSA key.
1844
1845 .. attribute:: DSA_WITH_SHA1
1846
1847 Corresponds to the dotted string ``"1.2.840.10040.4.3"``. This is
1848 a SHA1 digest signed by a DSA key.
1849
1850 .. attribute:: DSA_WITH_SHA224
1851
1852 Corresponds to the dotted string ``"2.16.840.1.101.3.4.3.1"``. This is
1853 a SHA224 digest signed by a DSA key.
1854
1855 .. attribute:: DSA_WITH_SHA256
Paul Kehrer56da2a52015-02-11 23:35:07 -06001856
Paul Kehrere27f6582015-08-10 18:33:38 -05001857 Corresponds to the dotted string ``"2.16.840.1.101.3.4.3.2"``. This is
1858 a SHA256 digest signed by a DSA key.
Paul Kehrer56da2a52015-02-11 23:35:07 -06001859
Paul Kehrer56da2a52015-02-11 23:35:07 -06001860
Paul Kehrere27f6582015-08-10 18:33:38 -05001861.. class:: ExtendedKeyUsageOID
Paul Kehrer56da2a52015-02-11 23:35:07 -06001862
Paul Kehrere27f6582015-08-10 18:33:38 -05001863 .. versionadded:: 1.0
Paul Kehrer56da2a52015-02-11 23:35:07 -06001864
Paul Kehrere27f6582015-08-10 18:33:38 -05001865 .. attribute:: SERVER_AUTH
Paul Kehrer56da2a52015-02-11 23:35:07 -06001866
Paul Kehrere27f6582015-08-10 18:33:38 -05001867 Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.1"``. This is used
1868 to denote that a certificate may be used for TLS web server
1869 authentication.
Paul Kehrer56da2a52015-02-11 23:35:07 -06001870
Paul Kehrere27f6582015-08-10 18:33:38 -05001871 .. attribute:: CLIENT_AUTH
Paul Kehrer56da2a52015-02-11 23:35:07 -06001872
Paul Kehrere27f6582015-08-10 18:33:38 -05001873 Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.2"``. This is used
1874 to denote that a certificate may be used for TLS web client
1875 authentication.
Paul Kehrerffa2a152015-03-31 08:18:25 -05001876
Paul Kehrere27f6582015-08-10 18:33:38 -05001877 .. attribute:: CODE_SIGNING
Paul Kehrere1513fa2015-03-30 23:08:17 -05001878
Paul Kehrere27f6582015-08-10 18:33:38 -05001879 Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.3"``. This is used
1880 to denote that a certificate may be used for code signing.
Paul Kehrere1513fa2015-03-30 23:08:17 -05001881
Paul Kehrere27f6582015-08-10 18:33:38 -05001882 .. attribute:: EMAIL_PROTECTION
Paul Kehrere1513fa2015-03-30 23:08:17 -05001883
Paul Kehrere27f6582015-08-10 18:33:38 -05001884 Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.4"``. This is used
1885 to denote that a certificate may be used for email protection.
Paul Kehrere1513fa2015-03-30 23:08:17 -05001886
Paul Kehrere27f6582015-08-10 18:33:38 -05001887 .. attribute:: TIME_STAMPING
Paul Kehrere1513fa2015-03-30 23:08:17 -05001888
Paul Kehrere27f6582015-08-10 18:33:38 -05001889 Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.8"``. This is used
1890 to denote that a certificate may be used for time stamping.
Paul Kehrere1513fa2015-03-30 23:08:17 -05001891
Paul Kehrere27f6582015-08-10 18:33:38 -05001892 .. attribute:: OCSP_SIGNING
Paul Kehrere1513fa2015-03-30 23:08:17 -05001893
Paul Kehrere27f6582015-08-10 18:33:38 -05001894 Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.9"``. This is used
1895 to denote that a certificate may be used for signing OCSP responses.
Paul Kehrere1513fa2015-03-30 23:08:17 -05001896
Paul Kehrere1513fa2015-03-30 23:08:17 -05001897
Paul Kehrere27f6582015-08-10 18:33:38 -05001898.. class:: AuthorityInformationAccessOID
Paul Kehrere1513fa2015-03-30 23:08:17 -05001899
Paul Kehrere27f6582015-08-10 18:33:38 -05001900 .. versionadded:: 1.0
Paul Kehrere1513fa2015-03-30 23:08:17 -05001901
Paul Kehrere27f6582015-08-10 18:33:38 -05001902 .. attribute:: OCSP
Paul Kehrere1513fa2015-03-30 23:08:17 -05001903
Paul Kehrere27f6582015-08-10 18:33:38 -05001904 Corresponds to the dotted string ``"1.3.6.1.5.5.7.48.1"``. Used as the
1905 identifier for OCSP data in
1906 :class:`~cryptography.x509.AccessDescription` objects.
Paul Kehrere1513fa2015-03-30 23:08:17 -05001907
Paul Kehrere27f6582015-08-10 18:33:38 -05001908 .. attribute:: CA_ISSUERS
Paul Kehrer3e6d5582015-05-02 21:57:56 -05001909
Paul Kehrere27f6582015-08-10 18:33:38 -05001910 Corresponds to the dotted string ``"1.3.6.1.5.5.7.48.2"``. Used as the
1911 identifier for CA issuer data in
1912 :class:`~cryptography.x509.AccessDescription` objects.
Paul Kehrer3e6d5582015-05-02 21:57:56 -05001913
Paul Kehrer3e6d5582015-05-02 21:57:56 -05001914
Paul Kehrere27f6582015-08-10 18:33:38 -05001915.. class:: CertificatePoliciesOID
Paul Kehrer3e6d5582015-05-02 21:57:56 -05001916
Paul Kehrere27f6582015-08-10 18:33:38 -05001917 .. versionadded:: 1.0
Paul Kehrer3e6d5582015-05-02 21:57:56 -05001918
Paul Kehrere27f6582015-08-10 18:33:38 -05001919 .. attribute:: CPS_QUALIFIER
Paul Kehrer2e879742015-05-02 23:09:56 -05001920
Paul Kehrere27f6582015-08-10 18:33:38 -05001921 Corresponds to the dotted string ``"1.3.6.1.5.5.7.2.1"``.
Paul Kehrer2e879742015-05-02 23:09:56 -05001922
Paul Kehrere27f6582015-08-10 18:33:38 -05001923 .. attribute:: CPS_USER_NOTICE
Paul Kehrer2e879742015-05-02 23:09:56 -05001924
Paul Kehrere27f6582015-08-10 18:33:38 -05001925 Corresponds to the dotted string ``"1.3.6.1.5.5.7.2.2"``.
Paul Kehrer2e879742015-05-02 23:09:56 -05001926
Paul Kehrere27f6582015-08-10 18:33:38 -05001927 .. attribute:: ANY_POLICY
Paul Kehrer2e879742015-05-02 23:09:56 -05001928
Paul Kehrere27f6582015-08-10 18:33:38 -05001929 Corresponds to the dotted string ``"2.5.29.32.0"``.
Paul Kehrer16fae762015-05-01 23:14:20 -05001930
Paul Kehrer16fae762015-05-01 23:14:20 -05001931
Paul Kehrere27f6582015-08-10 18:33:38 -05001932.. class:: ExtensionOID
Paul Kehrer5553d572015-03-23 21:08:01 -05001933
Paul Kehrere27f6582015-08-10 18:33:38 -05001934 .. versionadded:: 1.0
Paul Kehrer2bb94642015-03-21 09:54:17 -05001935
Paul Kehrere27f6582015-08-10 18:33:38 -05001936 .. attribute:: BASIC_CONSTRAINTS
Paul Kehrer2bb94642015-03-21 09:54:17 -05001937
Paul Kehrere27f6582015-08-10 18:33:38 -05001938 Corresponds to the dotted string ``"2.5.29.19"``. The identifier for the
1939 :class:`~cryptography.x509.BasicConstraints` extension type.
Paul Kehrer2bb94642015-03-21 09:54:17 -05001940
Paul Kehrere27f6582015-08-10 18:33:38 -05001941 .. attribute:: KEY_USAGE
Paul Kehrercecbbba2015-03-30 14:58:38 -05001942
Paul Kehrere27f6582015-08-10 18:33:38 -05001943 Corresponds to the dotted string ``"2.5.29.15"``. The identifier for the
1944 :class:`~cryptography.x509.KeyUsage` extension type.
Paul Kehrercecbbba2015-03-30 14:58:38 -05001945
Paul Kehrere27f6582015-08-10 18:33:38 -05001946 .. attribute:: SUBJECT_ALTERNATIVE_NAME
Paul Kehrerd4f632e2015-05-12 08:25:42 -05001947
Paul Kehrere27f6582015-08-10 18:33:38 -05001948 Corresponds to the dotted string ``"2.5.29.17"``. The identifier for the
1949 :class:`~cryptography.x509.SubjectAlternativeName` extension type.
Paul Kehrerd4f632e2015-05-12 08:25:42 -05001950
Paul Kehrere27f6582015-08-10 18:33:38 -05001951 .. attribute:: ISSUER_ALTERNATIVE_NAME
Paul Kehrer99125c92015-06-07 18:37:10 -05001952
Paul Kehrere27f6582015-08-10 18:33:38 -05001953 Corresponds to the dotted string ``"2.5.29.18"``. The identifier for the
1954 :class:`~cryptography.x509.IssuerAlternativeName` extension type.
Paul Kehrer99125c92015-06-07 18:37:10 -05001955
Paul Kehrere27f6582015-08-10 18:33:38 -05001956 .. attribute:: SUBJECT_KEY_IDENTIFIER
Paul Kehrerd4f632e2015-05-12 08:25:42 -05001957
Paul Kehrere27f6582015-08-10 18:33:38 -05001958 Corresponds to the dotted string ``"2.5.29.14"``. The identifier for the
1959 :class:`~cryptography.x509.SubjectKeyIdentifier` extension type.
Paul Kehrerd4f632e2015-05-12 08:25:42 -05001960
Paul Kehrere27f6582015-08-10 18:33:38 -05001961 .. attribute:: NAME_CONSTRAINTS
Paul Kehrere0017be2015-05-17 20:39:40 -06001962
Paul Kehrere27f6582015-08-10 18:33:38 -05001963 Corresponds to the dotted string ``"2.5.29.30"``. The identifier for the
1964 :class:`~cryptography.x509.NameConstraints` extension type.
Paul Kehrere0017be2015-05-17 20:39:40 -06001965
Paul Kehrere27f6582015-08-10 18:33:38 -05001966 .. attribute:: CRL_DISTRIBUTION_POINTS
Paul Kehrerd4f632e2015-05-12 08:25:42 -05001967
Paul Kehrere27f6582015-08-10 18:33:38 -05001968 Corresponds to the dotted string ``"2.5.29.31"``. The identifier for the
1969 :class:`~cryptography.x509.CRLDistributionPoints` extension type.
Paul Kehrerd4f632e2015-05-12 08:25:42 -05001970
Paul Kehrere27f6582015-08-10 18:33:38 -05001971 .. attribute:: CERTIFICATE_POLICIES
Paul Kehrerd4f632e2015-05-12 08:25:42 -05001972
Paul Kehrere27f6582015-08-10 18:33:38 -05001973 Corresponds to the dotted string ``"2.5.29.32"``. The identifier for the
1974 :class:`~cryptography.x509.CertificatePolicies` extension type.
Paul Kehrerd4f632e2015-05-12 08:25:42 -05001975
Paul Kehrere27f6582015-08-10 18:33:38 -05001976 .. attribute:: AUTHORITY_KEY_IDENTIFIER
Paul Kehrerd4f632e2015-05-12 08:25:42 -05001977
Paul Kehrere27f6582015-08-10 18:33:38 -05001978 Corresponds to the dotted string ``"2.5.29.35"``. The identifier for the
1979 :class:`~cryptography.x509.AuthorityKeyIdentifier` extension type.
Paul Kehrerd4f632e2015-05-12 08:25:42 -05001980
Paul Kehrere27f6582015-08-10 18:33:38 -05001981 .. attribute:: EXTENDED_KEY_USAGE
Paul Kehrerd4f632e2015-05-12 08:25:42 -05001982
Paul Kehrere27f6582015-08-10 18:33:38 -05001983 Corresponds to the dotted string ``"2.5.29.37"``. The identifier for the
1984 :class:`~cryptography.x509.ExtendedKeyUsage` extension type.
Paul Kehrerd4f632e2015-05-12 08:25:42 -05001985
Paul Kehrere27f6582015-08-10 18:33:38 -05001986 .. attribute:: AUTHORITY_INFORMATION_ACCESS
Paul Kehrerd4f632e2015-05-12 08:25:42 -05001987
Paul Kehrere27f6582015-08-10 18:33:38 -05001988 Corresponds to the dotted string ``"1.3.6.1.5.5.7.1.1"``. The identifier
1989 for the :class:`~cryptography.x509.AuthorityInformationAccess` extension
1990 type.
Paul Kehrer56da2a52015-02-11 23:35:07 -06001991
Paul Kehrere27f6582015-08-10 18:33:38 -05001992 .. attribute:: INHIBIT_ANY_POLICY
Paul Kehrerb33de932015-08-06 23:41:05 +01001993
Paul Kehrere27f6582015-08-10 18:33:38 -05001994 Corresponds to the dotted string ``"2.5.29.54"``. The identifier
1995 for the :class:`~cryptography.x509.InhibitAnyPolicy` extension type.
Paul Kehrerb33de932015-08-06 23:41:05 +01001996
Paul Kehrere27f6582015-08-10 18:33:38 -05001997 .. attribute:: OCSP_NO_CHECK
Paul Kehrer4a1038e2015-05-18 10:28:31 -07001998
Paul Kehrere27f6582015-08-10 18:33:38 -05001999 Corresponds to the dotted string ``"1.3.6.1.5.5.7.48.1.5"``. The
2000 identifier for the :class:`~cryptography.x509.OCSPNoCheck` extension
2001 type.
Paul Kehrer4a1038e2015-05-18 10:28:31 -07002002
Paul Kehrer912d3fb2015-01-29 11:19:22 -06002003Exceptions
2004~~~~~~~~~~
Paul Kehrere27f6582015-08-10 18:33:38 -05002005.. currentmodule:: cryptography.x509
Paul Kehrer912d3fb2015-01-29 11:19:22 -06002006
Paul Kehrere76cd272014-12-14 19:00:51 -06002007.. class:: InvalidVersion
Paul Kehrera68fd332014-11-27 07:08:40 -10002008
2009 This is raised when an X.509 certificate has an invalid version number.
Paul Kehrer016e08a2014-11-26 09:41:18 -10002010
Paul Kehrerd5cccf72014-12-15 17:20:33 -06002011 .. attribute:: parsed_version
2012
Paul Kehrerbbffc402014-12-17 13:33:55 -06002013 :type: int
2014
2015 Returns the raw version that was parsed from the certificate.
Paul Kehrerd5cccf72014-12-15 17:20:33 -06002016
Paul Kehrerfbb7ac82015-03-16 19:26:29 -05002017.. class:: DuplicateExtension
2018
2019 This is raised when more than one X.509 extension of the same type is
2020 found within a certificate.
2021
2022 .. attribute:: oid
2023
2024 :type: :class:`ObjectIdentifier`
2025
2026 Returns the OID.
2027
2028.. class:: UnsupportedExtension
2029
2030 This is raised when a certificate contains an unsupported extension type.
2031
2032 .. attribute:: oid
2033
2034 :type: :class:`ObjectIdentifier`
2035
2036 Returns the OID.
2037
Paul Kehrerfa56a232015-03-17 13:14:03 -05002038.. class:: ExtensionNotFound
2039
2040 This is raised when calling :meth:`Extensions.get_extension_for_oid` with
2041 an extension OID that is not present in the certificate.
2042
2043 .. attribute:: oid
2044
2045 :type: :class:`ObjectIdentifier`
2046
2047 Returns the OID.
2048
Paul Kehrer9089c912015-04-20 22:15:20 -05002049.. class:: UnsupportedGeneralNameType
2050
2051 This is raised when a certificate contains an unsupported general name
2052 type in an extension.
2053
Paul Kehrerbed07352015-04-21 08:31:10 -05002054 .. attribute:: type
2055
Paul Kehrer0a621bf2015-04-22 09:22:56 -05002056 :type: int
2057
2058 The integer value of the unsupported type. The complete list of
2059 types can be found in `RFC 5280 section 4.2.1.6`_.
Paul Kehrerbed07352015-04-21 08:31:10 -05002060
Paul Kehrer016e08a2014-11-26 09:41:18 -10002061
Paul Kehrerc7c9a432015-04-19 09:20:13 -05002062.. _`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 -05002063.. _`RFC 5280 section 4.2.1.6`: https://tools.ietf.org/html/rfc5280#section-4.2.1.6