blob: 64097bf27b3ef77a3487c2adfc205b5a478b8bdd [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
Alex Gaynor5ce14042016-05-29 13:13:46 -0400123 .. doctest::
124
125 >>> from cryptography import x509
126 >>> from cryptography.hazmat.backends import default_backend
127 >>> cert = x509.load_pem_x509_certificate(pem_data, default_backend())
Chelsea Winfreee295f3a2016-06-02 21:15:54 -0700128 >>> cert.serial_number
Alex Gaynor5ce14042016-05-29 13:13:46 -0400129 2
130
Paul Kehrer016e08a2014-11-26 09:41:18 -1000131.. function:: load_der_x509_certificate(data, backend)
132
133 .. versionadded:: 0.7
134
Paul Kehrere76cd272014-12-14 19:00:51 -0600135 Deserialize a certificate from DER encoded data. DER is a binary format
Paul Kehrer92aac382014-12-15 16:25:28 -0600136 and is commonly found in files with the ``.cer`` extension (although file
137 extensions are not a guarantee of encoding type).
Paul Kehrer016e08a2014-11-26 09:41:18 -1000138
139 :param bytes data: The DER encoded certificate data.
140
141 :param backend: A backend supporting the
142 :class:`~cryptography.hazmat.backends.interfaces.X509Backend`
143 interface.
144
Paul Kehrere76cd272014-12-14 19:00:51 -0600145 :returns: An instance of :class:`~cryptography.x509.Certificate`.
Paul Kehrer016e08a2014-11-26 09:41:18 -1000146
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
Alex Gaynor5ce14042016-05-29 13:13:46 -0400167 .. doctest::
168
169 >>> from cryptography import x509
170 >>> from cryptography.hazmat.backends import default_backend
171 >>> from cryptography.hazmat.primitives import hashes
172 >>> crl = x509.load_pem_x509_crl(pem_crl_data, default_backend())
173 >>> isinstance(crl.signature_hash_algorithm, hashes.SHA256)
174 True
175
Erik Trauschkedc570402015-09-24 20:24:28 -0700176.. function:: load_der_x509_crl(data, backend)
177
178 .. versionadded:: 1.1
179
180 Deserialize a certificate revocation list (CRL) from DER encoded data. DER
181 is a binary format.
182
183 :param bytes data: The DER encoded request data.
184
185 :param backend: A backend supporting the
186 :class:`~cryptography.hazmat.backends.interfaces.X509Backend`
187 interface.
188
189 :returns: An instance of
190 :class:`~cryptography.x509.CertificateRevocationList`.
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
Alex Gaynor5ce14042016-05-29 13:13:46 -0400213 .. doctest::
214
215 >>> from cryptography import x509
216 >>> from cryptography.hazmat.backends import default_backend
217 >>> from cryptography.hazmat.primitives import hashes
218 >>> csr = x509.load_pem_x509_csr(pem_req_data, default_backend())
219 >>> isinstance(csr.signature_hash_algorithm, hashes.SHA1)
220 True
221
Paul Kehrer1effb6e2015-03-30 15:05:59 -0500222.. function:: load_der_x509_csr(data, backend)
223
224 .. versionadded:: 0.9
225
226 Deserialize a certificate signing request (CSR) from DER encoded data. DER
227 is a binary format and is not commonly used with CSRs.
228
229 :param bytes data: The DER encoded request data.
230
231 :param backend: A backend supporting the
232 :class:`~cryptography.hazmat.backends.interfaces.X509Backend`
233 interface.
234
235 :returns: An instance of
236 :class:`~cryptography.x509.CertificateSigningRequest`.
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 Kehrer056c9dd2018-05-12 15:17:06 -0400274 b'\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
Chelsea Winfreee295f3a2016-06-02 21:15:54 -0700276 .. attribute:: serial_number
Paul Kehrerb2de9482014-12-11 14:54:48 -0600277
278 :type: int
279
280 The serial as a Python integer.
281
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600282 .. doctest::
283
Chelsea Winfreee295f3a2016-06-02 21:15:54 -0700284 >>> cert.serial_number
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600285 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 Kehrerc7b29b82016-09-01 09:17:21 +0800357 .. attribute:: signature_algorithm_oid
358
359 .. versionadded:: 1.6
360
361 :type: :class:`ObjectIdentifier`
362
363 Returns the :class:`ObjectIdentifier` of the signature algorithm used
364 to sign the certificate. This will be one of the OIDs from
365 :class:`~cryptography.x509.oid.SignatureAlgorithmOID`.
366
367
368 .. doctest::
369
370 >>> cert.signature_algorithm_oid
371 <ObjectIdentifier(oid=1.2.840.113549.1.1.11, name=sha256WithRSAEncryption)>
372
Paul Kehrerfbb7ac82015-03-16 19:26:29 -0500373 .. attribute:: extensions
374
375 :type: :class:`Extensions`
376
377 The extensions encoded in the certificate.
378
379 :raises cryptography.x509.DuplicateExtension: If more than one
380 extension of the same type is found within the certificate.
381
Paul Kehrerbed07352015-04-21 08:31:10 -0500382 :raises cryptography.x509.UnsupportedGeneralNameType: If an extension
383 contains a general name that is not supported.
384
Paul Kehrerb8968812015-05-15 09:01:34 -0700385 :raises UnicodeError: If an extension contains IDNA encoding that is
386 invalid or not compliant with IDNA 2008.
387
Paul Kehrerfa56a232015-03-17 13:14:03 -0500388 .. doctest::
389
390 >>> for ext in cert.extensions:
391 ... print(ext)
Paul Kehrer056c9dd2018-05-12 15:17:06 -0400392 <Extension(oid=<ObjectIdentifier(oid=2.5.29.35, name=authorityKeyIdentifier)>, critical=False, value=<AuthorityKeyIdentifier(key_identifier=b'\xe4}_\xd1\\\x95\x86\x08,\x05\xae\xbeu\xb6e\xa7\xd9]\xa8f', authority_cert_issuer=None, authority_cert_serial_number=None)>)>
393 <Extension(oid=<ObjectIdentifier(oid=2.5.29.14, name=subjectKeyIdentifier)>, critical=False, value=<SubjectKeyIdentifier(digest=b'X\x01\x84$\x1b\xbc+R\x94J=\xa5\x10r\x14Q\xf5\xaf:\xc9')>)>
Paul Kehrerb511ba82015-04-15 11:22:48 -0400394 <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 -0500395 <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 -0500396 <Extension(oid=<ObjectIdentifier(oid=2.5.29.19, name=basicConstraints)>, critical=True, value=<BasicConstraints(ca=True, path_length=None)>)>
397
Paul Kehrerd91e7c12015-10-01 16:50:42 -0500398 .. attribute:: signature
399
400 .. versionadded:: 1.2
401
402 :type: bytes
403
404 The bytes of the certificate's signature.
405
Paul Kehrerd2898052015-11-03 22:00:41 +0900406 .. attribute:: tbs_certificate_bytes
Paul Kehrerd91e7c12015-10-01 16:50:42 -0500407
408 .. versionadded:: 1.2
409
410 :type: bytes
411
412 The DER encoded bytes payload (as defined by :rfc:`5280`) that is hashed
413 and then signed by the private key of the certificate's issuer. This
414 data may be used to validate a signature, but use extreme caution as
415 certificate validation is a complex problem that involves much more
416 than just signature checks.
417
Andre Carona8aded62015-05-19 20:11:57 -0400418 .. method:: public_bytes(encoding)
419
Alex Gaynord0b376b2015-07-05 13:58:12 -0400420 .. versionadded:: 1.0
421
Andre Carona8aded62015-05-19 20:11:57 -0400422 :param encoding: The
423 :class:`~cryptography.hazmat.primitives.serialization.Encoding`
424 that will be used to serialize the certificate.
425
426 :return bytes: The data that can be written to a file or sent
427 over the network to be verified by clients.
428
Erik Trauschke2dcce902015-05-14 16:12:24 -0700429X.509 CRL (Certificate Revocation List) Object
430~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
431
432.. class:: CertificateRevocationList
433
434 .. versionadded:: 1.0
435
Erik Trauschke3cdabaf2015-10-13 09:42:53 -0700436 A CertificateRevocationList is an object representing a list of revoked
437 certificates. The object is iterable and will yield the RevokedCertificate
438 objects stored in this CRL.
439
440 .. doctest::
Erik Trauschkeb14f7d12015-10-13 09:55:39 -0700441
Erik Trauschke3cdabaf2015-10-13 09:42:53 -0700442 >>> len(crl)
443 1
Paul Kehrerdcdf9672015-10-21 20:27:28 -0500444 >>> revoked_certificate = crl[0]
445 >>> type(revoked_certificate)
Erik Trauschke3cdabaf2015-10-13 09:42:53 -0700446 <class 'cryptography.hazmat.backends.openssl.x509._RevokedCertificate'>
447 >>> for r in crl:
448 ... print(r.serial_number)
449 0
450
Erik Trauschke2dcce902015-05-14 16:12:24 -0700451 .. method:: fingerprint(algorithm)
452
453 :param algorithm: The
454 :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm`
455 that will be used to generate the fingerprint.
456
457 :return bytes: The fingerprint using the supplied hash algorithm, as
458 bytes.
459
Erik Trauschkedc570402015-09-24 20:24:28 -0700460 .. doctest::
461
462 >>> from cryptography.hazmat.primitives import hashes
463 >>> crl.fingerprint(hashes.SHA256())
Paul Kehrer056c9dd2018-05-12 15:17:06 -0400464 b'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'
Erik Trauschkedc570402015-09-24 20:24:28 -0700465
Erik Trauschke2dcce902015-05-14 16:12:24 -0700466 .. attribute:: signature_hash_algorithm
467
468 :type: :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm`
469
470 Returns the
471 :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` which
472 was used in signing this CRL.
473
Erik Trauschkedc570402015-09-24 20:24:28 -0700474 .. doctest::
475
476 >>> from cryptography.hazmat.primitives import hashes
477 >>> isinstance(crl.signature_hash_algorithm, hashes.SHA256)
478 True
479
Paul Kehrerc7b29b82016-09-01 09:17:21 +0800480 .. attribute:: signature_algorithm_oid
481
482 .. versionadded:: 1.6
483
484 :type: :class:`ObjectIdentifier`
485
486 Returns the :class:`ObjectIdentifier` of the signature algorithm used
487 to sign the CRL. This will be one of the OIDs from
488 :class:`~cryptography.x509.oid.SignatureAlgorithmOID`.
489
490 .. doctest::
491
492 >>> crl.signature_algorithm_oid
493 <ObjectIdentifier(oid=1.2.840.113549.1.1.11, name=sha256WithRSAEncryption)>
494
Erik Trauschke2dcce902015-05-14 16:12:24 -0700495 .. attribute:: issuer
496
497 :type: :class:`Name`
498
499 The :class:`Name` of the issuer.
500
Erik Trauschkedc570402015-09-24 20:24:28 -0700501 .. doctest::
502
503 >>> crl.issuer
Paul Kehrer056c9dd2018-05-12 15:17:06 -0400504 <Name([<NameAttribute(oid=<ObjectIdentifier(oid=2.5.4.6, name=countryName)>, value='US')>, <NameAttribute(oid=<ObjectIdentifier(oid=2.5.4.3, name=commonName)>, value='cryptography.io')>])>
Erik Trauschkedc570402015-09-24 20:24:28 -0700505
Erik Trauschke2dcce902015-05-14 16:12:24 -0700506 .. attribute:: next_update
507
508 :type: :class:`datetime.datetime`
509
510 A naïve datetime representing when the next update to this CRL is
511 expected.
512
Erik Trauschkedc570402015-09-24 20:24:28 -0700513 .. doctest::
514
515 >>> crl.next_update
516 datetime.datetime(2016, 1, 1, 0, 0)
517
Erik Trauschke2dcce902015-05-14 16:12:24 -0700518 .. attribute:: last_update
519
520 :type: :class:`datetime.datetime`
521
522 A naïve datetime representing when the this CRL was last updated.
523
Erik Trauschkedc570402015-09-24 20:24:28 -0700524 .. doctest::
Erik Trauschke2dcce902015-05-14 16:12:24 -0700525
Erik Trauschkedc570402015-09-24 20:24:28 -0700526 >>> crl.last_update
527 datetime.datetime(2015, 1, 1, 0, 0)
Erik Trauschke2dcce902015-05-14 16:12:24 -0700528
529 .. attribute:: extensions
530
531 :type: :class:`Extensions`
532
533 The extensions encoded in the CRL.
534
Erik Trauschke6abe2bb2015-11-19 10:27:01 -0800535 .. attribute:: signature
536
537 .. versionadded:: 1.2
538
539 :type: bytes
540
541 The bytes of the CRL's signature.
542
543 .. attribute:: tbs_certlist_bytes
544
545 .. versionadded:: 1.2
546
547 :type: bytes
548
549 The DER encoded bytes payload (as defined by :rfc:`5280`) that is hashed
550 and then signed by the private key of the CRL's issuer. This data may be
551 used to validate a signature, but use extreme caution as CRL validation
552 is a complex problem that involves much more than just signature checks.
553
Paul Kehrer54a837d2015-12-20 23:42:32 -0600554 .. method:: public_bytes(encoding)
555
556 .. versionadded:: 1.2
557
558 :param encoding: The
559 :class:`~cryptography.hazmat.primitives.serialization.Encoding`
560 that will be used to serialize the certificate revocation list.
561
562 :return bytes: The data that can be written to a file or sent
563 over the network and used as part of a certificate verification
564 process.
565
Vincent Pelletier6c02ee82017-08-12 22:05:00 +0900566 .. method:: is_signature_valid(public_key)
567
568 .. versionadded:: 2.1
569
Paul Kehrerf944c402017-08-12 08:52:55 -0500570 .. warning::
571
572 Checking the validity of the signature on the CRL is insufficient
573 to know if the CRL should be trusted. More details are available
574 in :rfc:`5280`.
575
Vincent Pelletier6c02ee82017-08-12 22:05:00 +0900576 Returns True if the CRL signature is correct for given public key,
577 False otherwise.
Erik Trauschke6abe2bb2015-11-19 10:27:01 -0800578
Andre Caron9bbfcea2015-05-18 20:55:29 -0400579X.509 Certificate Builder
580~~~~~~~~~~~~~~~~~~~~~~~~~
581
582.. class:: CertificateBuilder
583
Ian Cordasco1517a4b2015-08-02 22:11:19 -0500584 .. versionadded:: 1.0
585
586 .. doctest::
587
588 >>> from cryptography import x509
589 >>> from cryptography.hazmat.backends import default_backend
590 >>> from cryptography.hazmat.primitives import hashes
591 >>> from cryptography.hazmat.primitives.asymmetric import rsa
Paul Kehrere27f6582015-08-10 18:33:38 -0500592 >>> from cryptography.x509.oid import NameOID
Ian Cordasco1517a4b2015-08-02 22:11:19 -0500593 >>> import datetime
Ian Cordasco1517a4b2015-08-02 22:11:19 -0500594 >>> one_day = datetime.timedelta(1, 0, 0)
595 >>> private_key = rsa.generate_private_key(
596 ... public_exponent=65537,
597 ... key_size=2048,
598 ... backend=default_backend()
599 ... )
Cory Benfieldc47b2522015-12-07 15:25:12 +0000600 >>> public_key = private_key.public_key()
Ian Cordasco1517a4b2015-08-02 22:11:19 -0500601 >>> builder = x509.CertificateBuilder()
602 >>> builder = builder.subject_name(x509.Name([
Paul Kehrere27f6582015-08-10 18:33:38 -0500603 ... x509.NameAttribute(NameOID.COMMON_NAME, u'cryptography.io'),
Ian Cordasco1517a4b2015-08-02 22:11:19 -0500604 ... ]))
605 >>> builder = builder.issuer_name(x509.Name([
Paul Kehrere27f6582015-08-10 18:33:38 -0500606 ... x509.NameAttribute(NameOID.COMMON_NAME, u'cryptography.io'),
Ian Cordasco1517a4b2015-08-02 22:11:19 -0500607 ... ]))
608 >>> builder = builder.not_valid_before(datetime.datetime.today() - one_day)
609 >>> builder = builder.not_valid_after(datetime.datetime(2018, 8, 2))
Paul Kehrer8b89bcc2016-09-03 11:31:43 -0500610 >>> builder = builder.serial_number(x509.random_serial_number())
Ian Cordasco1517a4b2015-08-02 22:11:19 -0500611 >>> builder = builder.public_key(public_key)
612 >>> builder = builder.add_extension(
Paul Kehrer1bab7bc2017-01-18 13:44:40 +0800613 ... x509.SubjectAlternativeName(
Paul Kehrered321052017-10-11 08:11:44 +0800614 ... [x509.DNSName(u'cryptography.io')]
Paul Kehrer1bab7bc2017-01-18 13:44:40 +0800615 ... ),
616 ... critical=False
617 ... )
618 >>> builder = builder.add_extension(
Ian Cordasco1517a4b2015-08-02 22:11:19 -0500619 ... x509.BasicConstraints(ca=False, path_length=None), critical=True,
620 ... )
621 >>> certificate = builder.sign(
622 ... private_key=private_key, algorithm=hashes.SHA256(),
623 ... backend=default_backend()
624 ... )
625 >>> isinstance(certificate, x509.Certificate)
626 True
627
Ian Cordasco0092a0b2015-07-18 21:46:41 -0500628 .. method:: issuer_name(name)
Andre Caron9bbfcea2015-05-18 20:55:29 -0400629
630 Sets the issuer's distinguished name.
631
Ian Cordascoc9682ad2015-08-01 12:11:13 -0500632 :param name: The :class:`~cryptography.x509.Name` that describes the
633 issuer (CA).
Andre Caron9bbfcea2015-05-18 20:55:29 -0400634
Ian Cordasco0092a0b2015-07-18 21:46:41 -0500635 .. method:: subject_name(name)
Andre Caron9bbfcea2015-05-18 20:55:29 -0400636
637 Sets the subject's distinguished name.
638
Ian Cordascoc9682ad2015-08-01 12:11:13 -0500639 :param name: The :class:`~cryptography.x509.Name` that describes the
Ian Cordasco85fc4d52015-08-01 20:29:31 -0500640 subject.
Andre Caron9bbfcea2015-05-18 20:55:29 -0400641
Ian Cordasco0092a0b2015-07-18 21:46:41 -0500642 .. method:: public_key(public_key)
Andre Caron9bbfcea2015-05-18 20:55:29 -0400643
644 Sets the subject's public key.
645
Ian Cordasco8f571422015-08-02 11:31:08 -0500646 :param public_key: The subject's public key. This can be one of
647 :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey`,
648 :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPublicKey` or
649 :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey`
Andre Caron9bbfcea2015-05-18 20:55:29 -0400650
Ian Cordasco0092a0b2015-07-18 21:46:41 -0500651 .. method:: serial_number(serial_number)
Andre Caron9bbfcea2015-05-18 20:55:29 -0400652
653 Sets the certificate's serial number (an integer). The CA's policy
Paul Kehrer8b89bcc2016-09-03 11:31:43 -0500654 determines how it attributes serial numbers to certificates. This
655 number must uniquely identify the certificate given the issuer.
656 `CABForum Guidelines`_ require entropy in the serial number
657 to provide protection against hash collision attacks. For more
658 information on secure random number generation, see
659 :doc:`/random-numbers`.
Andre Caron9bbfcea2015-05-18 20:55:29 -0400660
661 :param serial_number: Integer number that will be used by the CA to
662 identify this certificate (most notably during certificate
Paul Kehrer8b89bcc2016-09-03 11:31:43 -0500663 revocation checking). Users should consider using
664 :func:`~cryptography.x509.random_serial_number` when possible.
Andre Caron9bbfcea2015-05-18 20:55:29 -0400665
Ian Cordasco0092a0b2015-07-18 21:46:41 -0500666 .. method:: not_valid_before(time)
Andre Caron9bbfcea2015-05-18 20:55:29 -0400667
668 Sets the certificate's activation time. This is the time from which
669 clients can start trusting the certificate. It may be different from
670 the time at which the certificate was created.
671
Ian Cordasco17c89002015-08-02 21:13:59 -0500672 :param time: The :class:`datetime.datetime` object (in UTC) that marks the
Andre Caron9bbfcea2015-05-18 20:55:29 -0400673 activation time for the certificate. The certificate may not be
674 trusted clients if it is used before this time.
675
Ian Cordasco0092a0b2015-07-18 21:46:41 -0500676 .. method:: not_valid_after(time)
Andre Caron9bbfcea2015-05-18 20:55:29 -0400677
678 Sets the certificate's expiration time. This is the time from which
679 clients should no longer trust the certificate. The CA's policy will
680 determine how long the certificate should remain in use.
681
Ian Cordasco17c89002015-08-02 21:13:59 -0500682 :param time: The :class:`datetime.datetime` object (in UTC) that marks the
Andre Caron9bbfcea2015-05-18 20:55:29 -0400683 expiration time for the certificate. The certificate may not be
684 trusted clients if it is used after this time.
685
Ian Cordasco17c89002015-08-02 21:13:59 -0500686 .. method:: add_extension(extension, critical)
Andre Caron9bbfcea2015-05-18 20:55:29 -0400687
688 Adds an X.509 extension to the certificate.
689
Paul Kehrer2c145cc2015-10-02 11:27:21 -0500690 :param extension: An extension conforming to the
691 :class:`~cryptography.x509.ExtensionType` interface.
Andre Caron9bbfcea2015-05-18 20:55:29 -0400692
Ian Cordasco17c89002015-08-02 21:13:59 -0500693 :param critical: Set to ``True`` if the extension must be understood and
694 handled by whoever reads the certificate.
695
Paul Kehrer9add80e2015-08-03 17:53:14 +0100696 .. method:: sign(private_key, algorithm, backend)
Andre Caron9bbfcea2015-05-18 20:55:29 -0400697
698 Sign the certificate using the CA's private key.
699
Ian Cordascoc5e1c252015-07-31 23:33:35 -0500700 :param private_key: The
701 :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey`,
702 :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPrivateKey` or
703 :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateKey`
704 that will be used to sign the certificate.
705
Andre Caron9bbfcea2015-05-18 20:55:29 -0400706 :param algorithm: The
707 :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` that
708 will be used to generate the signature.
709
Paul Kehrer9add80e2015-08-03 17:53:14 +0100710 :param backend: Backend that will be used to build the certificate.
711 Must support the
712 :class:`~cryptography.hazmat.backends.interfaces.X509Backend`
713 interface.
714
Benjamin Peterson9ed312b2015-10-12 20:51:34 -0700715 :returns: :class:`~cryptography.x509.Certificate`
Andre Caron9bbfcea2015-05-18 20:55:29 -0400716
717
Paul Kehrer5aadb9c2015-03-11 20:48:42 -0500718X.509 CSR (Certificate Signing Request) Object
719~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600720
Paul Kehrera1a1f232015-03-15 15:34:35 -0500721.. class:: CertificateSigningRequest
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600722
723 .. versionadded:: 0.9
724
725 .. method:: public_key()
726
Alex Gaynor4c2561a2015-10-12 23:53:39 -0400727 The public key associated with the request.
728
729 :returns:
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600730 :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey` or
731 :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPublicKey` or
732 :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey`
733
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600734 .. doctest::
735
736 >>> from cryptography.hazmat.primitives.asymmetric import rsa
Paul Kehrera1a1f232015-03-15 15:34:35 -0500737 >>> public_key = csr.public_key()
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600738 >>> isinstance(public_key, rsa.RSAPublicKey)
739 True
740
741 .. attribute:: subject
742
743 :type: :class:`Name`
744
745 The :class:`Name` of the subject.
746
747 .. attribute:: signature_hash_algorithm
748
749 :type: :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm`
750
751 Returns the
752 :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` which
753 was used in signing this request.
754
755 .. doctest::
756
757 >>> from cryptography.hazmat.primitives import hashes
Paul Kehrera1a1f232015-03-15 15:34:35 -0500758 >>> isinstance(csr.signature_hash_algorithm, hashes.SHA1)
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600759 True
760
Paul Kehrerc7b29b82016-09-01 09:17:21 +0800761 .. attribute:: signature_algorithm_oid
762
763 .. versionadded:: 1.6
764
765 :type: :class:`ObjectIdentifier`
766
767 Returns the :class:`ObjectIdentifier` of the signature algorithm used
768 to sign the request. This will be one of the OIDs from
769 :class:`~cryptography.x509.oid.SignatureAlgorithmOID`.
770
771 .. doctest::
772
773 >>> csr.signature_algorithm_oid
774 <ObjectIdentifier(oid=1.2.840.113549.1.1.5, name=sha1WithRSAEncryption)>
775
Paul Kehrerc4e61942015-08-01 21:21:13 +0100776 .. attribute:: extensions
777
778 :type: :class:`Extensions`
779
780 The extensions encoded in the certificate signing request.
781
782 :raises cryptography.x509.DuplicateExtension: If more than one
Paul Kehrer24283d22015-08-01 21:31:19 +0100783 extension of the same type is found within the certificate signing request.
Paul Kehrerc4e61942015-08-01 21:21:13 +0100784
Paul Kehrerc4e61942015-08-01 21:21:13 +0100785 :raises cryptography.x509.UnsupportedGeneralNameType: If an extension
786 contains a general name that is not supported.
787
788 :raises UnicodeError: If an extension contains IDNA encoding that is
789 invalid or not compliant with IDNA 2008.
790
791
Andre Caron476c5df2015-05-18 10:23:28 -0400792 .. method:: public_bytes(encoding)
793
Alex Gaynord0b376b2015-07-05 13:58:12 -0400794 .. versionadded:: 1.0
795
Andre Caron476c5df2015-05-18 10:23:28 -0400796 :param encoding: The
797 :class:`~cryptography.hazmat.primitives.serialization.Encoding`
798 that will be used to serialize the certificate request.
799
800 :return bytes: The data that can be written to a file or sent
801 over the network to be signed by the certificate
802 authority.
803
Paul Kehrerab209392015-12-01 14:50:31 -0600804 .. attribute:: signature
805
806 .. versionadded:: 1.2
807
808 :type: bytes
809
810 The bytes of the certificate signing request's signature.
811
812 .. attribute:: tbs_certrequest_bytes
813
814 .. versionadded:: 1.2
815
816 :type: bytes
817
818 The DER encoded bytes payload (as defined by :rfc:`2986`) that is
819 hashed and then signed by the private key (corresponding to the public
820 key embedded in the CSR). This data may be used to validate the CSR
821 signature.
822
Joern Heisslerfbda8ce2016-01-18 00:24:44 +0100823 .. attribute:: is_signature_valid
Joern Heissler1bd77e22016-01-13 22:51:37 +0100824
825 .. versionadded:: 1.3
826
Joern Heisslerfbda8ce2016-01-18 00:24:44 +0100827 Returns True if the CSR signature is correct, False otherwise.
Joern Heissler1bd77e22016-01-13 22:51:37 +0100828
Paul Kehrerbfac2d12015-12-19 23:32:08 -0600829X.509 Certificate Revocation List Builder
830~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
831
832.. class:: CertificateRevocationListBuilder
833
834 .. versionadded:: 1.2
835
836 .. doctest::
837
838 >>> from cryptography import x509
839 >>> from cryptography.hazmat.backends import default_backend
840 >>> from cryptography.hazmat.primitives import hashes
841 >>> from cryptography.hazmat.primitives.asymmetric import rsa
842 >>> from cryptography.x509.oid import NameOID
843 >>> import datetime
844 >>> one_day = datetime.timedelta(1, 0, 0)
845 >>> private_key = rsa.generate_private_key(
846 ... public_exponent=65537,
847 ... key_size=2048,
848 ... backend=default_backend()
849 ... )
850 >>> builder = x509.CertificateRevocationListBuilder()
851 >>> builder = builder.issuer_name(x509.Name([
852 ... x509.NameAttribute(NameOID.COMMON_NAME, u'cryptography.io CA'),
853 ... ]))
854 >>> builder = builder.last_update(datetime.datetime.today())
855 >>> builder = builder.next_update(datetime.datetime.today() + one_day)
Paul Kehrer4c7fd5f2015-12-25 13:40:55 -0600856 >>> revoked_cert = x509.RevokedCertificateBuilder().serial_number(
857 ... 333
858 ... ).revocation_date(
859 ... datetime.datetime.today()
860 ... ).build(default_backend())
861 >>> builder = builder.add_revoked_certificate(revoked_cert)
Paul Kehrerbfac2d12015-12-19 23:32:08 -0600862 >>> crl = builder.sign(
863 ... private_key=private_key, algorithm=hashes.SHA256(),
864 ... backend=default_backend()
865 ... )
Paul Kehrer4c7fd5f2015-12-25 13:40:55 -0600866 >>> len(crl)
867 1
Paul Kehrerbfac2d12015-12-19 23:32:08 -0600868
869 .. method:: issuer_name(name)
870
871 Sets the issuer's distinguished name.
872
873 :param name: The :class:`~cryptography.x509.Name` that describes the
874 issuer (CA).
875
876 .. method:: last_update(time)
877
Paul Kehrer0325b9d2015-12-24 19:19:59 -0600878 Sets this CRL's activation time. This is the time from which
879 clients can start trusting this CRL. It may be different from
880 the time at which this CRL was created. This is also known as the
Paul Kehrerbfac2d12015-12-19 23:32:08 -0600881 ``thisUpdate`` time.
882
Paul Kehrer0325b9d2015-12-24 19:19:59 -0600883 :param time: The :class:`datetime.datetime` object (in UTC) that marks
884 the activation time for this CRL. The CRL may not be trusted if it
885 is used before this time.
Paul Kehrerbfac2d12015-12-19 23:32:08 -0600886
887 .. method:: next_update(time)
888
Paul Kehrer0325b9d2015-12-24 19:19:59 -0600889 Sets this CRL's next update time. This is the time by which
890 a new CRL will be issued. The CA is allowed to issue a new CRL before
891 this date, however clients are not required to check for it.
Paul Kehrerbfac2d12015-12-19 23:32:08 -0600892
Paul Kehrer0325b9d2015-12-24 19:19:59 -0600893 :param time: The :class:`datetime.datetime` object (in UTC) that marks
894 the next update time for this CRL.
Paul Kehrerbfac2d12015-12-19 23:32:08 -0600895
Paul Kehrer426b48d2015-12-24 20:50:43 -0600896 .. method:: add_extension(extension, critical)
897
898 Adds an X.509 extension to this CRL.
899
900 :param extension: An extension with the
901 :class:`~cryptography.x509.ExtensionType` interface.
902
903 :param critical: Set to ``True`` if the extension must be understood and
904 handled by whoever reads the CRL.
905
Paul Kehrer4c7fd5f2015-12-25 13:40:55 -0600906 .. method:: add_revoked_certificate(revoked_certificate)
907
908 Adds a revoked certificate to this CRL.
909
910 :param revoked_certificate: An instance of
911 :class:`~cryptography.x509.RevokedCertificate`. These can be
912 obtained from an existing CRL or created with
913 :class:`~cryptography.x509.RevokedCertificateBuilder`.
914
Paul Kehrerbfac2d12015-12-19 23:32:08 -0600915 .. method:: sign(private_key, algorithm, backend)
916
Paul Kehrer0325b9d2015-12-24 19:19:59 -0600917 Sign this CRL using the CA's private key.
Paul Kehrerbfac2d12015-12-19 23:32:08 -0600918
919 :param private_key: The
920 :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey`,
921 :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPrivateKey` or
922 :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateKey`
923 that will be used to sign the certificate.
924
925 :param algorithm: The
926 :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` that
927 will be used to generate the signature.
928
929 :param backend: Backend that will be used to build the CRL.
930 Must support the
931 :class:`~cryptography.hazmat.backends.interfaces.X509Backend`
932 interface.
933
934 :returns: :class:`~cryptography.x509.CertificateRevocationList`
935
Erik Trauschke2dcce902015-05-14 16:12:24 -0700936X.509 Revoked Certificate Object
Erik Trauschkec5a8d172015-05-28 10:24:25 -0700937~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Erik Trauschke2dcce902015-05-14 16:12:24 -0700938
939.. class:: RevokedCertificate
940
941 .. versionadded:: 1.0
942
943 .. attribute:: serial_number
944
945 :type: :class:`int`
946
947 An integer representing the serial number of the revoked certificate.
948
Erik Trauschkedc570402015-09-24 20:24:28 -0700949 .. doctest::
950
Erik Trauschke3cdabaf2015-10-13 09:42:53 -0700951 >>> revoked_certificate.serial_number
Erik Trauschkedc570402015-09-24 20:24:28 -0700952 0
953
Erik Trauschke2dcce902015-05-14 16:12:24 -0700954 .. attribute:: revocation_date
955
956 :type: :class:`datetime.datetime`
957
958 A naïve datetime representing the date this certificates was revoked.
959
Erik Trauschkedc570402015-09-24 20:24:28 -0700960 .. doctest::
961
Erik Trauschke77f5a252015-10-14 08:06:38 -0700962 >>> revoked_certificate.revocation_date
Erik Trauschkedc570402015-09-24 20:24:28 -0700963 datetime.datetime(2015, 1, 1, 0, 0)
964
Erik Trauschke2dcce902015-05-14 16:12:24 -0700965 .. attribute:: extensions
966
967 :type: :class:`Extensions`
968
969 The extensions encoded in the revoked certificate.
Andre Caron476c5df2015-05-18 10:23:28 -0400970
Erik Trauschkedc570402015-09-24 20:24:28 -0700971 .. doctest::
972
Erik Trauschke77f5a252015-10-14 08:06:38 -0700973 >>> for ext in revoked_certificate.extensions:
Erik Trauschkedc570402015-09-24 20:24:28 -0700974 ... print(ext)
Paul Kehrer23c0bbc2015-12-25 22:35:19 -0600975 <Extension(oid=<ObjectIdentifier(oid=2.5.29.24, name=invalidityDate)>, critical=False, value=<InvalidityDate(invalidity_date=2015-01-01 00:00:00)>)>
Paul Kehrer7058ece2015-12-25 22:28:29 -0600976 <Extension(oid=<ObjectIdentifier(oid=2.5.29.21, name=cRLReason)>, critical=False, value=<CRLReason(reason=ReasonFlags.key_compromise)>)>
Erik Trauschkedc570402015-09-24 20:24:28 -0700977
Paul Kehrerc33ffd72015-12-25 10:59:22 -0600978X.509 Revoked Certificate Builder
979~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
980
981.. class:: RevokedCertificateBuilder
982
983 This class is used to create :class:`~cryptography.x509.RevokedCertificate`
984 objects that can be used with the
985 :class:`~cryptography.x509.CertificateRevocationListBuilder`.
986
987 .. versionadded:: 1.2
988
989 .. doctest::
990
991 >>> from cryptography import x509
992 >>> from cryptography.hazmat.backends import default_backend
993 >>> import datetime
994 >>> builder = x509.RevokedCertificateBuilder()
995 >>> builder = builder.revocation_date(datetime.datetime.today())
996 >>> builder = builder.serial_number(3333)
997 >>> revoked_certificate = builder.build(default_backend())
998 >>> isinstance(revoked_certificate, x509.RevokedCertificate)
999 True
1000
1001 .. method:: serial_number(serial_number)
1002
1003 Sets the revoked certificate's serial number.
1004
1005 :param serial_number: Integer number that is used to identify the
1006 revoked certificate.
1007
1008 .. method:: revocation_date(time)
1009
1010 Sets the certificate's revocation date.
1011
1012 :param time: The :class:`datetime.datetime` object (in UTC) that marks the
1013 revocation time for the certificate.
1014
Paul Kehrere5f152b2015-12-25 23:55:47 -06001015 .. method:: add_extension(extension, critical)
1016
1017 Adds an X.509 extension to this revoked certificate.
1018
1019 :param extension: An instance of one of the
1020 :ref:`CRL entry extensions <crl_entry_extensions>`.
1021
1022 :param critical: Set to ``True`` if the extension must be understood and
1023 handled.
1024
Paul Kehrerc33ffd72015-12-25 10:59:22 -06001025 .. method:: build(backend)
1026
1027 Create a revoked certificate object using the provided backend.
1028
1029 :param backend: Backend that will be used to build the revoked
1030 certificate. Must support the
1031 :class:`~cryptography.hazmat.backends.interfaces.X509Backend`
1032 interface.
1033
1034 :returns: :class:`~cryptography.x509.RevokedCertificate`
1035
Andre Caron0ef595f2015-05-18 13:53:43 -04001036X.509 CSR (Certificate Signing Request) Builder Object
1037~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1038
1039.. class:: CertificateSigningRequestBuilder
1040
Andre Carond259ee52015-06-02 23:47:11 -04001041 .. versionadded:: 1.0
1042
1043 .. doctest::
1044
1045 >>> from cryptography import x509
1046 >>> from cryptography.hazmat.backends import default_backend
1047 >>> from cryptography.hazmat.primitives import hashes
1048 >>> from cryptography.hazmat.primitives.asymmetric import rsa
Paul Kehrere27f6582015-08-10 18:33:38 -05001049 >>> from cryptography.x509.oid import NameOID
Andre Carond259ee52015-06-02 23:47:11 -04001050 >>> private_key = rsa.generate_private_key(
1051 ... public_exponent=65537,
1052 ... key_size=2048,
1053 ... backend=default_backend()
1054 ... )
1055 >>> builder = x509.CertificateSigningRequestBuilder()
Andre Carona9a51172015-06-06 20:18:44 -04001056 >>> builder = builder.subject_name(x509.Name([
Paul Kehrere27f6582015-08-10 18:33:38 -05001057 ... x509.NameAttribute(NameOID.COMMON_NAME, u'cryptography.io'),
Andre Carond259ee52015-06-02 23:47:11 -04001058 ... ]))
Ian Cordascof06b6be2015-06-21 10:09:18 -05001059 >>> builder = builder.add_extension(
Ian Cordasco0112b022015-06-16 17:51:18 -05001060 ... x509.BasicConstraints(ca=False, path_length=None), critical=True,
Andre Caron472fd692015-06-06 20:04:44 -04001061 ... )
Andre Carond259ee52015-06-02 23:47:11 -04001062 >>> request = builder.sign(
Alex Gaynorde9e5842015-06-26 20:11:23 -04001063 ... private_key, hashes.SHA256(), default_backend()
Andre Carond259ee52015-06-02 23:47:11 -04001064 ... )
1065 >>> isinstance(request, x509.CertificateSigningRequest)
1066 True
1067
Andre Carona9a51172015-06-06 20:18:44 -04001068 .. method:: subject_name(name)
Andre Caron0ef595f2015-05-18 13:53:43 -04001069
Andre Caron341ff852015-06-06 20:14:31 -04001070 :param name: The :class:`~cryptography.x509.Name` of the certificate
1071 subject.
1072 :returns: A new
1073 :class:`~cryptography.x509.CertificateSigningRequestBuilder`.
Andre Caron0ef595f2015-05-18 13:53:43 -04001074
Ian Cordascof06b6be2015-06-21 10:09:18 -05001075 .. method:: add_extension(extension, critical)
Andre Caron0ef595f2015-05-18 13:53:43 -04001076
Paul Kehrer2c145cc2015-10-02 11:27:21 -05001077 :param extension: An extension conforming to the
1078 :class:`~cryptography.x509.ExtensionType` interface.
Andre Caron472fd692015-06-06 20:04:44 -04001079 :param critical: Set to `True` if the extension must be understood and
1080 handled by whoever reads the certificate.
Andre Caron341ff852015-06-06 20:14:31 -04001081 :returns: A new
1082 :class:`~cryptography.x509.CertificateSigningRequestBuilder`.
Andre Caron0ef595f2015-05-18 13:53:43 -04001083
Alex Gaynorb3b0fbe2015-06-26 19:57:18 -04001084 .. method:: sign(private_key, algorithm, backend)
Andre Caron0ef595f2015-05-18 13:53:43 -04001085
1086 :param backend: Backend that will be used to sign the request.
1087 Must support the
1088 :class:`~cryptography.hazmat.backends.interfaces.X509Backend`
1089 interface.
1090
1091 :param private_key: The
Andre Caron24f9bf42015-06-06 20:14:54 -04001092 :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey`,
1093 :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPrivateKey` or
1094 :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateKey`
Andre Caron0ef595f2015-05-18 13:53:43 -04001095 that will be used to sign the request. When the request is
1096 signed by a certificate authority, the private key's associated
1097 public key will be stored in the resulting certificate.
1098
1099 :param algorithm: The
1100 :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm`
1101 that will be used to generate the request signature.
1102
Andre Caron341ff852015-06-06 20:14:31 -04001103 :returns: A new
1104 :class:`~cryptography.x509.CertificateSigningRequest`.
Andre Caron0ef595f2015-05-18 13:53:43 -04001105
1106
Paul Kehrer719d5362015-01-01 20:03:52 -06001107.. class:: Name
1108
1109 .. versionadded:: 0.8
1110
Paul Kehrer53d8d492015-02-13 18:47:30 -06001111 An X509 Name is an ordered list of attributes. The object is iterable to
Paul Kehrerd21596e2015-02-14 09:17:26 -06001112 get every attribute or you can use :meth:`Name.get_attributes_for_oid` to
Paul Kehrer719d5362015-01-01 20:03:52 -06001113 obtain the specific type you want. Names are sometimes represented as a
Paul Kehrer53d8d492015-02-13 18:47:30 -06001114 slash or comma delimited string (e.g. ``/CN=mydomain.com/O=My Org/C=US`` or
1115 ``CN=mydomain.com, O=My Org, C=US``).
Paul Kehrer719d5362015-01-01 20:03:52 -06001116
Fraser Tweedale01ee6f52016-11-12 01:28:56 +10001117 Technically, a Name is a list of *sets* of attributes, called *Relative
1118 Distinguished Names* or *RDNs*, although multi-valued RDNs are rarely
1119 encountered. The iteration order of values within a multi-valued RDN is
Marti Raudsepp9e1873a2018-07-09 16:11:18 +03001120 preserved. If you need to handle multi-valued RDNs, the ``rdns`` property
Fraser Tweedale01ee6f52016-11-12 01:28:56 +10001121 gives access to an ordered list of :class:`RelativeDistinguishedName`
1122 objects.
1123
1124 A Name can be initialized with an iterable of :class:`NameAttribute` (the
1125 common case where each RDN has a single attribute) or an iterable of
1126 :class:`RelativeDistinguishedName` objects (in the rare case of
1127 multi-valued RDNs).
1128
Paul Kehrer53d8d492015-02-13 18:47:30 -06001129 .. doctest::
Paul Kehrer719d5362015-01-01 20:03:52 -06001130
Paul Kehrer8b21a4a2015-02-14 07:56:36 -06001131 >>> len(cert.subject)
Paul Kehrer53d8d492015-02-13 18:47:30 -06001132 3
Paul Kehrer8b21a4a2015-02-14 07:56:36 -06001133 >>> for attribute in cert.subject:
1134 ... print(attribute)
Paul Kehrer056c9dd2018-05-12 15:17:06 -04001135 <NameAttribute(oid=<ObjectIdentifier(oid=2.5.4.6, name=countryName)>, value='US')>
1136 <NameAttribute(oid=<ObjectIdentifier(oid=2.5.4.10, name=organizationName)>, value='Test Certificates 2011')>
1137 <NameAttribute(oid=<ObjectIdentifier(oid=2.5.4.3, name=commonName)>, value='Good CA')>
Paul Kehrer719d5362015-01-01 20:03:52 -06001138
Fraser Tweedale01ee6f52016-11-12 01:28:56 +10001139 .. attribute:: rdns
1140
1141 .. versionadded:: 1.6
1142
1143 :type: list of :class:`RelativeDistinguishedName`
1144
Paul Kehrere901d642015-02-11 18:50:58 -06001145 .. method:: get_attributes_for_oid(oid)
Paul Kehrer719d5362015-01-01 20:03:52 -06001146
Paul Kehrere901d642015-02-11 18:50:58 -06001147 :param oid: An :class:`ObjectIdentifier` instance.
Paul Kehrer719d5362015-01-01 20:03:52 -06001148
Paul Kehrere901d642015-02-11 18:50:58 -06001149 :returns: A list of :class:`NameAttribute` instances that match the
1150 OID provided. If nothing matches an empty list will be returned.
Paul Kehrer719d5362015-01-01 20:03:52 -06001151
1152 .. doctest::
1153
Paul Kehrere27f6582015-08-10 18:33:38 -05001154 >>> cert.subject.get_attributes_for_oid(NameOID.COMMON_NAME)
Paul Kehrer056c9dd2018-05-12 15:17:06 -04001155 [<NameAttribute(oid=<ObjectIdentifier(oid=2.5.4.3, name=commonName)>, value='Good CA')>]
Paul Kehrerb2de9482014-12-11 14:54:48 -06001156
Paul Kehrer3a15b032016-11-13 14:30:11 -08001157 .. method:: public_bytes(backend)
1158
1159 .. versionadded:: 1.6
1160
1161 :param backend: A backend supporting the
1162 :class:`~cryptography.hazmat.backends.interfaces.X509Backend`
1163 interface.
1164
1165 :return bytes: The DER encoded name.
1166
Paul Kehrere76cd272014-12-14 19:00:51 -06001167.. class:: Version
Paul Kehrer016e08a2014-11-26 09:41:18 -10001168
1169 .. versionadded:: 0.7
1170
1171 An enumeration for X.509 versions.
1172
1173 .. attribute:: v1
1174
1175 For version 1 X.509 certificates.
1176
1177 .. attribute:: v3
1178
1179 For version 3 X.509 certificates.
1180
Paul Kehrer806bfb22015-02-02 17:05:24 -06001181.. class:: NameAttribute
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001182
1183 .. versionadded:: 0.8
1184
Fraser Tweedale01ee6f52016-11-12 01:28:56 +10001185 An X.509 name consists of a list of :class:`RelativeDistinguishedName`
1186 instances, which consist of a set of :class:`NameAttribute` instances.
Paul Kehrer5b0a8d62015-01-30 20:05:55 -06001187
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001188 .. attribute:: oid
1189
1190 :type: :class:`ObjectIdentifier`
1191
1192 The attribute OID.
1193
1194 .. attribute:: value
1195
Paul Kehrerd5852cb2015-01-30 08:25:23 -06001196 :type: :term:`text`
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001197
1198 The value of the attribute.
1199
Fraser Tweedale02467dd2016-11-07 15:54:04 +10001200
1201.. class:: RelativeDistinguishedName(attributes)
1202
1203 .. versionadded:: 1.6
1204
1205 A relative distinguished name is a non-empty set of name attributes. The
Marti Raudsepp9e1873a2018-07-09 16:11:18 +03001206 object is iterable to get every attribute, preserving the original order.
1207 Passing duplicate attributes to the constructor raises ``ValueError``.
Fraser Tweedale02467dd2016-11-07 15:54:04 +10001208
1209 .. method:: get_attributes_for_oid(oid)
1210
1211 :param oid: An :class:`ObjectIdentifier` instance.
1212
1213 :returns: A list of :class:`NameAttribute` instances that match the OID
1214 provided. The list should contain zero or one values.
1215
1216
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001217.. class:: ObjectIdentifier
1218
1219 .. versionadded:: 0.8
1220
Paul Kehrer5b0a8d62015-01-30 20:05:55 -06001221 Object identifiers (frequently seen abbreviated as OID) identify the type
Paul Kehrer806bfb22015-02-02 17:05:24 -06001222 of a value (see: :class:`NameAttribute`).
Paul Kehrer5b0a8d62015-01-30 20:05:55 -06001223
Paul Kehrerd44f9a62015-02-04 14:47:34 -06001224 .. attribute:: dotted_string
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001225
1226 :type: :class:`str`
1227
Paul Kehrerfedf4f42015-02-06 11:22:07 -06001228 The dotted string value of the OID (e.g. ``"2.5.4.3"``)
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001229
Paul Kehrer31bdf792015-03-25 14:11:00 -05001230.. _general_name_classes:
1231
1232General Name Classes
1233~~~~~~~~~~~~~~~~~~~~
1234
1235.. class:: GeneralName
1236
1237 .. versionadded:: 0.9
1238
1239 This is the generic interface that all the following classes are registered
1240 against.
1241
Paul Kehrer47c32ba2015-10-28 09:12:07 +09001242.. class:: RFC822Name(value)
Paul Kehrer31bdf792015-03-25 14:11:00 -05001243
1244 .. versionadded:: 0.9
1245
Paul Kehrere885bd62017-10-11 20:29:23 +08001246 .. versionchanged:: 2.1
Paul Kehrer3e15ca52017-08-01 21:21:19 -05001247
Paul Kehrere885bd62017-10-11 20:29:23 +08001248 .. warning::
1249
1250 Starting with version 2.1 :term:`U-label` input is deprecated. If
1251 passing an internationalized domain name (IDN) you should first IDNA
1252 encode the value and then pass the result as a string. Accessing
1253 ``value`` will return the :term:`A-label` encoded form even if you pass
1254 a U-label. This breaks backwards compatibility, but only for
1255 internationalized domain names.
1256
Paul Kehrer1b86dc52017-09-20 23:42:34 +08001257
1258 This corresponds to an email address. For example, ``user@example.com``.
1259
Paul Kehrere885bd62017-10-11 20:29:23 +08001260 :param value: The email address. If the address contains an
Paul Kehrer1b86dc52017-09-20 23:42:34 +08001261 internationalized domain name then it must be encoded to an
Paul Kehrere885bd62017-10-11 20:29:23 +08001262 :term:`A-label` string before being passed.
Paul Kehrer1b86dc52017-09-20 23:42:34 +08001263
Paul Kehrer31bdf792015-03-25 14:11:00 -05001264 .. attribute:: value
1265
1266 :type: :term:`text`
1267
Paul Kehrer47c32ba2015-10-28 09:12:07 +09001268.. class:: DNSName(value)
Paul Kehrer31bdf792015-03-25 14:11:00 -05001269
1270 .. versionadded:: 0.9
1271
Paul Kehrere885bd62017-10-11 20:29:23 +08001272 .. versionchanged:: 2.1
Paul Kehrer1b86dc52017-09-20 23:42:34 +08001273
Paul Kehrere885bd62017-10-11 20:29:23 +08001274 .. warning::
1275
1276 Starting with version 2.1 :term:`U-label` input is deprecated. If
1277 passing an internationalized domain name (IDN) you should first IDNA
1278 encode the value and then pass the result as a string. Accessing
1279 ``value`` will return the :term:`A-label` encoded form even if you pass
1280 a U-label. This breaks backwards compatibility, but only for
1281 internationalized domain names.
Paul Kehrer1b86dc52017-09-20 23:42:34 +08001282
Paul Kehrer31bdf792015-03-25 14:11:00 -05001283 This corresponds to a domain name. For example, ``cryptography.io``.
1284
Paul Kehrere885bd62017-10-11 20:29:23 +08001285 :param value: The domain name. If it is an internationalized domain
1286 name then it must be encoded to an :term:`A-label` string before being
1287 passed.
Paul Kehrer1b86dc52017-09-20 23:42:34 +08001288
Paul Kehrere885bd62017-10-11 20:29:23 +08001289 :type: :term:`text`
Paul Kehrer1b86dc52017-09-20 23:42:34 +08001290
Paul Kehrer31bdf792015-03-25 14:11:00 -05001291 .. attribute:: value
1292
1293 :type: :term:`text`
1294
Paul Kehrer47c32ba2015-10-28 09:12:07 +09001295.. class:: DirectoryName(value)
Paul Kehrer31bdf792015-03-25 14:11:00 -05001296
1297 .. versionadded:: 0.9
1298
1299 This corresponds to a directory name.
1300
1301 .. attribute:: value
1302
1303 :type: :class:`Name`
1304
Paul Kehrer47c32ba2015-10-28 09:12:07 +09001305.. class:: UniformResourceIdentifier(value)
Paul Kehrer31bdf792015-03-25 14:11:00 -05001306
1307 .. versionadded:: 0.9
1308
Paul Kehrere885bd62017-10-11 20:29:23 +08001309 .. versionchanged:: 2.1
Paul Kehrerb8ef82e2015-04-22 16:04:24 -05001310
Paul Kehrere885bd62017-10-11 20:29:23 +08001311 .. warning::
1312
1313 Starting with version 2.1 :term:`U-label` input is deprecated. If
1314 passing an internationalized domain name (IDN) you should first IDNA
1315 encode the value and then pass the result as a string. Accessing
1316 ``value`` will return the :term:`A-label` encoded form even if you pass
1317 a U-label. This breaks backwards compatibility, but only for
1318 internationalized domain names.
Paul Kehrer1b86dc52017-09-20 23:42:34 +08001319
1320 This corresponds to a uniform resource identifier. For example,
1321 ``https://cryptography.io``.
1322
Paul Kehrere885bd62017-10-11 20:29:23 +08001323 :param value: The URI. If it contains an internationalized domain
1324 name then it must be encoded to an :term:`A-label` string before
1325 being passed.
Paul Kehrer1b86dc52017-09-20 23:42:34 +08001326
Paul Kehrer31bdf792015-03-25 14:11:00 -05001327 .. attribute:: value
1328
1329 :type: :term:`text`
1330
Paul Kehrer47c32ba2015-10-28 09:12:07 +09001331.. class:: IPAddress(value)
Paul Kehrer31bdf792015-03-25 14:11:00 -05001332
1333 .. versionadded:: 0.9
1334
1335 This corresponds to an IP address.
1336
1337 .. attribute:: value
1338
Paul Kehrereb177932015-05-17 18:33:33 -07001339 :type: :class:`~ipaddress.IPv4Address`,
1340 :class:`~ipaddress.IPv6Address`, :class:`~ipaddress.IPv4Network`,
1341 or :class:`~ipaddress.IPv6Network`.
Paul Kehrer31bdf792015-03-25 14:11:00 -05001342
Paul Kehrer47c32ba2015-10-28 09:12:07 +09001343.. class:: RegisteredID(value)
Paul Kehrer31bdf792015-03-25 14:11:00 -05001344
1345 .. versionadded:: 0.9
1346
1347 This corresponds to a registered ID.
1348
1349 .. attribute:: value
1350
1351 :type: :class:`ObjectIdentifier`
1352
Paul Kehrer47c32ba2015-10-28 09:12:07 +09001353.. class:: OtherName(type_id, value)
Joshua Tauberer2ee5e3c2015-07-04 20:09:46 +00001354
1355 .. versionadded:: 1.0
1356
Joshua Tauberer18b6fc82015-07-05 21:44:51 +00001357 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 +00001358
1359 .. attribute:: type_id
1360
1361 :type: :class:`ObjectIdentifier`
1362
1363 .. attribute:: value
1364
1365 :type: `bytes`
1366
Paul Kehrer8cf26422015-03-21 09:50:24 -05001367X.509 Extensions
1368~~~~~~~~~~~~~~~~
1369
Paul Kehrerfbb7ac82015-03-16 19:26:29 -05001370.. class:: Extensions
1371
1372 .. versionadded:: 0.9
1373
1374 An X.509 Extensions instance is an ordered list of extensions. The object
1375 is iterable to get every extension.
1376
Paul Kehrerfa56a232015-03-17 13:14:03 -05001377 .. method:: get_extension_for_oid(oid)
1378
1379 :param oid: An :class:`ObjectIdentifier` instance.
1380
1381 :returns: An instance of the extension class.
1382
1383 :raises cryptography.x509.ExtensionNotFound: If the certificate does
1384 not have the extension requested.
1385
Paul Kehrerfa56a232015-03-17 13:14:03 -05001386 .. doctest::
1387
Paul Kehrere27f6582015-08-10 18:33:38 -05001388 >>> from cryptography.x509.oid import ExtensionOID
1389 >>> cert.extensions.get_extension_for_oid(ExtensionOID.BASIC_CONSTRAINTS)
Paul Kehrerfa56a232015-03-17 13:14:03 -05001390 <Extension(oid=<ObjectIdentifier(oid=2.5.29.19, name=basicConstraints)>, critical=True, value=<BasicConstraints(ca=True, path_length=None)>)>
1391
Phoebe Queen019b7f82015-08-12 03:52:03 +01001392 .. method:: get_extension_for_class(extclass)
1393
Phoebe Queen6a603eb2015-08-12 14:14:49 +01001394 .. versionadded:: 1.1
1395
Phoebe Queen019b7f82015-08-12 03:52:03 +01001396 :param extclass: An extension class.
1397
1398 :returns: An instance of the extension class.
1399
1400 :raises cryptography.x509.ExtensionNotFound: If the certificate does
1401 not have the extension requested.
1402
1403 .. doctest::
1404
1405 >>> from cryptography import x509
1406 >>> cert.extensions.get_extension_for_class(x509.BasicConstraints)
1407 <Extension(oid=<ObjectIdentifier(oid=2.5.29.19, name=basicConstraints)>, critical=True, value=<BasicConstraints(ca=True, path_length=None)>)>
1408
Paul Kehrer8cf26422015-03-21 09:50:24 -05001409.. class:: Extension
1410
1411 .. versionadded:: 0.9
1412
Paul Kehrer85894662015-03-22 13:19:31 -05001413 .. attribute:: oid
1414
1415 :type: :class:`ObjectIdentifier`
1416
Paul Kehrere27f6582015-08-10 18:33:38 -05001417 One of the :class:`~cryptography.x509.oid.ExtensionOID` OIDs.
Paul Kehrer8cf26422015-03-21 09:50:24 -05001418
1419 .. attribute:: critical
1420
1421 :type: bool
1422
Paul Kehrer58b75692015-03-22 23:24:58 -05001423 Determines whether a given extension is critical or not. :rfc:`5280`
1424 requires that "A certificate-using system MUST reject the certificate
1425 if it encounters a critical extension it does not recognize or a
1426 critical extension that contains information that it cannot process".
Paul Kehrer8cf26422015-03-21 09:50:24 -05001427
Paul Kehrer85894662015-03-22 13:19:31 -05001428 .. attribute:: value
1429
1430 Returns an instance of the extension type corresponding to the OID.
1431
Paul Kehrer14f0bd02015-08-06 11:55:18 +01001432.. class:: ExtensionType
1433
1434 .. versionadded:: 1.0
1435
1436 This is the interface against which all the following extension types are
1437 registered.
1438
Paul Kehrer47c32ba2015-10-28 09:12:07 +09001439.. class:: KeyUsage(digital_signature, content_commitment, key_encipherment, data_encipherment, key_agreement, key_cert_sign, crl_sign, encipher_only, decipher_only)
Paul Kehrercecbbba2015-03-30 14:58:38 -05001440
1441 .. versionadded:: 0.9
1442
1443 The key usage extension defines the purpose of the key contained in the
1444 certificate. The usage restriction might be employed when a key that could
Paul Kehrerb33de932015-08-06 23:41:05 +01001445 be used for more than one operation is to be restricted.
Paul Kehrercecbbba2015-03-30 14:58:38 -05001446
Paul Kehrer822f3d32015-08-06 11:47:32 +01001447 .. attribute:: oid
1448
1449 .. versionadded:: 1.0
1450
1451 :type: :class:`ObjectIdentifier`
1452
Paul Kehrere27f6582015-08-10 18:33:38 -05001453 Returns :attr:`~cryptography.x509.oid.ExtensionOID.KEY_USAGE`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001454
Paul Kehrercecbbba2015-03-30 14:58:38 -05001455 .. attribute:: digital_signature
1456
1457 :type: bool
1458
Paul Kehrer738407b2015-04-01 22:39:02 -05001459 This purpose is set to true when the subject public key is used for verifying
Paul Kehrercecbbba2015-03-30 14:58:38 -05001460 digital signatures, other than signatures on certificates
1461 (``key_cert_sign``) and CRLs (``crl_sign``).
1462
1463 .. attribute:: content_commitment
1464
1465 :type: bool
1466
Paul Kehrer738407b2015-04-01 22:39:02 -05001467 This purpose is set to true when the subject public key is used for verifying
Paul Kehrercecbbba2015-03-30 14:58:38 -05001468 digital signatures, other than signatures on certificates
1469 (``key_cert_sign``) and CRLs (``crl_sign``). It is used to provide a
1470 non-repudiation service that protects against the signing entity
1471 falsely denying some action. In the case of later conflict, a
1472 reliable third party may determine the authenticity of the signed
1473 data. This was called ``non_repudiation`` in older revisions of the
1474 X.509 specification.
1475
1476 .. attribute:: key_encipherment
1477
1478 :type: bool
1479
Paul Kehrer738407b2015-04-01 22:39:02 -05001480 This purpose is set to true when the subject public key is used for
1481 enciphering private or secret keys.
Paul Kehrercecbbba2015-03-30 14:58:38 -05001482
1483 .. attribute:: data_encipherment
1484
1485 :type: bool
1486
Paul Kehrer738407b2015-04-01 22:39:02 -05001487 This purpose is set to true when the subject public key is used for
1488 directly enciphering raw user data without the use of an intermediate
1489 symmetric cipher.
Paul Kehrercecbbba2015-03-30 14:58:38 -05001490
1491 .. attribute:: key_agreement
1492
1493 :type: bool
1494
Paul Kehrer738407b2015-04-01 22:39:02 -05001495 This purpose is set to true when the subject public key is used for key
1496 agreement. For example, when a Diffie-Hellman key is to be used for
1497 key management, then this purpose is set to true.
Paul Kehrercecbbba2015-03-30 14:58:38 -05001498
1499 .. attribute:: key_cert_sign
1500
1501 :type: bool
1502
Paul Kehrer738407b2015-04-01 22:39:02 -05001503 This purpose is set to true when the subject public key is used for
1504 verifying signatures on public key certificates. If this purpose is set
1505 to true then ``ca`` must be true in the :class:`BasicConstraints`
1506 extension.
Paul Kehrercecbbba2015-03-30 14:58:38 -05001507
1508 .. attribute:: crl_sign
1509
1510 :type: bool
1511
Paul Kehrer738407b2015-04-01 22:39:02 -05001512 This purpose is set to true when the subject public key is used for
1513 verifying signatures on certificate revocation lists.
Paul Kehrercecbbba2015-03-30 14:58:38 -05001514
1515 .. attribute:: encipher_only
1516
1517 :type: bool
1518
Paul Kehrer738407b2015-04-01 22:39:02 -05001519 When this purposes is set to true and the ``key_agreement`` purpose is
1520 also set, the subject public key may be used only for enciphering data
1521 while performing key agreement.
Paul Kehrercecbbba2015-03-30 14:58:38 -05001522
1523 :raises ValueError: This is raised if accessed when ``key_agreement``
1524 is false.
1525
1526 .. attribute:: decipher_only
1527
1528 :type: bool
1529
Paul Kehrer738407b2015-04-01 22:39:02 -05001530 When this purposes is set to true and the ``key_agreement`` purpose is
1531 also set, the subject public key may be used only for deciphering data
1532 while performing key agreement.
Paul Kehrercecbbba2015-03-30 14:58:38 -05001533
1534 :raises ValueError: This is raised if accessed when ``key_agreement``
1535 is false.
1536
1537
Paul Kehrer47c32ba2015-10-28 09:12:07 +09001538.. class:: BasicConstraints(ca, path_length)
Paul Kehrer8cf26422015-03-21 09:50:24 -05001539
1540 .. versionadded:: 0.9
1541
Paul Kehrer85894662015-03-22 13:19:31 -05001542 Basic constraints is an X.509 extension type that defines whether a given
Paul Kehrer8cf26422015-03-21 09:50:24 -05001543 certificate is allowed to sign additional certificates and what path
Paul Kehrerb33de932015-08-06 23:41:05 +01001544 length restrictions may exist.
Paul Kehrer8cf26422015-03-21 09:50:24 -05001545
Paul Kehrer822f3d32015-08-06 11:47:32 +01001546 .. attribute:: oid
1547
1548 .. versionadded:: 1.0
1549
1550 :type: :class:`ObjectIdentifier`
1551
Paul Kehrere27f6582015-08-10 18:33:38 -05001552 Returns :attr:`~cryptography.x509.oid.ExtensionOID.BASIC_CONSTRAINTS`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001553
Paul Kehrer8cf26422015-03-21 09:50:24 -05001554 .. attribute:: ca
1555
1556 :type: bool
1557
1558 Whether the certificate can sign certificates.
1559
1560 .. attribute:: path_length
1561
Paul Kehrerfd1444c2015-03-21 19:47:05 -05001562 :type: int or None
Paul Kehrer8cf26422015-03-21 09:50:24 -05001563
1564 The maximum path length for certificates subordinate to this
1565 certificate. This attribute only has meaning if ``ca`` is true.
1566 If ``ca`` is true then a path length of None means there's no
1567 restriction on the number of subordinate CAs in the certificate chain.
Alex Gaynor99c5f152015-05-03 10:01:04 -04001568 If it is zero or greater then it defines the maximum length for a
1569 subordinate CA's certificate chain. For example, a ``path_length`` of 1
1570 means the certificate can sign a subordinate CA, but the subordinate CA
1571 is not allowed to create subordinates with ``ca`` set to true.
Paul Kehrer8cf26422015-03-21 09:50:24 -05001572
Paul Kehrer47c32ba2015-10-28 09:12:07 +09001573.. class:: ExtendedKeyUsage(usages)
Paul Kehrerffa2a152015-03-31 08:18:25 -05001574
1575 .. versionadded:: 0.9
1576
1577 This extension indicates one or more purposes for which the certified
1578 public key may be used, in addition to or in place of the basic
1579 purposes indicated in the key usage extension. The object is
Paul Kehrere27f6582015-08-10 18:33:38 -05001580 iterable to obtain the list of
1581 :class:`~cryptography.x509.oid.ExtendedKeyUsageOID` OIDs present.
Paul Kehrerffa2a152015-03-31 08:18:25 -05001582
Paul Kehrer1cb9e552015-10-28 09:37:29 +09001583 :param list usages: A list of
Paul Kehrer47c32ba2015-10-28 09:12:07 +09001584 :class:`~cryptography.x509.oid.ExtendedKeyUsageOID` OIDs.
1585
Paul Kehrer822f3d32015-08-06 11:47:32 +01001586 .. attribute:: oid
1587
1588 .. versionadded:: 1.0
1589
1590 :type: :class:`ObjectIdentifier`
1591
Paul Kehrere27f6582015-08-10 18:33:38 -05001592 Returns :attr:`~cryptography.x509.oid.ExtensionOID.EXTENDED_KEY_USAGE`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001593
1594
Paul Kehrer47c32ba2015-10-28 09:12:07 +09001595.. class:: OCSPNoCheck()
Paul Kehrer4a1038e2015-05-18 10:28:31 -07001596
Paul Kehrer506a2152015-05-26 08:01:18 -05001597 .. versionadded:: 1.0
Paul Kehrer4a1038e2015-05-18 10:28:31 -07001598
1599 This presence of this extension indicates that an OCSP client can trust a
1600 responder for the lifetime of the responder's certificate. CAs issuing
1601 such a certificate should realize that a compromise of the responder's key
1602 is as serious as the compromise of a CA key used to sign CRLs, at least for
1603 the validity period of this certificate. CA's may choose to issue this type
1604 of certificate with a very short lifetime and renew it frequently. This
1605 extension is only relevant when the certificate is an authorized OCSP
1606 responder.
1607
Paul Kehrer822f3d32015-08-06 11:47:32 +01001608 .. attribute:: oid
1609
1610 .. versionadded:: 1.0
1611
1612 :type: :class:`ObjectIdentifier`
1613
Paul Kehrere27f6582015-08-10 18:33:38 -05001614 Returns :attr:`~cryptography.x509.oid.ExtensionOID.OCSP_NO_CHECK`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001615
Paul Kehrer5d669662017-09-11 09:16:34 +08001616
1617.. class:: TLSFeature(features)
1618
1619 .. versionadded:: 2.1
1620
1621 The TLS Feature extension is defined in :rfc:`7633` and is used in
1622 certificates for OCSP Must-Staple. The object is iterable to get every
1623 element.
1624
1625 :param list features: A list of features to enable from the
1626 :class:`~cryptography.x509.TLSFeatureType` enum. At this time only
1627 ``status_request`` or ``status_request_v2`` are allowed.
1628
1629 .. attribute:: oid
1630
1631 :type: :class:`ObjectIdentifier`
1632
1633 Returns :attr:`~cryptography.x509.oid.ExtensionOID.TLS_FEATURE`.
1634
1635.. class:: TLSFeatureType
1636
1637 .. versionadded:: 2.1
1638
1639 An enumeration of TLS Feature types.
1640
1641 .. attribute:: status_request
1642
1643 This feature type is defined in :rfc:`6066` and, when embedded in
1644 an X.509 certificate, signals to the client that it should require
1645 a stapled OCSP response in the TLS handshake. Commonly known as OCSP
1646 Must-Staple in certificates.
1647
1648 .. attribute:: status_request_v2
1649
1650 This feature type is defined in :rfc:`6961`. This value is not
1651 commonly used and if you want to enable OCSP Must-Staple you should
1652 use ``status_request``.
1653
1654
Paul Kehrer47c32ba2015-10-28 09:12:07 +09001655.. class:: NameConstraints(permitted_subtrees, excluded_subtrees)
Paul Kehrere0017be2015-05-17 20:39:40 -06001656
1657 .. versionadded:: 1.0
1658
1659 The name constraints extension, which only has meaning in a CA certificate,
1660 defines a name space within which all subject names in certificates issued
1661 beneath the CA certificate must (or must not) be in. For specific details
1662 on the way this extension should be processed see :rfc:`5280`.
1663
Paul Kehrer822f3d32015-08-06 11:47:32 +01001664 .. attribute:: oid
1665
1666 .. versionadded:: 1.0
1667
1668 :type: :class:`ObjectIdentifier`
1669
Paul Kehrere27f6582015-08-10 18:33:38 -05001670 Returns :attr:`~cryptography.x509.oid.ExtensionOID.NAME_CONSTRAINTS`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001671
Paul Kehrere0017be2015-05-17 20:39:40 -06001672 .. attribute:: permitted_subtrees
1673
1674 :type: list of :class:`GeneralName` objects or None
1675
1676 The set of permitted name patterns. If a name matches this and an
1677 element in ``excluded_subtrees`` it is invalid. At least one of
1678 ``permitted_subtrees`` and ``excluded_subtrees`` will be non-None.
1679
1680 .. attribute:: excluded_subtrees
1681
1682 :type: list of :class:`GeneralName` objects or None
1683
1684 Any name matching a restriction in the ``excluded_subtrees`` field is
1685 invalid regardless of information appearing in the
1686 ``permitted_subtrees``. At least one of ``permitted_subtrees`` and
1687 ``excluded_subtrees`` will be non-None.
1688
Paul Kehrer47c32ba2015-10-28 09:12:07 +09001689.. class:: AuthorityKeyIdentifier(key_identifier, authority_cert_issuer, authority_cert_serial_number)
Paul Kehrer2eb4ed92015-04-11 15:33:45 -04001690
1691 .. versionadded:: 0.9
1692
1693 The authority key identifier extension provides a means of identifying the
1694 public key corresponding to the private key used to sign a certificate.
Paul Kehrer8c8cd722015-04-19 09:15:04 -05001695 This extension is typically used to assist in determining the appropriate
1696 certificate chain. For more information about generation and use of this
1697 extension see `RFC 5280 section 4.2.1.1`_.
Paul Kehrer2eb4ed92015-04-11 15:33:45 -04001698
Paul Kehrer822f3d32015-08-06 11:47:32 +01001699 .. attribute:: oid
1700
1701 .. versionadded:: 1.0
1702
1703 :type: :class:`ObjectIdentifier`
1704
Paul Kehrere27f6582015-08-10 18:33:38 -05001705 Returns
1706 :attr:`~cryptography.x509.oid.ExtensionOID.AUTHORITY_KEY_IDENTIFIER`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001707
Paul Kehrer2eb4ed92015-04-11 15:33:45 -04001708 .. attribute:: key_identifier
1709
1710 :type: bytes
1711
Paul Kehrer9104b1d2015-04-18 09:23:44 -05001712 A value derived from the public key used to verify the certificate's
Paul Kehrer8c8cd722015-04-19 09:15:04 -05001713 signature.
Paul Kehrer9104b1d2015-04-18 09:23:44 -05001714
Paul Kehrer2eb4ed92015-04-11 15:33:45 -04001715 .. attribute:: authority_cert_issuer
1716
Thom Dixon488c0482018-05-18 03:55:29 -07001717 :type: A list of :class:`GeneralName` instances or None
Paul Kehrer2eb4ed92015-04-11 15:33:45 -04001718
Paul Kehrer9104b1d2015-04-18 09:23:44 -05001719 The :class:`Name` of the issuer's issuer.
1720
Paul Kehrer2eb4ed92015-04-11 15:33:45 -04001721 .. attribute:: authority_cert_serial_number
1722
1723 :type: int or None
1724
Paul Kehrer9104b1d2015-04-18 09:23:44 -05001725 The serial number of the issuer's issuer.
1726
Paul Kehrer253929a2015-08-05 17:30:39 +01001727 .. classmethod:: from_issuer_public_key(public_key)
1728
1729 .. versionadded:: 1.0
1730
Paul Kehrer2d8e5742016-03-12 09:27:55 -04001731 .. note::
1732
1733 This method should be used if the issuer certificate does not
1734 contain a :class:`~cryptography.x509.SubjectKeyIdentifier`.
1735 Otherwise, use
1736 :meth:`~cryptography.x509.AuthorityKeyIdentifier.from_issuer_subject_key_identifier`.
1737
Paul Kehrer253929a2015-08-05 17:30:39 +01001738 Creates a new AuthorityKeyIdentifier instance using the public key
1739 provided to generate the appropriate digest. This should be the
Paul Kehrer26ac47f2015-08-08 15:20:52 -05001740 **issuer's public key**. The resulting object will contain
1741 :attr:`~cryptography.x509.AuthorityKeyIdentifier.key_identifier`, but
1742 :attr:`~cryptography.x509.AuthorityKeyIdentifier.authority_cert_issuer`
1743 and
1744 :attr:`~cryptography.x509.AuthorityKeyIdentifier.authority_cert_serial_number`
1745 will be None.
1746 The generated ``key_identifier`` is the SHA1 hash of the ``subjectPublicKey``
1747 ASN.1 bit string. This is the first recommendation in :rfc:`5280`
Paul Kehrer253929a2015-08-05 17:30:39 +01001748 section 4.2.1.2.
1749
Paul Kehrercc671822015-08-08 15:41:54 -05001750 :param public_key: One of
1751 :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey`
1752 ,
1753 :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPublicKey`
1754 , or
1755 :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey`.
Paul Kehrer253929a2015-08-05 17:30:39 +01001756
1757 .. doctest::
1758
1759 >>> from cryptography import x509
1760 >>> from cryptography.hazmat.backends import default_backend
Paul Kehrercc671822015-08-08 15:41:54 -05001761 >>> issuer_cert = x509.load_pem_x509_certificate(pem_data, default_backend())
1762 >>> x509.AuthorityKeyIdentifier.from_issuer_public_key(issuer_cert.public_key())
Paul Kehrer056c9dd2018-05-12 15:17:06 -04001763 <AuthorityKeyIdentifier(key_identifier=b'X\x01\x84$\x1b\xbc+R\x94J=\xa5\x10r\x14Q\xf5\xaf:\xc9', authority_cert_issuer=None, authority_cert_serial_number=None)>
Paul Kehrer253929a2015-08-05 17:30:39 +01001764
Paul Kehrer61ff3562016-03-11 22:51:27 -04001765 .. classmethod:: from_issuer_subject_key_identifier(ski)
1766
1767 .. versionadded:: 1.3
1768
Paul Kehrer2d8e5742016-03-12 09:27:55 -04001769 .. note::
1770 This method should be used if the issuer certificate contains a
1771 :class:`~cryptography.x509.SubjectKeyIdentifier`. Otherwise, use
1772 :meth:`~cryptography.x509.AuthorityKeyIdentifier.from_issuer_public_key`.
1773
Paul Kehrer61ff3562016-03-11 22:51:27 -04001774 Creates a new AuthorityKeyIdentifier instance using the
1775 SubjectKeyIdentifier from the issuer certificate. The resulting object
1776 will contain
1777 :attr:`~cryptography.x509.AuthorityKeyIdentifier.key_identifier`, but
1778 :attr:`~cryptography.x509.AuthorityKeyIdentifier.authority_cert_issuer`
1779 and
1780 :attr:`~cryptography.x509.AuthorityKeyIdentifier.authority_cert_serial_number`
1781 will be None.
1782
1783 :param ski: The
1784 :class:`~cryptography.x509.SubjectKeyIdentifier` from the issuer
1785 certificate.
1786
1787 .. doctest::
1788
1789 >>> from cryptography import x509
1790 >>> from cryptography.hazmat.backends import default_backend
1791 >>> issuer_cert = x509.load_pem_x509_certificate(pem_data, default_backend())
1792 >>> ski = issuer_cert.extensions.get_extension_for_class(x509.SubjectKeyIdentifier)
1793 >>> x509.AuthorityKeyIdentifier.from_issuer_subject_key_identifier(ski)
Paul Kehrer056c9dd2018-05-12 15:17:06 -04001794 <AuthorityKeyIdentifier(key_identifier=b'X\x01\x84$\x1b\xbc+R\x94J=\xa5\x10r\x14Q\xf5\xaf:\xc9', authority_cert_issuer=None, authority_cert_serial_number=None)>
Paul Kehrer61ff3562016-03-11 22:51:27 -04001795
Paul Kehrer47c32ba2015-10-28 09:12:07 +09001796.. class:: SubjectKeyIdentifier(digest)
Paul Kehrer1eb82a62015-03-31 20:00:33 -05001797
1798 .. versionadded:: 0.9
1799
1800 The subject key identifier extension provides a means of identifying
1801 certificates that contain a particular public key.
1802
Paul Kehrer822f3d32015-08-06 11:47:32 +01001803 .. attribute:: oid
1804
1805 .. versionadded:: 1.0
1806
1807 :type: :class:`ObjectIdentifier`
1808
Paul Kehrere27f6582015-08-10 18:33:38 -05001809 Returns
1810 :attr:`~cryptography.x509.oid.ExtensionOID.SUBJECT_KEY_IDENTIFIER`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001811
Paul Kehrer1eb82a62015-03-31 20:00:33 -05001812 .. attribute:: digest
1813
1814 :type: bytes
1815
1816 The binary value of the identifier.
1817
Paul Kehrerd4a7f062015-08-05 18:32:18 +01001818 .. classmethod:: from_public_key(public_key)
Paul Kehrerf22f6122015-08-05 12:57:13 +01001819
1820 .. versionadded:: 1.0
1821
1822 Creates a new SubjectKeyIdentifier instance using the public key
1823 provided to generate the appropriate digest. This should be the public
Paul Kehrereb9ec002015-08-08 10:03:02 -05001824 key that is in the certificate. The generated digest is the SHA1 hash
1825 of the ``subjectPublicKey`` ASN.1 bit string. This is the first
1826 recommendation in :rfc:`5280` section 4.2.1.2.
Paul Kehrerf22f6122015-08-05 12:57:13 +01001827
1828 :param public_key: One of
1829 :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey`
1830 ,
1831 :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPublicKey`
1832 , or
1833 :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey`.
1834
Paul Kehrer253929a2015-08-05 17:30:39 +01001835 .. doctest::
1836
1837 >>> from cryptography import x509
1838 >>> from cryptography.hazmat.backends import default_backend
Paul Kehrercc671822015-08-08 15:41:54 -05001839 >>> csr = x509.load_pem_x509_csr(pem_req_data, default_backend())
1840 >>> x509.SubjectKeyIdentifier.from_public_key(csr.public_key())
Paul Kehrer056c9dd2018-05-12 15:17:06 -04001841 <SubjectKeyIdentifier(digest=b'\xdb\xaa\xf0\x06\x11\xdbD\xfe\xbf\x93\x03\x8av\x88WP7\xa6\x91\xf7')>
Paul Kehrer253929a2015-08-05 17:30:39 +01001842
Paul Kehrer47c32ba2015-10-28 09:12:07 +09001843.. class:: SubjectAlternativeName(general_names)
Paul Kehrer31bdf792015-03-25 14:11:00 -05001844
1845 .. versionadded:: 0.9
1846
1847 Subject alternative name is an X.509 extension that provides a list of
1848 :ref:`general name <general_name_classes>` instances that provide a set
1849 of identities for which the certificate is valid. The object is iterable to
1850 get every element.
1851
Paul Kehrer1cb9e552015-10-28 09:37:29 +09001852 :param list general_names: A list of :class:`GeneralName` instances.
Paul Kehrer47c32ba2015-10-28 09:12:07 +09001853
Paul Kehrer822f3d32015-08-06 11:47:32 +01001854 .. attribute:: oid
1855
1856 .. versionadded:: 1.0
1857
1858 :type: :class:`ObjectIdentifier`
1859
Paul Kehrere27f6582015-08-10 18:33:38 -05001860 Returns
1861 :attr:`~cryptography.x509.oid.ExtensionOID.SUBJECT_ALTERNATIVE_NAME`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001862
Paul Kehrer31bdf792015-03-25 14:11:00 -05001863 .. method:: get_values_for_type(type)
1864
Gabriel Orisaka617fe4b2016-07-31 10:49:59 -03001865 :param type: A :class:`GeneralName` instance. This is one of the
Paul Kehrer31bdf792015-03-25 14:11:00 -05001866 :ref:`general name classes <general_name_classes>`.
1867
1868 :returns: A list of values extracted from the matched general names.
Joshua Taubererd2afad32015-07-06 22:37:53 +00001869 The type of the returned values depends on the :class:`GeneralName`.
Paul Kehrer31bdf792015-03-25 14:11:00 -05001870
Paul Kehrer93ae8052015-05-02 23:18:09 -05001871 .. doctest::
1872
1873 >>> from cryptography import x509
1874 >>> from cryptography.hazmat.backends import default_backend
1875 >>> from cryptography.hazmat.primitives import hashes
1876 >>> cert = x509.load_pem_x509_certificate(cryptography_cert_pem, default_backend())
Paul Kehrerd0cd5072015-05-02 23:27:00 -05001877 >>> # Get the subjectAltName extension from the certificate
Paul Kehrere27f6582015-08-10 18:33:38 -05001878 >>> ext = cert.extensions.get_extension_for_oid(ExtensionOID.SUBJECT_ALTERNATIVE_NAME)
Paul Kehrerd0cd5072015-05-02 23:27:00 -05001879 >>> # Get the dNSName entries from the SAN extension
1880 >>> ext.value.get_values_for_type(x509.DNSName)
Paul Kehrer056c9dd2018-05-12 15:17:06 -04001881 ['www.cryptography.io', 'cryptography.io']
Paul Kehrer93ae8052015-05-02 23:18:09 -05001882
Paul Kehrer8cf26422015-03-21 09:50:24 -05001883
Paul Kehrer47c32ba2015-10-28 09:12:07 +09001884.. class:: IssuerAlternativeName(general_names)
Paul Kehrer99125c92015-06-07 18:37:10 -05001885
1886 .. versionadded:: 1.0
1887
1888 Issuer alternative name is an X.509 extension that provides a list of
1889 :ref:`general name <general_name_classes>` instances that provide a set
1890 of identities for the certificate issuer. The object is iterable to
1891 get every element.
1892
Paul Kehrer1cb9e552015-10-28 09:37:29 +09001893 :param list general_names: A list of :class:`GeneralName` instances.
Paul Kehrer47c32ba2015-10-28 09:12:07 +09001894
Paul Kehrer822f3d32015-08-06 11:47:32 +01001895 .. attribute:: oid
1896
1897 .. versionadded:: 1.0
1898
1899 :type: :class:`ObjectIdentifier`
1900
Paul Kehrere27f6582015-08-10 18:33:38 -05001901 Returns
1902 :attr:`~cryptography.x509.oid.ExtensionOID.ISSUER_ALTERNATIVE_NAME`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001903
Paul Kehrer99125c92015-06-07 18:37:10 -05001904 .. method:: get_values_for_type(type)
1905
Gabriel Orisaka617fe4b2016-07-31 10:49:59 -03001906 :param type: A :class:`GeneralName` instance. This is one of the
Paul Kehrer99125c92015-06-07 18:37:10 -05001907 :ref:`general name classes <general_name_classes>`.
1908
1909 :returns: A list of values extracted from the matched general names.
1910
1911
Alex Gaynor6a0718f2017-06-04 13:36:58 -04001912.. class:: PrecertificateSignedCertificateTimestamps(scts)
1913
1914 .. versionadded:: 2.0
1915
1916 This extension contains
1917 :class:`~cryptography.x509.certificate_transparency.SignedCertificateTimestamp`
1918 instances which were issued for the pre-certificate corresponding to this
1919 certificate. These can be used to verify that the certificate is included
1920 in a public Certificate Transparency log.
1921
1922 It is an iterable containing one or more
1923 :class:`~cryptography.x509.certificate_transparency.SignedCertificateTimestamp`
1924 objects.
1925
1926 :param list scts: A ``list`` of
1927 :class:`~cryptography.x509.certificate_transparency.SignedCertificateTimestamp`
1928 objects.
1929
1930 .. attribute:: oid
1931
1932 :type: :class:`ObjectIdentifier`
1933
1934 Returns
1935 :attr:`~cryptography.x509.oid.ExtensionOID.PRECERT_SIGNED_CERTIFICATE_TIMESTAMPS`.
1936
1937
Paul Kehrer5e3cc982017-09-22 21:29:36 +08001938.. class:: DeltaCRLIndicator(crl_number)
1939
1940 .. versionadded:: 2.1
1941
1942 The delta CRL indicator is a CRL extension that identifies a CRL as being
1943 a delta CRL. Delta CRLs contain updates to revocation information
1944 previously distributed, rather than all the information that would appear
1945 in a complete CRL.
1946
1947 :param int crl_number: The CRL number of the complete CRL that the
1948 delta CRL is updating.
1949
1950 .. attribute:: oid
1951
1952 :type: :class:`ObjectIdentifier`
1953
1954 Returns
1955 :attr:`~cryptography.x509.oid.ExtensionOID.DELTA_CRL_INDICATOR`.
1956
1957 .. attribute:: crl_number
1958
1959 :type: int
1960
1961
Paul Kehrer47c32ba2015-10-28 09:12:07 +09001962.. class:: AuthorityInformationAccess(descriptions)
Paul Kehrer3e6d5582015-05-02 21:57:56 -05001963
1964 .. versionadded:: 0.9
1965
1966 The authority information access extension indicates how to access
1967 information and services for the issuer of the certificate in which
1968 the extension appears. Information and services may include online
1969 validation services (such as OCSP) and issuer data. It is an iterable,
Paul Kehrere27f6582015-08-10 18:33:38 -05001970 containing one or more :class:`~cryptography.x509.AccessDescription`
1971 instances.
Paul Kehrer3e6d5582015-05-02 21:57:56 -05001972
Paul Kehrer1cb9e552015-10-28 09:37:29 +09001973 :param list descriptions: A list of :class:`AccessDescription` objects.
Paul Kehrer47c32ba2015-10-28 09:12:07 +09001974
Paul Kehrer822f3d32015-08-06 11:47:32 +01001975 .. attribute:: oid
1976
1977 .. versionadded:: 1.0
1978
1979 :type: :class:`ObjectIdentifier`
1980
Paul Kehrere27f6582015-08-10 18:33:38 -05001981 Returns
1982 :attr:`~cryptography.x509.oid.ExtensionOID.AUTHORITY_INFORMATION_ACCESS`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001983
Paul Kehrer3e6d5582015-05-02 21:57:56 -05001984
Paul Kehrer47c32ba2015-10-28 09:12:07 +09001985.. class:: AccessDescription(access_method, access_location)
Paul Kehrer3e6d5582015-05-02 21:57:56 -05001986
Paul Kehrer5a485522015-05-06 00:29:12 -05001987 .. versionadded:: 0.9
1988
Paul Kehrer3e6d5582015-05-02 21:57:56 -05001989 .. attribute:: access_method
1990
1991 :type: :class:`ObjectIdentifier`
1992
Paul Kehrerf506bca2015-05-02 22:31:47 -05001993 The access method defines what the ``access_location`` means. It must
Paul Kehrere27f6582015-08-10 18:33:38 -05001994 be either
1995 :attr:`~cryptography.x509.oid.AuthorityInformationAccessOID.OCSP` or
1996 :attr:`~cryptography.x509.oid.AuthorityInformationAccessOID.CA_ISSUERS`.
1997 If it is
1998 :attr:`~cryptography.x509.oid.AuthorityInformationAccessOID.OCSP`
1999 the access location will be where to obtain OCSP
2000 information for the certificate. If it is
2001 :attr:`~cryptography.x509.oid.AuthorityInformationAccessOID.CA_ISSUERS`
2002 the access location will provide additional information about the
2003 issuing certificate.
Paul Kehrer3e6d5582015-05-02 21:57:56 -05002004
2005 .. attribute:: access_location
2006
2007 :type: :class:`GeneralName`
2008
Paul Kehrerf506bca2015-05-02 22:31:47 -05002009 Where to access the information defined by the access method.
2010
Paul Kehrerb76bcf82017-09-24 08:44:12 +08002011.. class:: FreshestCRL(distribution_points)
2012
2013 .. versionadded:: 2.1
2014
2015 The freshest CRL extension (also known as Delta CRL Distribution Point)
2016 identifies how delta CRL information is obtained. It is an iterable,
2017 containing one or more :class:`DistributionPoint` instances.
2018
2019 :param list distribution_points: A list of :class:`DistributionPoint`
2020 instances.
2021
2022 .. attribute:: oid
2023
2024 :type: :class:`ObjectIdentifier`
2025
2026 Returns
2027 :attr:`~cryptography.x509.oid.ExtensionOID.FRESHEST_CRL`.
2028
Paul Kehrer47c32ba2015-10-28 09:12:07 +09002029.. class:: CRLDistributionPoints(distribution_points)
Paul Kehrer5a485522015-05-06 00:29:12 -05002030
2031 .. versionadded:: 0.9
2032
2033 The CRL distribution points extension identifies how CRL information is
2034 obtained. It is an iterable, containing one or more
2035 :class:`DistributionPoint` instances.
2036
Paul Kehrer1cb9e552015-10-28 09:37:29 +09002037 :param list distribution_points: A list of :class:`DistributionPoint`
2038 instances.
Paul Kehrer47c32ba2015-10-28 09:12:07 +09002039
Paul Kehrer822f3d32015-08-06 11:47:32 +01002040 .. attribute:: oid
2041
2042 .. versionadded:: 1.0
2043
2044 :type: :class:`ObjectIdentifier`
2045
Paul Kehrere27f6582015-08-10 18:33:38 -05002046 Returns
2047 :attr:`~cryptography.x509.oid.ExtensionOID.CRL_DISTRIBUTION_POINTS`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01002048
Paul Kehrer47c32ba2015-10-28 09:12:07 +09002049.. class:: DistributionPoint(full_name, relative_name, reasons, crl_issuer)
Paul Kehrer5a485522015-05-06 00:29:12 -05002050
2051 .. versionadded:: 0.9
2052
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05002053 .. attribute:: full_name
Paul Kehrer5a485522015-05-06 00:29:12 -05002054
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05002055 :type: list of :class:`GeneralName` instances or None
Paul Kehrer5a485522015-05-06 00:29:12 -05002056
Paul Kehrerf2c072b2015-05-09 17:04:28 -05002057 This field describes methods to retrieve the CRL. At most one of
2058 ``full_name`` or ``relative_name`` will be non-None.
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05002059
2060 .. attribute:: relative_name
2061
Fraser Tweedale02467dd2016-11-07 15:54:04 +10002062 :type: :class:`RelativeDistinguishedName` or None
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05002063
2064 This field describes methods to retrieve the CRL relative to the CRL
Paul Kehrerf2c072b2015-05-09 17:04:28 -05002065 issuer. At most one of ``full_name`` or ``relative_name`` will be
2066 non-None.
Paul Kehrer5a485522015-05-06 00:29:12 -05002067
Fraser Tweedale02467dd2016-11-07 15:54:04 +10002068 .. versionchanged:: 1.6
2069 Changed from :class:`Name` to :class:`RelativeDistinguishedName`.
2070
Paul Kehrer5a485522015-05-06 00:29:12 -05002071 .. attribute:: crl_issuer
2072
2073 :type: list of :class:`GeneralName` instances or None
2074
2075 Information about the issuer of the CRL.
2076
2077 .. attribute:: reasons
2078
Paul Kehrer3fd02602015-05-09 19:46:13 -05002079 :type: frozenset of :class:`ReasonFlags` or None
Paul Kehrer5a485522015-05-06 00:29:12 -05002080
2081 The reasons a given distribution point may be used for when performing
2082 revocation checks.
2083
2084.. class:: ReasonFlags
2085
2086 .. versionadded:: 0.9
2087
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05002088 An enumeration for CRL reasons.
2089
2090 .. attribute:: unspecified
2091
2092 It is unspecified why the certificate was revoked. This reason cannot
2093 be used as a reason flag in a :class:`DistributionPoint`.
Paul Kehrer5a485522015-05-06 00:29:12 -05002094
2095 .. attribute:: key_compromise
2096
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05002097 This reason indicates that the private key was compromised.
Paul Kehrer5a485522015-05-06 00:29:12 -05002098
2099 .. attribute:: ca_compromise
2100
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05002101 This reason indicates that the CA issuing the certificate was
2102 compromised.
Paul Kehrer5a485522015-05-06 00:29:12 -05002103
2104 .. attribute:: affiliation_changed
2105
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05002106 This reason indicates that the subject's name or other information has
2107 changed.
Paul Kehrer5a485522015-05-06 00:29:12 -05002108
2109 .. attribute:: superseded
2110
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05002111 This reason indicates that a certificate has been superseded.
Paul Kehrer5a485522015-05-06 00:29:12 -05002112
2113 .. attribute:: cessation_of_operation
2114
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05002115 This reason indicates that the certificate is no longer required.
Paul Kehrer5a485522015-05-06 00:29:12 -05002116
2117 .. attribute:: certificate_hold
2118
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05002119 This reason indicates that the certificate is on hold.
Paul Kehrer5a485522015-05-06 00:29:12 -05002120
2121 .. attribute:: privilege_withdrawn
2122
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05002123 This reason indicates that the privilege granted by this certificate
2124 have been withdrawn.
Paul Kehrer5a485522015-05-06 00:29:12 -05002125
2126 .. attribute:: aa_compromise
2127
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05002128 When an attribute authority has been compromised.
2129
2130 .. attribute:: remove_from_crl
2131
2132 This reason indicates that the certificate was on hold and should be
2133 removed from the CRL. This reason cannot be used as a reason flag
2134 in a :class:`DistributionPoint`.
Paul Kehrer5a485522015-05-06 00:29:12 -05002135
Paul Kehrer47c32ba2015-10-28 09:12:07 +09002136.. class:: InhibitAnyPolicy(skip_certs)
Paul Kehrer16fae762015-05-01 23:14:20 -05002137
2138 .. versionadded:: 1.0
2139
2140 The inhibit ``anyPolicy`` extension indicates that the special OID
Paul Kehrere27f6582015-08-10 18:33:38 -05002141 :attr:`~cryptography.x509.oid.CertificatePoliciesOID.ANY_POLICY`, is not
2142 considered an explicit match for other :class:`CertificatePolicies` except
2143 when it appears in an intermediate self-issued CA certificate. The value
2144 indicates the number of additional non-self-issued certificates that may
2145 appear in the path before
2146 :attr:`~cryptography.x509.oid.CertificatePoliciesOID.ANY_POLICY` is no
2147 longer permitted. For example, a value of one indicates that
2148 :attr:`~cryptography.x509.oid.CertificatePoliciesOID.ANY_POLICY` may be
2149 processed in certificates issued by the subject of this certificate, but
2150 not in additional certificates in the path.
Paul Kehrer16fae762015-05-01 23:14:20 -05002151
Paul Kehrer822f3d32015-08-06 11:47:32 +01002152 .. attribute:: oid
2153
2154 .. versionadded:: 1.0
2155
2156 :type: :class:`ObjectIdentifier`
2157
Paul Kehrere27f6582015-08-10 18:33:38 -05002158 Returns
2159 :attr:`~cryptography.x509.oid.ExtensionOID.INHIBIT_ANY_POLICY`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01002160
Paul Kehrer16fae762015-05-01 23:14:20 -05002161 .. attribute:: skip_certs
2162
2163 :type: int
2164
Paul Kehrer7e8fe9d2015-05-18 09:53:47 -07002165.. class:: PolicyConstraints
2166
2167 .. versionadded:: 1.3
2168
Paul Kehrer648c0fb2016-02-26 16:10:36 -06002169 The policy constraints extension is used to inhibit policy mapping or
2170 require that each certificate in a chain contain an acceptable policy
Paul Kehrer7e8fe9d2015-05-18 09:53:47 -07002171 identifier. For more information about the use of this extension see
2172 :rfc:`5280`.
2173
Paul Kehrer159b3b52016-02-26 08:27:22 -06002174 .. attribute:: oid
2175
2176 :type: :class:`ObjectIdentifier`
2177
2178 Returns :attr:`~cryptography.x509.oid.ExtensionOID.POLICY_CONSTRAINTS`.
2179
Paul Kehrer7e8fe9d2015-05-18 09:53:47 -07002180 .. attribute:: require_explicit_policy
2181
2182 :type: int or None
2183
Paul Kehrer648c0fb2016-02-26 16:10:36 -06002184 If this field is not None, the value indicates the number of additional
2185 certificates that may appear in the chain before an explicit policy is
Paul Kehrer7e8fe9d2015-05-18 09:53:47 -07002186 required for the entire path. When an explicit policy is required, it
Paul Kehrer648c0fb2016-02-26 16:10:36 -06002187 is necessary for all certificates in the chain to contain an acceptable
Paul Kehrer7e8fe9d2015-05-18 09:53:47 -07002188 policy identifier in the certificate policies extension. An
2189 acceptable policy identifier is the identifier of a policy required
2190 by the user of the certification path or the identifier of a policy
2191 that has been declared equivalent through policy mapping.
2192
2193 .. attribute:: inhibit_policy_mapping
2194
2195 :type: int or None
2196
Paul Kehrer648c0fb2016-02-26 16:10:36 -06002197 If this field is not None, the value indicates the number of additional
2198 certificates that may appear in the chain before policy mapping is no
Paul Kehrer7e8fe9d2015-05-18 09:53:47 -07002199 longer permitted. For example, a value of one indicates that policy
2200 mapping may be processed in certificates issued by the subject of this
Paul Kehrer648c0fb2016-02-26 16:10:36 -06002201 certificate, but not in additional certificates in the chain.
Paul Kehrer7e8fe9d2015-05-18 09:53:47 -07002202
Paul Kehrer3b95cd72015-12-22 21:40:20 -06002203.. class:: CRLNumber(crl_number)
2204
2205 .. versionadded:: 1.2
2206
Paul Kehrere32b9942015-12-22 22:26:53 -06002207 The CRL number is a CRL extension that conveys a monotonically increasing
2208 sequence number for a given CRL scope and CRL issuer. This extension allows
2209 users to easily determine when a particular CRL supersedes another CRL.
2210 :rfc:`5280` requires that this extension be present in conforming CRLs.
Paul Kehrer3b95cd72015-12-22 21:40:20 -06002211
2212 .. attribute:: oid
2213
2214 :type: :class:`ObjectIdentifier`
2215
2216 Returns
2217 :attr:`~cryptography.x509.oid.ExtensionOID.CRL_NUMBER`.
2218
2219 .. attribute:: crl_number
2220
2221 :type: int
2222
Paul Kehrer14fd6972015-12-30 10:58:25 -06002223.. class:: UnrecognizedExtension
2224
2225 .. versionadded:: 1.2
2226
Alex Gaynord08ddd52017-05-20 09:01:54 -07002227 A generic extension class used to hold the raw value of extensions that
2228 ``cryptography`` does not know how to parse.
Paul Kehrer14fd6972015-12-30 10:58:25 -06002229
2230 .. attribute:: oid
2231
2232 :type: :class:`ObjectIdentifier`
2233
2234 Returns the OID associated with this extension.
2235
2236 .. attribute:: value
2237
2238 :type: byte
2239
2240 Returns the DER encoded bytes payload of the extension.
2241
Paul Kehrer47c32ba2015-10-28 09:12:07 +09002242.. class:: CertificatePolicies(policies)
Paul Kehrer0d210922015-04-28 17:31:07 -05002243
2244 .. versionadded:: 0.9
2245
Paul Kehrer2e879742015-05-02 23:09:56 -05002246 The certificate policies extension is an iterable, containing one or more
2247 :class:`PolicyInformation` instances.
Paul Kehrer0d210922015-04-28 17:31:07 -05002248
Paul Kehrer1cb9e552015-10-28 09:37:29 +09002249 :param list policies: A list of :class:`PolicyInformation` instances.
Paul Kehrer47c32ba2015-10-28 09:12:07 +09002250
Paul Kehrer822f3d32015-08-06 11:47:32 +01002251 .. attribute:: oid
2252
2253 .. versionadded:: 1.0
2254
2255 :type: :class:`ObjectIdentifier`
2256
Paul Kehrere27f6582015-08-10 18:33:38 -05002257 Returns
2258 :attr:`~cryptography.x509.oid.ExtensionOID.CERTIFICATE_POLICIES`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01002259
Paul Kehrer0d210922015-04-28 17:31:07 -05002260Certificate Policies Classes
2261~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2262
2263These classes may be present within a :class:`CertificatePolicies` instance.
2264
Paul Kehrer47c32ba2015-10-28 09:12:07 +09002265.. class:: PolicyInformation(policy_identifier, policy_qualifiers)
Paul Kehrer0d210922015-04-28 17:31:07 -05002266
2267 .. versionadded:: 0.9
2268
2269 Contains a policy identifier and an optional list of qualifiers.
2270
2271 .. attribute:: policy_identifier
2272
2273 :type: :class:`ObjectIdentifier`
2274
2275 .. attribute:: policy_qualifiers
2276
2277 :type: list
2278
Paul Kehrerba35b3b2015-05-10 13:07:59 -05002279 A list consisting of :term:`text` and/or :class:`UserNotice` objects.
Paul Kehrer3f8ddeb2015-05-11 00:25:36 -05002280 If the value is text it is a pointer to the practice statement
2281 published by the certificate authority. If it is a user notice it is
2282 meant for display to the relying party when the certificate is
2283 used.
Paul Kehrer2e879742015-05-02 23:09:56 -05002284
Paul Kehrer47c32ba2015-10-28 09:12:07 +09002285.. class:: UserNotice(notice_reference, explicit_text)
Paul Kehrer0d210922015-04-28 17:31:07 -05002286
2287 .. versionadded:: 0.9
2288
Paul Kehrer2e879742015-05-02 23:09:56 -05002289 User notices are intended for display to a relying party when a certificate
2290 is used. In practice, few if any UIs expose this data and it is a rarely
2291 encoded component.
2292
Paul Kehrer0d210922015-04-28 17:31:07 -05002293 .. attribute:: notice_reference
2294
2295 :type: :class:`NoticeReference` or None
2296
Paul Kehrer2e879742015-05-02 23:09:56 -05002297 The notice reference field names an organization and identifies,
2298 by number, a particular statement prepared by that organization.
2299
Paul Kehrer0d210922015-04-28 17:31:07 -05002300 .. attribute:: explicit_text
2301
Paul Kehrer2e879742015-05-02 23:09:56 -05002302 This field includes an arbitrary textual statement directly in the
2303 certificate.
2304
Paul Kehrer0d210922015-04-28 17:31:07 -05002305 :type: :term:`text`
2306
Paul Kehrer47c32ba2015-10-28 09:12:07 +09002307.. class:: NoticeReference(organization, notice_numbers)
Paul Kehrer0d210922015-04-28 17:31:07 -05002308
Paul Kehrer2e879742015-05-02 23:09:56 -05002309 Notice reference can name an organization and provide information about
2310 notices related to the certificate. For example, it might identify the
2311 organization name and notice number 1. Application software could
2312 have a notice file containing the current set of notices for the named
2313 organization; the application would then extract the notice text from the
2314 file and display it. In practice this is rarely seen.
2315
Paul Kehrer0d210922015-04-28 17:31:07 -05002316 .. versionadded:: 0.9
2317
2318 .. attribute:: organization
2319
Paul Kehrer66c61702015-05-12 16:39:18 -05002320 :type: :term:`text`
Paul Kehrer0d210922015-04-28 17:31:07 -05002321
Paul Kehrer3f8ddeb2015-05-11 00:25:36 -05002322 .. attribute:: notice_numbers
Paul Kehrer0d210922015-04-28 17:31:07 -05002323
Paul Kehrer66c61702015-05-12 16:39:18 -05002324 :type: list
Paul Kehrer0d210922015-04-28 17:31:07 -05002325
Paul Kehrer66c61702015-05-12 16:39:18 -05002326 A list of integers.
Paul Kehrer0d210922015-04-28 17:31:07 -05002327
Paul Kehrere5f152b2015-12-25 23:55:47 -06002328.. _crl_entry_extensions:
2329
Paul Kehrer49bb7562015-12-25 16:17:40 -06002330CRL Entry Extensions
2331~~~~~~~~~~~~~~~~~~~~
2332
2333These extensions are only valid within a :class:`RevokedCertificate` object.
2334
2335.. class:: CertificateIssuer(general_names)
2336
2337 .. versionadded:: 1.2
2338
2339 The certificate issuer is an extension that is only valid inside
2340 :class:`~cryptography.x509.RevokedCertificate` objects. If the
2341 ``indirectCRL`` property of the parent CRL's IssuingDistributionPoint
2342 extension is set, then this extension identifies the certificate issuer
2343 associated with the revoked certificate. The object is iterable to get
2344 every element.
2345
2346 :param list general_names: A list of :class:`GeneralName` instances.
2347
2348 .. attribute:: oid
2349
2350 :type: :class:`ObjectIdentifier`
2351
2352 Returns
2353 :attr:`~cryptography.x509.oid.CRLEntryExtensionOID.CERTIFICATE_ISSUER`.
2354
2355 .. method:: get_values_for_type(type)
2356
2357 :param type: A :class:`GeneralName` instance. This is one of the
2358 :ref:`general name classes <general_name_classes>`.
2359
2360 :returns: A list of values extracted from the matched general names.
2361 The type of the returned values depends on the :class:`GeneralName`.
2362
Paul Kehrer7058ece2015-12-25 22:28:29 -06002363.. class:: CRLReason(reason)
2364
2365 .. versionadded:: 1.2
2366
2367 CRL reason (also known as ``reasonCode``) is an extension that is only
2368 valid inside :class:`~cryptography.x509.RevokedCertificate` objects. It
2369 identifies a reason for the certificate revocation.
2370
Paul Kehrerce4d0842017-09-20 22:14:26 +08002371 :param reason: An element from :class:`~cryptography.x509.ReasonFlags`.
Paul Kehrer7058ece2015-12-25 22:28:29 -06002372
2373 .. attribute:: oid
2374
2375 :type: :class:`ObjectIdentifier`
2376
2377 Returns
2378 :attr:`~cryptography.x509.oid.CRLEntryExtensionOID.CRL_REASON`.
2379
2380 .. attribute:: reason
2381
2382 :type: An element from :class:`~cryptography.x509.ReasonFlags`
2383
Paul Kehrer23c0bbc2015-12-25 22:35:19 -06002384.. class:: InvalidityDate(invalidity_date)
2385
2386 .. versionadded:: 1.2
2387
2388 Invalidity date is an extension that is only valid inside
2389 :class:`~cryptography.x509.RevokedCertificate` objects. It provides
2390 the date on which it is known or suspected that the private key was
2391 compromised or that the certificate otherwise became invalid.
2392 This date may be earlier than the revocation date in the CRL entry,
2393 which is the date at which the CA processed the revocation.
2394
2395 :param invalidity_date: The :class:`datetime.datetime` when it is known
2396 or suspected that the private key was compromised.
2397
2398 .. attribute:: oid
2399
2400 :type: :class:`ObjectIdentifier`
2401
2402 Returns
2403 :attr:`~cryptography.x509.oid.CRLEntryExtensionOID.INVALIDITY_DATE`.
2404
2405 .. attribute:: invalidity_date
2406
2407 :type: :class:`datetime.datetime`
2408
Paul Kehrer49bb7562015-12-25 16:17:40 -06002409
Paul Kehrer912d3fb2015-01-29 11:19:22 -06002410Object Identifiers
2411~~~~~~~~~~~~~~~~~~
2412
Paul Kehrer4bb46492015-02-07 16:59:14 -06002413X.509 elements are frequently identified by :class:`ObjectIdentifier`
2414instances. The following common OIDs are available as constants.
Paul Kehrer912d3fb2015-01-29 11:19:22 -06002415
Paul Kehrere27f6582015-08-10 18:33:38 -05002416.. currentmodule:: cryptography.x509.oid
Paul Kehrer56da2a52015-02-11 23:35:07 -06002417
Paul Kehrere27f6582015-08-10 18:33:38 -05002418.. class:: NameOID
Paul Kehrer912d3fb2015-01-29 11:19:22 -06002419
Paul Kehrere27f6582015-08-10 18:33:38 -05002420 These OIDs are typically seen in X.509 names.
Paul Kehrer858b9b72015-02-05 09:50:31 -06002421
Paul Kehrere27f6582015-08-10 18:33:38 -05002422 .. versionadded:: 1.0
Paul Kehrer912d3fb2015-01-29 11:19:22 -06002423
Paul Kehrere27f6582015-08-10 18:33:38 -05002424 .. attribute:: COMMON_NAME
Paul Kehrer858b9b72015-02-05 09:50:31 -06002425
Paul Kehrere27f6582015-08-10 18:33:38 -05002426 Corresponds to the dotted string ``"2.5.4.3"``. Historically the domain
2427 name would be encoded here for server certificates. :rfc:`2818`
2428 deprecates this practice and names of that type should now be located
2429 in a :class:`~cryptography.x509.SubjectAlternativeName` extension.
Paul Kehrer912d3fb2015-01-29 11:19:22 -06002430
Paul Kehrere27f6582015-08-10 18:33:38 -05002431 .. attribute:: COUNTRY_NAME
Paul Kehrer858b9b72015-02-05 09:50:31 -06002432
Paul Kehrere27f6582015-08-10 18:33:38 -05002433 Corresponds to the dotted string ``"2.5.4.6"``.
Paul Kehrer912d3fb2015-01-29 11:19:22 -06002434
Paul Kehrere27f6582015-08-10 18:33:38 -05002435 .. attribute:: LOCALITY_NAME
Paul Kehrer858b9b72015-02-05 09:50:31 -06002436
Paul Kehrere27f6582015-08-10 18:33:38 -05002437 Corresponds to the dotted string ``"2.5.4.7"``.
Paul Kehrer912d3fb2015-01-29 11:19:22 -06002438
Paul Kehrere27f6582015-08-10 18:33:38 -05002439 .. attribute:: STATE_OR_PROVINCE_NAME
Paul Kehrer858b9b72015-02-05 09:50:31 -06002440
Paul Kehrere27f6582015-08-10 18:33:38 -05002441 Corresponds to the dotted string ``"2.5.4.8"``.
Paul Kehrer912d3fb2015-01-29 11:19:22 -06002442
Paul Kehrerc3b8ff62016-11-11 17:38:59 -08002443 .. attribute:: STREET_ADDRESS
2444
2445 .. versionadded:: 1.6
2446
2447 Corresponds to the dotted string ``"2.5.4.9"``.
2448
Paul Kehrere27f6582015-08-10 18:33:38 -05002449 .. attribute:: ORGANIZATION_NAME
Paul Kehrer858b9b72015-02-05 09:50:31 -06002450
Paul Kehrere27f6582015-08-10 18:33:38 -05002451 Corresponds to the dotted string ``"2.5.4.10"``.
Paul Kehrer912d3fb2015-01-29 11:19:22 -06002452
Paul Kehrere27f6582015-08-10 18:33:38 -05002453 .. attribute:: ORGANIZATIONAL_UNIT_NAME
Paul Kehrer858b9b72015-02-05 09:50:31 -06002454
Paul Kehrere27f6582015-08-10 18:33:38 -05002455 Corresponds to the dotted string ``"2.5.4.11"``.
Paul Kehrer912d3fb2015-01-29 11:19:22 -06002456
Paul Kehrere27f6582015-08-10 18:33:38 -05002457 .. attribute:: SERIAL_NUMBER
Paul Kehrer858b9b72015-02-05 09:50:31 -06002458
Paul Kehrere27f6582015-08-10 18:33:38 -05002459 Corresponds to the dotted string ``"2.5.4.5"``. This is distinct from
2460 the serial number of the certificate itself (which can be obtained with
Chelsea Winfreee295f3a2016-06-02 21:15:54 -07002461 :func:`~cryptography.x509.Certificate.serial_number`).
Paul Kehrer912d3fb2015-01-29 11:19:22 -06002462
Paul Kehrere27f6582015-08-10 18:33:38 -05002463 .. attribute:: SURNAME
Paul Kehrer858b9b72015-02-05 09:50:31 -06002464
Paul Kehrere27f6582015-08-10 18:33:38 -05002465 Corresponds to the dotted string ``"2.5.4.4"``.
Paul Kehrer912d3fb2015-01-29 11:19:22 -06002466
Paul Kehrere27f6582015-08-10 18:33:38 -05002467 .. attribute:: GIVEN_NAME
Paul Kehrer858b9b72015-02-05 09:50:31 -06002468
Paul Kehrere27f6582015-08-10 18:33:38 -05002469 Corresponds to the dotted string ``"2.5.4.42"``.
Paul Kehrer912d3fb2015-01-29 11:19:22 -06002470
Paul Kehrere27f6582015-08-10 18:33:38 -05002471 .. attribute:: TITLE
Paul Kehrer858b9b72015-02-05 09:50:31 -06002472
Paul Kehrere27f6582015-08-10 18:33:38 -05002473 Corresponds to the dotted string ``"2.5.4.12"``.
Paul Kehrer912d3fb2015-01-29 11:19:22 -06002474
Paul Kehrere27f6582015-08-10 18:33:38 -05002475 .. attribute:: GENERATION_QUALIFIER
Paul Kehrer858b9b72015-02-05 09:50:31 -06002476
Paul Kehrere27f6582015-08-10 18:33:38 -05002477 Corresponds to the dotted string ``"2.5.4.44"``.
Paul Kehrer912d3fb2015-01-29 11:19:22 -06002478
Paul Kehrerc7ab9312016-11-12 05:00:42 -08002479 .. attribute:: X500_UNIQUE_IDENTIFIER
Paul Kehrerc3b8ff62016-11-11 17:38:59 -08002480
2481 .. versionadded:: 1.6
2482
2483 Corresponds to the dotted string ``"2.5.4.45"``.
2484
Paul Kehrere27f6582015-08-10 18:33:38 -05002485 .. attribute:: DN_QUALIFIER
Paul Kehrer858b9b72015-02-05 09:50:31 -06002486
Paul Kehrere27f6582015-08-10 18:33:38 -05002487 Corresponds to the dotted string ``"2.5.4.46"``. This specifies
2488 disambiguating information to add to the relative distinguished name of an
2489 entry. See :rfc:`2256`.
Paul Kehrer912d3fb2015-01-29 11:19:22 -06002490
Paul Kehrere27f6582015-08-10 18:33:38 -05002491 .. attribute:: PSEUDONYM
Paul Kehrer858b9b72015-02-05 09:50:31 -06002492
Paul Kehrere27f6582015-08-10 18:33:38 -05002493 Corresponds to the dotted string ``"2.5.4.65"``.
Paul Kehrer912d3fb2015-01-29 11:19:22 -06002494
Paul Kehrer36d5cd62016-11-19 22:05:26 +08002495 .. attribute:: USER_ID
2496
2497 .. versionadded:: 1.6
2498
2499 Corresponds to the dotted string ``"0.9.2342.19200300.100.1.1"``.
2500
Paul Kehrere27f6582015-08-10 18:33:38 -05002501 .. attribute:: DOMAIN_COMPONENT
Paul Kehrer858b9b72015-02-05 09:50:31 -06002502
Paul Kehrere27f6582015-08-10 18:33:38 -05002503 Corresponds to the dotted string ``"0.9.2342.19200300.100.1.25"``. A string
2504 holding one component of a domain name. See :rfc:`4519`.
Paul Kehrer56da2a52015-02-11 23:35:07 -06002505
Paul Kehrere27f6582015-08-10 18:33:38 -05002506 .. attribute:: EMAIL_ADDRESS
Paul Kehrer56da2a52015-02-11 23:35:07 -06002507
Paul Kehrere27f6582015-08-10 18:33:38 -05002508 Corresponds to the dotted string ``"1.2.840.113549.1.9.1"``.
Paul Kehrer56da2a52015-02-11 23:35:07 -06002509
Alex Gaynor1d3f2bf2015-12-19 12:15:09 -05002510 .. attribute:: JURISDICTION_COUNTRY_NAME
2511
2512 Corresponds to the dotted string ``"1.3.6.1.4.1.311.60.2.1.3"``.
2513
Alex Gaynor45e507f2015-12-19 13:44:23 -05002514 .. attribute:: JURISDICTION_LOCALITY_NAME
2515
2516 Corresponds to the dotted string ``"1.3.6.1.4.1.311.60.2.1.1"``.
2517
2518 .. attribute:: JURISDICTION_STATE_OR_PROVINCE_NAME
2519
2520 Corresponds to the dotted string ``"1.3.6.1.4.1.311.60.2.1.2"``.
2521
Alex Gaynora2293c82015-12-19 20:49:15 -05002522 .. attribute:: BUSINESS_CATEGORY
2523
2524 Corresponds to the dotted string ``"2.5.4.15"``.
2525
Paul Kehrer36d5cd62016-11-19 22:05:26 +08002526 .. attribute:: POSTAL_ADDRESS
2527
2528 .. versionadded:: 1.6
2529
2530 Corresponds to the dotted string ``"2.5.4.16"``.
2531
2532 .. attribute:: POSTAL_CODE
2533
2534 .. versionadded:: 1.6
2535
2536 Corresponds to the dotted string ``"2.5.4.17"``.
2537
Paul Kehrer56da2a52015-02-11 23:35:07 -06002538
Paul Kehrere27f6582015-08-10 18:33:38 -05002539.. class:: SignatureAlgorithmOID
Paul Kehrer56da2a52015-02-11 23:35:07 -06002540
Paul Kehrere27f6582015-08-10 18:33:38 -05002541 .. versionadded:: 1.0
Paul Kehrer56da2a52015-02-11 23:35:07 -06002542
Paul Kehrere27f6582015-08-10 18:33:38 -05002543 .. attribute:: RSA_WITH_MD5
Paul Kehrer56da2a52015-02-11 23:35:07 -06002544
Paul Kehrere27f6582015-08-10 18:33:38 -05002545 Corresponds to the dotted string ``"1.2.840.113549.1.1.4"``. This is
2546 an MD5 digest signed by an RSA key.
Paul Kehrer56da2a52015-02-11 23:35:07 -06002547
Paul Kehrere27f6582015-08-10 18:33:38 -05002548 .. attribute:: RSA_WITH_SHA1
Paul Kehrer56da2a52015-02-11 23:35:07 -06002549
Paul Kehrere27f6582015-08-10 18:33:38 -05002550 Corresponds to the dotted string ``"1.2.840.113549.1.1.5"``. This is
2551 a SHA1 digest signed by an RSA key.
Paul Kehrer56da2a52015-02-11 23:35:07 -06002552
Paul Kehrere27f6582015-08-10 18:33:38 -05002553 .. attribute:: RSA_WITH_SHA224
Paul Kehrer56da2a52015-02-11 23:35:07 -06002554
Paul Kehrere27f6582015-08-10 18:33:38 -05002555 Corresponds to the dotted string ``"1.2.840.113549.1.1.14"``. This is
2556 a SHA224 digest signed by an RSA key.
Paul Kehrer56da2a52015-02-11 23:35:07 -06002557
Paul Kehrere27f6582015-08-10 18:33:38 -05002558 .. attribute:: RSA_WITH_SHA256
Paul Kehrer56da2a52015-02-11 23:35:07 -06002559
Paul Kehrere27f6582015-08-10 18:33:38 -05002560 Corresponds to the dotted string ``"1.2.840.113549.1.1.11"``. This is
2561 a SHA256 digest signed by an RSA key.
Alex Gaynor3aadabf2015-06-23 22:06:21 -04002562
Paul Kehrere27f6582015-08-10 18:33:38 -05002563 .. attribute:: RSA_WITH_SHA384
Alex Gaynor3aadabf2015-06-23 22:06:21 -04002564
Paul Kehrere27f6582015-08-10 18:33:38 -05002565 Corresponds to the dotted string ``"1.2.840.113549.1.1.12"``. This is
2566 a SHA384 digest signed by an RSA key.
Paul Kehrer56da2a52015-02-11 23:35:07 -06002567
Paul Kehrere27f6582015-08-10 18:33:38 -05002568 .. attribute:: RSA_WITH_SHA512
Paul Kehrer56da2a52015-02-11 23:35:07 -06002569
Paul Kehrere27f6582015-08-10 18:33:38 -05002570 Corresponds to the dotted string ``"1.2.840.113549.1.1.13"``. This is
2571 a SHA512 digest signed by an RSA key.
Paul Kehrer56da2a52015-02-11 23:35:07 -06002572
Marti Raudsepp33678062018-06-30 02:27:28 +03002573 .. attribute:: RSASSA_PSS
2574
2575 .. versionadded:: 2.3
2576
2577 Corresponds to the dotted string ``"1.2.840.113549.1.1.10"``. This is
2578 signed by an RSA key using the Probabilistic Signature Scheme (PSS)
2579 padding from RFC 4055. The hash function and padding are defined by
2580 signature algorithm parameters.
2581
Paul Kehrere27f6582015-08-10 18:33:38 -05002582 .. attribute:: ECDSA_WITH_SHA1
Paul Kehrer56da2a52015-02-11 23:35:07 -06002583
Paul Kehrere27f6582015-08-10 18:33:38 -05002584 Corresponds to the dotted string ``"1.2.840.10045.4.1"``. This is a SHA1
2585 digest signed by an ECDSA key.
Paul Kehrer56da2a52015-02-11 23:35:07 -06002586
Paul Kehrere27f6582015-08-10 18:33:38 -05002587 .. attribute:: ECDSA_WITH_SHA224
Paul Kehrer56da2a52015-02-11 23:35:07 -06002588
Paul Kehrere27f6582015-08-10 18:33:38 -05002589 Corresponds to the dotted string ``"1.2.840.10045.4.3.1"``. This is
2590 a SHA224 digest signed by an ECDSA key.
2591
2592 .. attribute:: ECDSA_WITH_SHA256
2593
2594 Corresponds to the dotted string ``"1.2.840.10045.4.3.2"``. This is
2595 a SHA256 digest signed by an ECDSA key.
2596
2597 .. attribute:: ECDSA_WITH_SHA384
2598
2599 Corresponds to the dotted string ``"1.2.840.10045.4.3.3"``. This is
2600 a SHA384 digest signed by an ECDSA key.
2601
2602 .. attribute:: ECDSA_WITH_SHA512
2603
2604 Corresponds to the dotted string ``"1.2.840.10045.4.3.4"``. This is
2605 a SHA512 digest signed by an ECDSA key.
2606
2607 .. attribute:: DSA_WITH_SHA1
2608
2609 Corresponds to the dotted string ``"1.2.840.10040.4.3"``. This is
2610 a SHA1 digest signed by a DSA key.
2611
2612 .. attribute:: DSA_WITH_SHA224
2613
2614 Corresponds to the dotted string ``"2.16.840.1.101.3.4.3.1"``. This is
2615 a SHA224 digest signed by a DSA key.
2616
2617 .. attribute:: DSA_WITH_SHA256
Paul Kehrer56da2a52015-02-11 23:35:07 -06002618
Paul Kehrere27f6582015-08-10 18:33:38 -05002619 Corresponds to the dotted string ``"2.16.840.1.101.3.4.3.2"``. This is
2620 a SHA256 digest signed by a DSA key.
Paul Kehrer56da2a52015-02-11 23:35:07 -06002621
Paul Kehrer56da2a52015-02-11 23:35:07 -06002622
Paul Kehrere27f6582015-08-10 18:33:38 -05002623.. class:: ExtendedKeyUsageOID
Paul Kehrer56da2a52015-02-11 23:35:07 -06002624
Paul Kehrere27f6582015-08-10 18:33:38 -05002625 .. versionadded:: 1.0
Paul Kehrer56da2a52015-02-11 23:35:07 -06002626
Paul Kehrere27f6582015-08-10 18:33:38 -05002627 .. attribute:: SERVER_AUTH
Paul Kehrer56da2a52015-02-11 23:35:07 -06002628
Paul Kehrere27f6582015-08-10 18:33:38 -05002629 Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.1"``. This is used
2630 to denote that a certificate may be used for TLS web server
2631 authentication.
Paul Kehrer56da2a52015-02-11 23:35:07 -06002632
Paul Kehrere27f6582015-08-10 18:33:38 -05002633 .. attribute:: CLIENT_AUTH
Paul Kehrer56da2a52015-02-11 23:35:07 -06002634
Paul Kehrere27f6582015-08-10 18:33:38 -05002635 Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.2"``. This is used
2636 to denote that a certificate may be used for TLS web client
2637 authentication.
Paul Kehrerffa2a152015-03-31 08:18:25 -05002638
Paul Kehrere27f6582015-08-10 18:33:38 -05002639 .. attribute:: CODE_SIGNING
Paul Kehrere1513fa2015-03-30 23:08:17 -05002640
Paul Kehrere27f6582015-08-10 18:33:38 -05002641 Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.3"``. This is used
2642 to denote that a certificate may be used for code signing.
Paul Kehrere1513fa2015-03-30 23:08:17 -05002643
Paul Kehrere27f6582015-08-10 18:33:38 -05002644 .. attribute:: EMAIL_PROTECTION
Paul Kehrere1513fa2015-03-30 23:08:17 -05002645
Paul Kehrere27f6582015-08-10 18:33:38 -05002646 Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.4"``. This is used
2647 to denote that a certificate may be used for email protection.
Paul Kehrere1513fa2015-03-30 23:08:17 -05002648
Paul Kehrere27f6582015-08-10 18:33:38 -05002649 .. attribute:: TIME_STAMPING
Paul Kehrere1513fa2015-03-30 23:08:17 -05002650
Paul Kehrere27f6582015-08-10 18:33:38 -05002651 Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.8"``. This is used
2652 to denote that a certificate may be used for time stamping.
Paul Kehrere1513fa2015-03-30 23:08:17 -05002653
Paul Kehrere27f6582015-08-10 18:33:38 -05002654 .. attribute:: OCSP_SIGNING
Paul Kehrere1513fa2015-03-30 23:08:17 -05002655
Paul Kehrere27f6582015-08-10 18:33:38 -05002656 Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.9"``. This is used
2657 to denote that a certificate may be used for signing OCSP responses.
Paul Kehrere1513fa2015-03-30 23:08:17 -05002658
Alex Gaynorb7912ee2017-07-03 10:07:02 -04002659 .. attribute:: ANY_EXTENDED_KEY_USAGE
2660
2661 .. versionadded:: 2.0
2662
2663 Corresponds to the dotted string ``"2.5.29.37.0"``. This is used to
2664 denote that a certificate may be used for _any_ purposes.
2665
Paul Kehrere1513fa2015-03-30 23:08:17 -05002666
Paul Kehrere27f6582015-08-10 18:33:38 -05002667.. class:: AuthorityInformationAccessOID
Paul Kehrere1513fa2015-03-30 23:08:17 -05002668
Paul Kehrere27f6582015-08-10 18:33:38 -05002669 .. versionadded:: 1.0
Paul Kehrere1513fa2015-03-30 23:08:17 -05002670
Paul Kehrere27f6582015-08-10 18:33:38 -05002671 .. attribute:: OCSP
Paul Kehrere1513fa2015-03-30 23:08:17 -05002672
Paul Kehrere27f6582015-08-10 18:33:38 -05002673 Corresponds to the dotted string ``"1.3.6.1.5.5.7.48.1"``. Used as the
2674 identifier for OCSP data in
2675 :class:`~cryptography.x509.AccessDescription` objects.
Paul Kehrere1513fa2015-03-30 23:08:17 -05002676
Paul Kehrere27f6582015-08-10 18:33:38 -05002677 .. attribute:: CA_ISSUERS
Paul Kehrer3e6d5582015-05-02 21:57:56 -05002678
Paul Kehrere27f6582015-08-10 18:33:38 -05002679 Corresponds to the dotted string ``"1.3.6.1.5.5.7.48.2"``. Used as the
2680 identifier for CA issuer data in
2681 :class:`~cryptography.x509.AccessDescription` objects.
Paul Kehrer3e6d5582015-05-02 21:57:56 -05002682
Paul Kehrer3e6d5582015-05-02 21:57:56 -05002683
Paul Kehrere27f6582015-08-10 18:33:38 -05002684.. class:: CertificatePoliciesOID
Paul Kehrer3e6d5582015-05-02 21:57:56 -05002685
Paul Kehrere27f6582015-08-10 18:33:38 -05002686 .. versionadded:: 1.0
Paul Kehrer3e6d5582015-05-02 21:57:56 -05002687
Paul Kehrere27f6582015-08-10 18:33:38 -05002688 .. attribute:: CPS_QUALIFIER
Paul Kehrer2e879742015-05-02 23:09:56 -05002689
Paul Kehrere27f6582015-08-10 18:33:38 -05002690 Corresponds to the dotted string ``"1.3.6.1.5.5.7.2.1"``.
Paul Kehrer2e879742015-05-02 23:09:56 -05002691
Paul Kehrere27f6582015-08-10 18:33:38 -05002692 .. attribute:: CPS_USER_NOTICE
Paul Kehrer2e879742015-05-02 23:09:56 -05002693
Paul Kehrere27f6582015-08-10 18:33:38 -05002694 Corresponds to the dotted string ``"1.3.6.1.5.5.7.2.2"``.
Paul Kehrer2e879742015-05-02 23:09:56 -05002695
Paul Kehrere27f6582015-08-10 18:33:38 -05002696 .. attribute:: ANY_POLICY
Paul Kehrer2e879742015-05-02 23:09:56 -05002697
Paul Kehrere27f6582015-08-10 18:33:38 -05002698 Corresponds to the dotted string ``"2.5.29.32.0"``.
Paul Kehrer16fae762015-05-01 23:14:20 -05002699
Paul Kehrer16fae762015-05-01 23:14:20 -05002700
Paul Kehrere27f6582015-08-10 18:33:38 -05002701.. class:: ExtensionOID
Paul Kehrer5553d572015-03-23 21:08:01 -05002702
Paul Kehrere27f6582015-08-10 18:33:38 -05002703 .. versionadded:: 1.0
Paul Kehrer2bb94642015-03-21 09:54:17 -05002704
Paul Kehrere27f6582015-08-10 18:33:38 -05002705 .. attribute:: BASIC_CONSTRAINTS
Paul Kehrer2bb94642015-03-21 09:54:17 -05002706
Paul Kehrere27f6582015-08-10 18:33:38 -05002707 Corresponds to the dotted string ``"2.5.29.19"``. The identifier for the
2708 :class:`~cryptography.x509.BasicConstraints` extension type.
Paul Kehrer2bb94642015-03-21 09:54:17 -05002709
Paul Kehrere27f6582015-08-10 18:33:38 -05002710 .. attribute:: KEY_USAGE
Paul Kehrercecbbba2015-03-30 14:58:38 -05002711
Paul Kehrere27f6582015-08-10 18:33:38 -05002712 Corresponds to the dotted string ``"2.5.29.15"``. The identifier for the
2713 :class:`~cryptography.x509.KeyUsage` extension type.
Paul Kehrercecbbba2015-03-30 14:58:38 -05002714
Paul Kehrere27f6582015-08-10 18:33:38 -05002715 .. attribute:: SUBJECT_ALTERNATIVE_NAME
Paul Kehrerd4f632e2015-05-12 08:25:42 -05002716
Paul Kehrere27f6582015-08-10 18:33:38 -05002717 Corresponds to the dotted string ``"2.5.29.17"``. The identifier for the
2718 :class:`~cryptography.x509.SubjectAlternativeName` extension type.
Paul Kehrerd4f632e2015-05-12 08:25:42 -05002719
Paul Kehrere27f6582015-08-10 18:33:38 -05002720 .. attribute:: ISSUER_ALTERNATIVE_NAME
Paul Kehrer99125c92015-06-07 18:37:10 -05002721
Paul Kehrere27f6582015-08-10 18:33:38 -05002722 Corresponds to the dotted string ``"2.5.29.18"``. The identifier for the
2723 :class:`~cryptography.x509.IssuerAlternativeName` extension type.
Paul Kehrer99125c92015-06-07 18:37:10 -05002724
Paul Kehrere27f6582015-08-10 18:33:38 -05002725 .. attribute:: SUBJECT_KEY_IDENTIFIER
Paul Kehrerd4f632e2015-05-12 08:25:42 -05002726
Paul Kehrere27f6582015-08-10 18:33:38 -05002727 Corresponds to the dotted string ``"2.5.29.14"``. The identifier for the
2728 :class:`~cryptography.x509.SubjectKeyIdentifier` extension type.
Paul Kehrerd4f632e2015-05-12 08:25:42 -05002729
Paul Kehrere27f6582015-08-10 18:33:38 -05002730 .. attribute:: NAME_CONSTRAINTS
Paul Kehrere0017be2015-05-17 20:39:40 -06002731
Paul Kehrere27f6582015-08-10 18:33:38 -05002732 Corresponds to the dotted string ``"2.5.29.30"``. The identifier for the
2733 :class:`~cryptography.x509.NameConstraints` extension type.
Paul Kehrere0017be2015-05-17 20:39:40 -06002734
Paul Kehrere27f6582015-08-10 18:33:38 -05002735 .. attribute:: CRL_DISTRIBUTION_POINTS
Paul Kehrerd4f632e2015-05-12 08:25:42 -05002736
Paul Kehrere27f6582015-08-10 18:33:38 -05002737 Corresponds to the dotted string ``"2.5.29.31"``. The identifier for the
2738 :class:`~cryptography.x509.CRLDistributionPoints` extension type.
Paul Kehrerd4f632e2015-05-12 08:25:42 -05002739
Paul Kehrere27f6582015-08-10 18:33:38 -05002740 .. attribute:: CERTIFICATE_POLICIES
Paul Kehrerd4f632e2015-05-12 08:25:42 -05002741
Paul Kehrere27f6582015-08-10 18:33:38 -05002742 Corresponds to the dotted string ``"2.5.29.32"``. The identifier for the
2743 :class:`~cryptography.x509.CertificatePolicies` extension type.
Paul Kehrerd4f632e2015-05-12 08:25:42 -05002744
Paul Kehrere27f6582015-08-10 18:33:38 -05002745 .. attribute:: AUTHORITY_KEY_IDENTIFIER
Paul Kehrerd4f632e2015-05-12 08:25:42 -05002746
Paul Kehrere27f6582015-08-10 18:33:38 -05002747 Corresponds to the dotted string ``"2.5.29.35"``. The identifier for the
2748 :class:`~cryptography.x509.AuthorityKeyIdentifier` extension type.
Paul Kehrerd4f632e2015-05-12 08:25:42 -05002749
Paul Kehrere27f6582015-08-10 18:33:38 -05002750 .. attribute:: EXTENDED_KEY_USAGE
Paul Kehrerd4f632e2015-05-12 08:25:42 -05002751
Paul Kehrere27f6582015-08-10 18:33:38 -05002752 Corresponds to the dotted string ``"2.5.29.37"``. The identifier for the
2753 :class:`~cryptography.x509.ExtendedKeyUsage` extension type.
Paul Kehrerd4f632e2015-05-12 08:25:42 -05002754
Paul Kehrere27f6582015-08-10 18:33:38 -05002755 .. attribute:: AUTHORITY_INFORMATION_ACCESS
Paul Kehrerd4f632e2015-05-12 08:25:42 -05002756
Paul Kehrere27f6582015-08-10 18:33:38 -05002757 Corresponds to the dotted string ``"1.3.6.1.5.5.7.1.1"``. The identifier
2758 for the :class:`~cryptography.x509.AuthorityInformationAccess` extension
2759 type.
Paul Kehrer56da2a52015-02-11 23:35:07 -06002760
Paul Kehrere27f6582015-08-10 18:33:38 -05002761 .. attribute:: INHIBIT_ANY_POLICY
Paul Kehrerb33de932015-08-06 23:41:05 +01002762
Paul Kehrere27f6582015-08-10 18:33:38 -05002763 Corresponds to the dotted string ``"2.5.29.54"``. The identifier
2764 for the :class:`~cryptography.x509.InhibitAnyPolicy` extension type.
Paul Kehrerb33de932015-08-06 23:41:05 +01002765
Paul Kehrere27f6582015-08-10 18:33:38 -05002766 .. attribute:: OCSP_NO_CHECK
Paul Kehrer4a1038e2015-05-18 10:28:31 -07002767
Paul Kehrere27f6582015-08-10 18:33:38 -05002768 Corresponds to the dotted string ``"1.3.6.1.5.5.7.48.1.5"``. The
2769 identifier for the :class:`~cryptography.x509.OCSPNoCheck` extension
2770 type.
Paul Kehrer4a1038e2015-05-18 10:28:31 -07002771
Paul Kehrer5d669662017-09-11 09:16:34 +08002772 .. attribute:: TLS_FEATURE
2773
2774 Corresponds to the dotted string ``"1.3.6.1.5.5.7.1.24"``. The
2775 identifier for the :class:`~cryptography.x509.TLSFeature` extension
2776 type.
2777
Paul Kehrer51f39cb2015-12-21 21:17:39 -06002778 .. attribute:: CRL_NUMBER
2779
2780 Corresponds to the dotted string ``"2.5.29.20"``. The identifier for
2781 the ``CRLNumber`` extension type. This extension only has meaning
2782 for certificate revocation lists.
2783
Paul Kehrer5e3cc982017-09-22 21:29:36 +08002784 .. attribute:: DELTA_CRL_INDICATOR
2785
2786 .. versionadded:: 2.1
2787
2788 Corresponds to the dotted string ``"2.5.29.27"``. The identifier for
2789 the ``DeltaCRLIndicator`` extension type. This extension only has
2790 meaning for certificate revocation lists.
2791
Alex Gaynor9bab0ed2017-03-20 09:50:52 -04002792 .. attribute:: PRECERT_SIGNED_CERTIFICATE_TIMESTAMPS
2793
2794 .. versionadded:: 1.9
2795
2796 Corresponds to the dotted string ``"1.3.6.1.4.1.11129.2.4.2"``.
2797
Paul Kehrer7e8fe9d2015-05-18 09:53:47 -07002798 .. attribute:: POLICY_CONSTRAINTS
2799
2800 Corresponds to the dotted string ``"2.5.29.36"``. The identifier for the
Paul Kehrer20f0df52016-02-26 08:37:13 -06002801 :class:`~cryptography.x509.PolicyConstraints` extension type.
Paul Kehrer7e8fe9d2015-05-18 09:53:47 -07002802
Paul Kehrerb76bcf82017-09-24 08:44:12 +08002803 .. attribute:: FRESHEST_CRL
2804
2805 Corresponds to the dotted string ``"2.5.29.46"``. The identifier for the
2806 :class:`~cryptography.x509.FreshestCRL` extension type.
2807
Paul Kehrer7e8fe9d2015-05-18 09:53:47 -07002808
Paul Kehrerc6242dc2015-12-25 16:36:46 -06002809.. class:: CRLEntryExtensionOID
2810
2811 .. versionadded:: 1.2
2812
2813 .. attribute:: CERTIFICATE_ISSUER
2814
2815 Corresponds to the dotted string ``"2.5.29.29"``.
2816
2817 .. attribute:: CRL_REASON
2818
2819 Corresponds to the dotted string ``"2.5.29.21"``.
2820
2821 .. attribute:: INVALIDITY_DATE
2822
2823 Corresponds to the dotted string ``"2.5.29.24"``.
2824
Paul Kehrer8b89bcc2016-09-03 11:31:43 -05002825Helper Functions
2826~~~~~~~~~~~~~~~~
2827.. currentmodule:: cryptography.x509
2828
2829.. function:: random_serial_number()
2830
2831 .. versionadded:: 1.6
2832
2833 Generates a random serial number suitable for use when constructing
2834 certificates.
2835
Paul Kehrer912d3fb2015-01-29 11:19:22 -06002836Exceptions
2837~~~~~~~~~~
Paul Kehrere27f6582015-08-10 18:33:38 -05002838.. currentmodule:: cryptography.x509
Paul Kehrer912d3fb2015-01-29 11:19:22 -06002839
Paul Kehrere76cd272014-12-14 19:00:51 -06002840.. class:: InvalidVersion
Paul Kehrera68fd332014-11-27 07:08:40 -10002841
2842 This is raised when an X.509 certificate has an invalid version number.
Paul Kehrer016e08a2014-11-26 09:41:18 -10002843
Paul Kehrerd5cccf72014-12-15 17:20:33 -06002844 .. attribute:: parsed_version
2845
Paul Kehrerbbffc402014-12-17 13:33:55 -06002846 :type: int
2847
2848 Returns the raw version that was parsed from the certificate.
Paul Kehrerd5cccf72014-12-15 17:20:33 -06002849
Paul Kehrerfbb7ac82015-03-16 19:26:29 -05002850.. class:: DuplicateExtension
2851
2852 This is raised when more than one X.509 extension of the same type is
2853 found within a certificate.
2854
2855 .. attribute:: oid
2856
2857 :type: :class:`ObjectIdentifier`
2858
2859 Returns the OID.
2860
Paul Kehrerfa56a232015-03-17 13:14:03 -05002861.. class:: ExtensionNotFound
2862
2863 This is raised when calling :meth:`Extensions.get_extension_for_oid` with
2864 an extension OID that is not present in the certificate.
2865
2866 .. attribute:: oid
2867
2868 :type: :class:`ObjectIdentifier`
2869
2870 Returns the OID.
2871
Paul Kehrer9089c912015-04-20 22:15:20 -05002872.. class:: UnsupportedGeneralNameType
2873
2874 This is raised when a certificate contains an unsupported general name
2875 type in an extension.
2876
Paul Kehrerbed07352015-04-21 08:31:10 -05002877 .. attribute:: type
2878
Paul Kehrer0a621bf2015-04-22 09:22:56 -05002879 :type: int
2880
2881 The integer value of the unsupported type. The complete list of
2882 types can be found in `RFC 5280 section 4.2.1.6`_.
Paul Kehrerbed07352015-04-21 08:31:10 -05002883
Paul Kehrer016e08a2014-11-26 09:41:18 -10002884
Paul Kehrerc7c9a432015-04-19 09:20:13 -05002885.. _`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 -05002886.. _`RFC 5280 section 4.2.1.6`: https://tools.ietf.org/html/rfc5280#section-4.2.1.6
Paul Kehrer8b89bcc2016-09-03 11:31:43 -05002887.. _`CABForum Guidelines`: https://cabforum.org/baseline-requirements-documents/