blob: a05be1642c79a01e3546630f04124a85542ad8ce [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
8 pem_req_data = b"""
9 -----BEGIN CERTIFICATE REQUEST-----
10 MIIC0zCCAbsCAQAwWTELMAkGA1UEBhMCVVMxETAPBgNVBAgMCElsbGlub2lzMRAw
11 DgYDVQQHDAdDaGljYWdvMREwDwYDVQQKDAhyNTA5IExMQzESMBAGA1UEAwwJaGVs
12 bG8uY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqhZx+Mo9VRd9
13 vsnWWa6NBCws21rZ0+1B/JGgB4hDsZS7iDE4Bj5z4idheFRtl8bBbdjPknq7BfoF
14 8v15Zq/Zv7i2xMSDL+LUrTBZezRd4bRTGqCm6YJ5EYkhqdcqeZleHCFImguHoq1J
15 Fh0+kObQrTHXw3ZP57a3o1IvyIUA3nNoCBL0QQhwBXaDXOojMKNR+bqB5ve8GS1y
16 Elr0AM/+cJsfaIahNQUgFKx3Eu3GeEOMKYOAG1lycgdQdmTUybLrT3U7vkClTseM
17 xHg1r5En7ALjONIhqRuq3rddYahrP8HXozb3zUy3cJ7P6IeaosuvNzvMXOX9P6HD
18 Ha9urDAJ1wIDAQABoDUwMwYJKoZIhvcNAQkOMSYwJDAiBgNVHREEGzAZggl3b3Js
19 ZC5jb22CDHdoYXRldmVyLmNvbTANBgkqhkiG9w0BAQUFAAOCAQEAS4Ro6h+z52SK
20 YSLCYARpnEu/rmh4jdqndt8naqcNb6uLx9mlKZ2W9on9XDjnSdQD9q+ZP5aZfESw
21 R0+rJhW9ZrNa/g1pt6M24ihclHYDAxYMWxT1z/TXXGM3TmZZ6gfYlNE1kkBuODHa
22 UYsR/1Ht1E1EsmmUimt2n+zQR2K8T9Coa+boaUW/GsTEuz1aaJAkj5ZvTDiIhRG4
23 AOCqFZOLAQmCCNgJnnspD9hDz/Ons085LF5wnYjN4/Nsk5tS6AGs3xjZ3jPoOGGn
24 82WQ9m4dBGoVDZXsobVTaN592JEYwN5iu72zRn7Einb4V4H5y3yD2dD4yWPlt4pk
25 5wFkeYsZEA==
26 -----END CERTIFICATE REQUEST-----
27 """.strip()
28
Paul Kehrerd3dafbd2015-03-15 16:24:18 -050029 pem_data = b"""
30 -----BEGIN CERTIFICATE-----
31 MIIDfDCCAmSgAwIBAgIBAjANBgkqhkiG9w0BAQsFADBFMQswCQYDVQQGEwJVUzEf
32 MB0GA1UEChMWVGVzdCBDZXJ0aWZpY2F0ZXMgMjAxMTEVMBMGA1UEAxMMVHJ1c3Qg
33 QW5jaG9yMB4XDTEwMDEwMTA4MzAwMFoXDTMwMTIzMTA4MzAwMFowQDELMAkGA1UE
34 BhMCVVMxHzAdBgNVBAoTFlRlc3QgQ2VydGlmaWNhdGVzIDIwMTExEDAOBgNVBAMT
35 B0dvb2QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCQWJpHYo37
36 Xfb7oJSPe+WvfTlzIG21WQ7MyMbGtK/m8mejCzR6c+f/pJhEH/OcDSMsXq8h5kXa
37 BGqWK+vSwD/Pzp5OYGptXmGPcthDtAwlrafkGOS4GqIJ8+k9XGKs+vQUXJKsOk47
38 RuzD6PZupq4s16xaLVqYbUC26UcY08GpnoLNHJZS/EmXw1ZZ3d4YZjNlpIpWFNHn
39 UGmdiGKXUPX/9H0fVjIAaQwjnGAbpgyCumWgzIwPpX+ElFOUr3z7BoVnFKhIXze+
40 VmQGSWxZxvWDUN90Ul0tLEpLgk3OVxUB4VUGuf15OJOpgo1xibINPmWt14Vda2N9
41 yrNKloJGZNqLAgMBAAGjfDB6MB8GA1UdIwQYMBaAFOR9X9FclYYILAWuvnW2ZafZ
42 XahmMB0GA1UdDgQWBBRYAYQkG7wrUpRKPaUQchRR9a86yTAOBgNVHQ8BAf8EBAMC
43 AQYwFwYDVR0gBBAwDjAMBgpghkgBZQMCATABMA8GA1UdEwEB/wQFMAMBAf8wDQYJ
44 KoZIhvcNAQELBQADggEBADWHlxbmdTXNwBL/llwhQqwnazK7CC2WsXBBqgNPWj7m
45 tvQ+aLG8/50Qc2Sun7o2VnwF9D18UUe8Gj3uPUYH+oSI1vDdyKcjmMbKRU4rk0eo
46 3UHNDXwqIVc9CQS9smyV+x1HCwL4TTrq+LXLKx/qVij0Yqk+UJfAtrg2jnYKXsCu
47 FMBQQnWCGrwa1g1TphRp/RmYHnMynYFmZrXtzFz+U9XEA7C+gPq4kqDI/iVfIT1s
48 6lBtdB50lrDVwl2oYfAvW/6sC2se2QleZidUmrziVNP4oEeXINokU6T6p//HM1FG
49 QYw2jOvpKcKtWCSAnegEbgsGYzATKjmPJPJ0npHFqzM=
50 -----END CERTIFICATE-----
51 """.strip()
52
Paul Kehrer93ae8052015-05-02 23:18:09 -050053 cryptography_cert_pem = b"""
54 -----BEGIN CERTIFICATE-----
55 MIIFvTCCBKWgAwIBAgICPyAwDQYJKoZIhvcNAQELBQAwRzELMAkGA1UEBhMCVVMx
56 FjAUBgNVBAoTDUdlb1RydXN0IEluYy4xIDAeBgNVBAMTF1JhcGlkU1NMIFNIQTI1
57 NiBDQSAtIEczMB4XDTE0MTAxNTEyMDkzMloXDTE4MTExNjAxMTUwM1owgZcxEzAR
58 BgNVBAsTCkdUNDg3NDI5NjUxMTAvBgNVBAsTKFNlZSB3d3cucmFwaWRzc2wuY29t
59 L3Jlc291cmNlcy9jcHMgKGMpMTQxLzAtBgNVBAsTJkRvbWFpbiBDb250cm9sIFZh
60 bGlkYXRlZCAtIFJhcGlkU1NMKFIpMRwwGgYDVQQDExN3d3cuY3J5cHRvZ3JhcGh5
61 LmlvMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAom/FebKJIot7Sp3s
62 itG1sicpe3thCssjI+g1JDAS7I3GLVNmbms1DOdIIqwf01gZkzzXBN2+9sOnyRaR
63 PPfCe1jTr3dk2y6rPE559vPa1nZQkhlzlhMhlPyjaT+S7g4Tio4qV2sCBZU01DZJ
64 CaksfohN+5BNVWoJzTbOcrHOEJ+M8B484KlBCiSxqf9cyNQKru4W3bHaCVNVJ8eu
65 6i6KyhzLa0L7yK3LXwwXVs583C0/vwFhccGWsFODqD/9xHUzsBIshE8HKjdjDi7Y
66 3BFQzVUQFjBB50NSZfAA/jcdt1blxJouc7z9T8Oklh+V5DDBowgAsrT4b6Z2Fq6/
67 r7D1GqivLK/ypUQmxq2WXWAUBb/Q6xHgxASxI4Br+CByIUQJsm8L2jzc7k+mF4hW
68 ltAIUkbo8fGiVnat0505YJgxWEDKOLc4Gda6d/7GVd5AvKrz242bUqeaWo6e4MTx
69 diku2Ma3rhdcr044Qvfh9hGyjqNjvhWY/I+VRWgihU7JrYvgwFdJqsQ5eiKT4OHi
70 gsejvWwkZzDtiQ+aQTrzM1FsY2swJBJsLSX4ofohlVRlIJCn/ME+XErj553431Lu
71 YQ5SzMd3nXzN78Vj6qzTfMUUY72UoT1/AcFiUMobgIqrrmwuNxfrkbVE2b6Bga74
72 FsJX63prvrJ41kuHK/16RQBM7fcCAwEAAaOCAWAwggFcMB8GA1UdIwQYMBaAFMOc
73 8/zTRgg0u85Gf6B8W/PiCMtZMFcGCCsGAQUFBwEBBEswSTAfBggrBgEFBQcwAYYT
74 aHR0cDovL2d2LnN5bWNkLmNvbTAmBggrBgEFBQcwAoYaaHR0cDovL2d2LnN5bWNi
75 LmNvbS9ndi5jcnQwDgYDVR0PAQH/BAQDAgWgMB0GA1UdJQQWMBQGCCsGAQUFBwMB
76 BggrBgEFBQcDAjAvBgNVHREEKDAmghN3d3cuY3J5cHRvZ3JhcGh5Lmlvgg9jcnlw
77 dG9ncmFwaHkuaW8wKwYDVR0fBCQwIjAgoB6gHIYaaHR0cDovL2d2LnN5bWNiLmNv
78 bS9ndi5jcmwwDAYDVR0TAQH/BAIwADBFBgNVHSAEPjA8MDoGCmCGSAGG+EUBBzYw
79 LDAqBggrBgEFBQcCARYeaHR0cHM6Ly93d3cucmFwaWRzc2wuY29tL2xlZ2FsMA0G
80 CSqGSIb3DQEBCwUAA4IBAQAzIYO2jx7h17FBT74tJ2zbV9OKqGb7QF8y3wUtP4xc
81 dH80vprI/Cfji8s86kr77aAvAqjDjaVjHn7UzebhSUivvRPmfzRgyWBacomnXTSt
82 Xlt2dp2nDQuwGyK2vB7dMfKnQAkxwq1sYUXznB8i0IhhCAoXp01QGPKq51YoIlnF
83 7DRMk6iEaL1SJbkIrLsCQyZFDf0xtfW9DqXugMMLoxeCsBhZJQzNyS2ryirrv9LH
84 aK3+6IZjrcyy9bkpz/gzJucyhU+75c4My/mnRCrtItRbCQuiI5pd5poDowm+HH9i
85 GVI9+0lAFwxOUnOnwsoI40iOoxjLMGB+CgFLKCGUcWxP
86 -----END CERTIFICATE-----
87 """.strip()
88
Paul Kehrerb2de9482014-12-11 14:54:48 -060089Loading Certificates
90~~~~~~~~~~~~~~~~~~~~
Paul Kehrer016e08a2014-11-26 09:41:18 -100091
92.. function:: load_pem_x509_certificate(data, backend)
93
94 .. versionadded:: 0.7
95
Paul Kehrere76cd272014-12-14 19:00:51 -060096 Deserialize a certificate from PEM encoded data. PEM certificates are
97 base64 decoded and have delimiters that look like
98 ``-----BEGIN CERTIFICATE-----``.
Paul Kehrer016e08a2014-11-26 09:41:18 -100099
100 :param bytes data: The PEM encoded certificate data.
101
102 :param backend: A backend supporting the
103 :class:`~cryptography.hazmat.backends.interfaces.X509Backend`
104 interface.
105
Paul Kehrere76cd272014-12-14 19:00:51 -0600106 :returns: An instance of :class:`~cryptography.x509.Certificate`.
Paul Kehrer016e08a2014-11-26 09:41:18 -1000107
108.. function:: load_der_x509_certificate(data, backend)
109
110 .. versionadded:: 0.7
111
Paul Kehrere76cd272014-12-14 19:00:51 -0600112 Deserialize a certificate from DER encoded data. DER is a binary format
Paul Kehrer92aac382014-12-15 16:25:28 -0600113 and is commonly found in files with the ``.cer`` extension (although file
114 extensions are not a guarantee of encoding type).
Paul Kehrer016e08a2014-11-26 09:41:18 -1000115
116 :param bytes data: The DER encoded certificate data.
117
118 :param backend: A backend supporting the
119 :class:`~cryptography.hazmat.backends.interfaces.X509Backend`
120 interface.
121
Paul Kehrere76cd272014-12-14 19:00:51 -0600122 :returns: An instance of :class:`~cryptography.x509.Certificate`.
Paul Kehrer016e08a2014-11-26 09:41:18 -1000123
Paul Kehrer016e08a2014-11-26 09:41:18 -1000124.. doctest::
125
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600126 >>> from cryptography import x509
Paul Kehrer016e08a2014-11-26 09:41:18 -1000127 >>> from cryptography.hazmat.backends import default_backend
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600128 >>> cert = x509.load_pem_x509_certificate(pem_data, default_backend())
Paul Kehrer016e08a2014-11-26 09:41:18 -1000129 >>> cert.serial
130 2
131
Paul Kehrera1a1f232015-03-15 15:34:35 -0500132Loading Certificate Signing Requests
133~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600134
Paul Kehrer31e39882015-03-11 11:37:04 -0500135.. function:: load_pem_x509_csr(data, backend)
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600136
137 .. versionadded:: 0.9
138
Paul Kehrera1a1f232015-03-15 15:34:35 -0500139 Deserialize a certificate signing request (CSR) from PEM encoded data. PEM
Paul Kehrer5aadb9c2015-03-11 20:48:42 -0500140 requests are base64 decoded and have delimiters that look like
Paul Kehrerd3dafbd2015-03-15 16:24:18 -0500141 ``-----BEGIN CERTIFICATE REQUEST-----``. This format is also known as
142 PKCS#10.
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600143
144 :param bytes data: The PEM encoded request data.
145
146 :param backend: A backend supporting the
147 :class:`~cryptography.hazmat.backends.interfaces.X509Backend`
148 interface.
149
Paul Kehrera1a1f232015-03-15 15:34:35 -0500150 :returns: An instance of
151 :class:`~cryptography.x509.CertificateSigningRequest`.
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600152
Paul Kehrer1effb6e2015-03-30 15:05:59 -0500153.. function:: load_der_x509_csr(data, backend)
154
155 .. versionadded:: 0.9
156
157 Deserialize a certificate signing request (CSR) from DER encoded data. DER
158 is a binary format and is not commonly used with CSRs.
159
160 :param bytes data: The DER encoded request data.
161
162 :param backend: A backend supporting the
163 :class:`~cryptography.hazmat.backends.interfaces.X509Backend`
164 interface.
165
166 :returns: An instance of
167 :class:`~cryptography.x509.CertificateSigningRequest`.
168
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600169.. doctest::
170
171 >>> from cryptography import x509
172 >>> from cryptography.hazmat.backends import default_backend
173 >>> from cryptography.hazmat.primitives import hashes
Paul Kehrera1a1f232015-03-15 15:34:35 -0500174 >>> csr = x509.load_pem_x509_csr(pem_req_data, default_backend())
175 >>> isinstance(csr.signature_hash_algorithm, hashes.SHA1)
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600176 True
177
Paul Kehrere76cd272014-12-14 19:00:51 -0600178X.509 Certificate Object
179~~~~~~~~~~~~~~~~~~~~~~~~
Paul Kehrerb2de9482014-12-11 14:54:48 -0600180
Paul Kehrere76cd272014-12-14 19:00:51 -0600181.. class:: Certificate
Paul Kehrerb2de9482014-12-11 14:54:48 -0600182
183 .. versionadded:: 0.7
184
185 .. attribute:: version
186
Paul Kehrere76cd272014-12-14 19:00:51 -0600187 :type: :class:`~cryptography.x509.Version`
Paul Kehrerb2de9482014-12-11 14:54:48 -0600188
Paul Kehrere76cd272014-12-14 19:00:51 -0600189 The certificate version as an enumeration. Version 3 certificates are
190 the latest version and also the only type you should see in practice.
Paul Kehrerb2de9482014-12-11 14:54:48 -0600191
Alex Gaynor89c4dc82014-12-16 16:49:33 -0800192 :raises cryptography.x509.InvalidVersion: If the version in the
Alex Gaynor6d7ab4c2014-12-16 16:50:33 -0800193 certificate is not a known
194 :class:`X.509 version <cryptography.x509.Version>`.
Paul Kehrer92aac382014-12-15 16:25:28 -0600195
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600196 .. doctest::
197
198 >>> cert.version
199 <Version.v3: 2>
200
Paul Kehrerb2de9482014-12-11 14:54:48 -0600201 .. method:: fingerprint(algorithm)
202
203 :param algorithm: The
Paul Kehrer601278a2015-02-12 12:51:00 -0600204 :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm`
Paul Kehrerb2de9482014-12-11 14:54:48 -0600205 that will be used to generate the fingerprint.
206
Erik Trauschke2dcce902015-05-14 16:12:24 -0700207 :return bytes: The fingerprint using the supplied hash algorithm, as
Paul Kehrerb2de9482014-12-11 14:54:48 -0600208 bytes.
209
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600210 .. doctest::
211
212 >>> from cryptography.hazmat.primitives import hashes
213 >>> cert.fingerprint(hashes.SHA256())
Paul Kehrer78a81502014-12-16 14:47:52 -0600214 '\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 -0600215
Paul Kehrerb2de9482014-12-11 14:54:48 -0600216 .. attribute:: serial
217
218 :type: int
219
220 The serial as a Python integer.
221
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600222 .. doctest::
223
224 >>> cert.serial
225 2
226
Paul Kehrerb2de9482014-12-11 14:54:48 -0600227 .. method:: public_key()
228
229 :type:
Alex Stapletonf79c2312014-12-30 12:50:14 +0000230 :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey` or
Paul Kehrer45efdbc2015-02-12 10:58:22 -0600231 :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPublicKey` or
232 :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey`
Paul Kehrerb2de9482014-12-11 14:54:48 -0600233
234 The public key associated with the certificate.
235
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600236 .. doctest::
237
Alex Stapletonf79c2312014-12-30 12:50:14 +0000238 >>> from cryptography.hazmat.primitives.asymmetric import rsa
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600239 >>> public_key = cert.public_key()
Alex Stapletonf79c2312014-12-30 12:50:14 +0000240 >>> isinstance(public_key, rsa.RSAPublicKey)
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600241 True
242
Paul Kehrerb2de9482014-12-11 14:54:48 -0600243 .. attribute:: not_valid_before
244
245 :type: :class:`datetime.datetime`
246
Paul Kehrer78a81502014-12-16 14:47:52 -0600247 A naïve datetime representing the beginning of the validity period for
248 the certificate in UTC. This value is inclusive.
Paul Kehrerb2de9482014-12-11 14:54:48 -0600249
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600250 .. doctest::
251
252 >>> cert.not_valid_before
253 datetime.datetime(2010, 1, 1, 8, 30)
254
Paul Kehrerb2de9482014-12-11 14:54:48 -0600255 .. attribute:: not_valid_after
256
257 :type: :class:`datetime.datetime`
258
Paul Kehrer78a81502014-12-16 14:47:52 -0600259 A naïve datetime representing the end of the validity period for the
260 certificate in UTC. This value is inclusive.
Paul Kehrerb2de9482014-12-11 14:54:48 -0600261
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600262 .. doctest::
263
264 >>> cert.not_valid_after
265 datetime.datetime(2030, 12, 31, 8, 30)
266
Paul Kehrer719d5362015-01-01 20:03:52 -0600267 .. attribute:: issuer
268
269 .. versionadded:: 0.8
270
271 :type: :class:`Name`
272
273 The :class:`Name` of the issuer.
274
275 .. attribute:: subject
276
277 .. versionadded:: 0.8
278
279 :type: :class:`Name`
280
281 The :class:`Name` of the subject.
282
Paul Kehrer8802a5b2015-02-13 12:06:57 -0600283 .. attribute:: signature_hash_algorithm
Paul Kehrer56da2a52015-02-11 23:35:07 -0600284
Paul Kehrer8802a5b2015-02-13 12:06:57 -0600285 :type: :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm`
Paul Kehrer56da2a52015-02-11 23:35:07 -0600286
Paul Kehrere612ec72015-02-16 14:33:35 -0600287 Returns the
Paul Kehrer71d40c62015-02-19 08:21:04 -0600288 :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` which
Paul Kehrer1a7ba872015-02-19 18:09:05 -0600289 was used in signing this certificate.
Paul Kehrer56da2a52015-02-11 23:35:07 -0600290
291 .. doctest::
292
Paul Kehrer8802a5b2015-02-13 12:06:57 -0600293 >>> from cryptography.hazmat.primitives import hashes
294 >>> isinstance(cert.signature_hash_algorithm, hashes.SHA256)
295 True
Paul Kehrer719d5362015-01-01 20:03:52 -0600296
Paul Kehrerfbb7ac82015-03-16 19:26:29 -0500297 .. attribute:: extensions
298
299 :type: :class:`Extensions`
300
301 The extensions encoded in the certificate.
302
303 :raises cryptography.x509.DuplicateExtension: If more than one
304 extension of the same type is found within the certificate.
305
Paul Kehrerd8fc0be2015-04-21 08:31:10 -0500306 :raises cryptography.x509.UnsupportedExtension: If the certificate
307 contains an extension that is not supported.
308
Paul Kehrerbed07352015-04-21 08:31:10 -0500309 :raises cryptography.x509.UnsupportedGeneralNameType: If an extension
310 contains a general name that is not supported.
311
Paul Kehrerb8968812015-05-15 09:01:34 -0700312 :raises UnicodeError: If an extension contains IDNA encoding that is
313 invalid or not compliant with IDNA 2008.
314
Paul Kehrerfa56a232015-03-17 13:14:03 -0500315 .. doctest::
316
317 >>> for ext in cert.extensions:
318 ... print(ext)
Paul Kehrerd774de92015-05-03 10:52:25 -0500319 <Extension(oid=<ObjectIdentifier(oid=2.5.29.35, name=authorityKeyIdentifier)>, critical=False, value=<AuthorityKeyIdentifier(key_identifier='\xe4}_\xd1\\\x95\x86\x08,\x05\xae\xbeu\xb6e\xa7\xd9]\xa8f', authority_cert_issuer=None, authority_cert_serial_number=None)>)>
Paul Kehrercbfb1012015-04-10 20:57:20 -0400320 <Extension(oid=<ObjectIdentifier(oid=2.5.29.14, name=subjectKeyIdentifier)>, critical=False, value=<SubjectKeyIdentifier(digest='X\x01\x84$\x1b\xbc+R\x94J=\xa5\x10r\x14Q\xf5\xaf:\xc9')>)>
Paul Kehrerb511ba82015-04-15 11:22:48 -0400321 <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 -0500322 <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 -0500323 <Extension(oid=<ObjectIdentifier(oid=2.5.29.19, name=basicConstraints)>, critical=True, value=<BasicConstraints(ca=True, path_length=None)>)>
324
Andre Carona8aded62015-05-19 20:11:57 -0400325 .. method:: public_bytes(encoding)
326
Alex Gaynord0b376b2015-07-05 13:58:12 -0400327 .. versionadded:: 1.0
328
Andre Carona8aded62015-05-19 20:11:57 -0400329 :param encoding: The
330 :class:`~cryptography.hazmat.primitives.serialization.Encoding`
331 that will be used to serialize the certificate.
332
333 :return bytes: The data that can be written to a file or sent
334 over the network to be verified by clients.
335
Erik Trauschke2dcce902015-05-14 16:12:24 -0700336X.509 CRL (Certificate Revocation List) Object
337~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
338
339.. class:: CertificateRevocationList
340
341 .. versionadded:: 1.0
342
343 .. method:: fingerprint(algorithm)
344
345 :param algorithm: The
346 :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm`
347 that will be used to generate the fingerprint.
348
349 :return bytes: The fingerprint using the supplied hash algorithm, as
350 bytes.
351
352 .. attribute:: signature_hash_algorithm
353
354 :type: :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm`
355
356 Returns the
357 :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` which
358 was used in signing this CRL.
359
360 .. attribute:: issuer
361
362 :type: :class:`Name`
363
364 The :class:`Name` of the issuer.
365
366 .. attribute:: next_update
367
368 :type: :class:`datetime.datetime`
369
370 A naïve datetime representing when the next update to this CRL is
371 expected.
372
373 .. attribute:: last_update
374
375 :type: :class:`datetime.datetime`
376
377 A naïve datetime representing when the this CRL was last updated.
378
Erik Trauschkeabb7b6e2015-05-27 15:07:35 -0700379 .. attribute:: revoked_certificates
Erik Trauschke2dcce902015-05-14 16:12:24 -0700380
381 :type: list of :class:`RevokedCertificate`
382
383 The revoked certificates listed in this CRL.
384
385 .. attribute:: extensions
386
387 :type: :class:`Extensions`
388
389 The extensions encoded in the CRL.
390
Andre Caron9bbfcea2015-05-18 20:55:29 -0400391X.509 Certificate Builder
392~~~~~~~~~~~~~~~~~~~~~~~~~
393
394.. class:: CertificateBuilder
395
Ian Cordasco1517a4b2015-08-02 22:11:19 -0500396 .. versionadded:: 1.0
397
398 .. doctest::
399
400 >>> from cryptography import x509
401 >>> from cryptography.hazmat.backends import default_backend
402 >>> from cryptography.hazmat.primitives import hashes
403 >>> from cryptography.hazmat.primitives.asymmetric import rsa
404 >>> import datetime
405 >>> import uuid
406 >>> one_day = datetime.timedelta(1, 0, 0)
407 >>> private_key = rsa.generate_private_key(
408 ... public_exponent=65537,
409 ... key_size=2048,
410 ... backend=default_backend()
411 ... )
412 >>> public_key = rsa.generate_private_key(
413 ... public_exponent=65537,
414 ... key_size=2048,
415 ... backend=default_backend()
416 ... ).public_key()
417 >>> builder = x509.CertificateBuilder()
418 >>> builder = builder.subject_name(x509.Name([
419 ... x509.NameAttribute(x509.OID_COMMON_NAME, u'cryptography.io'),
420 ... ]))
421 >>> builder = builder.issuer_name(x509.Name([
422 ... x509.NameAttribute(x509.OID_COMMON_NAME, u'cryptography.io'),
423 ... ]))
424 >>> builder = builder.not_valid_before(datetime.datetime.today() - one_day)
425 >>> builder = builder.not_valid_after(datetime.datetime(2018, 8, 2))
426 >>> builder = builder.serial_number(int(uuid.uuid4()))
427 >>> builder = builder.public_key(public_key)
428 >>> builder = builder.add_extension(
429 ... x509.BasicConstraints(ca=False, path_length=None), critical=True,
430 ... )
431 >>> certificate = builder.sign(
432 ... private_key=private_key, algorithm=hashes.SHA256(),
433 ... backend=default_backend()
434 ... )
435 >>> isinstance(certificate, x509.Certificate)
436 True
437
Ian Cordasco0092a0b2015-07-18 21:46:41 -0500438 .. method:: issuer_name(name)
Andre Caron9bbfcea2015-05-18 20:55:29 -0400439
440 Sets the issuer's distinguished name.
441
Ian Cordascoc9682ad2015-08-01 12:11:13 -0500442 :param name: The :class:`~cryptography.x509.Name` that describes the
443 issuer (CA).
Andre Caron9bbfcea2015-05-18 20:55:29 -0400444
Ian Cordasco0092a0b2015-07-18 21:46:41 -0500445 .. method:: subject_name(name)
Andre Caron9bbfcea2015-05-18 20:55:29 -0400446
447 Sets the subject's distinguished name.
448
Ian Cordascoc9682ad2015-08-01 12:11:13 -0500449 :param name: The :class:`~cryptography.x509.Name` that describes the
Ian Cordasco85fc4d52015-08-01 20:29:31 -0500450 subject.
Andre Caron9bbfcea2015-05-18 20:55:29 -0400451
Ian Cordasco0092a0b2015-07-18 21:46:41 -0500452 .. method:: public_key(public_key)
Andre Caron9bbfcea2015-05-18 20:55:29 -0400453
454 Sets the subject's public key.
455
Ian Cordasco8f571422015-08-02 11:31:08 -0500456 :param public_key: The subject's public key. This can be one of
457 :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey`,
458 :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPublicKey` or
459 :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey`
Andre Caron9bbfcea2015-05-18 20:55:29 -0400460
Ian Cordasco0092a0b2015-07-18 21:46:41 -0500461 .. method:: serial_number(serial_number)
Andre Caron9bbfcea2015-05-18 20:55:29 -0400462
463 Sets the certificate's serial number (an integer). The CA's policy
464 determines how it attributes serial numbers to certificates. The only
465 requirement is that this number uniquely identify the certificate given
466 the issuer.
467
468 :param serial_number: Integer number that will be used by the CA to
469 identify this certificate (most notably during certificate
Ian Cordasco17c89002015-08-02 21:13:59 -0500470 revocation checking). Users are encouraged to use a method of
471 generating 20 bytes of entropy, e.g., UUID4. For more information
Ian Cordascob7530a42015-08-02 22:47:06 -0500472 on secure random number generation, see :doc:`/random-numbers`.
Andre Caron9bbfcea2015-05-18 20:55:29 -0400473
Ian Cordasco0092a0b2015-07-18 21:46:41 -0500474 .. method:: not_valid_before(time)
Andre Caron9bbfcea2015-05-18 20:55:29 -0400475
476 Sets the certificate's activation time. This is the time from which
477 clients can start trusting the certificate. It may be different from
478 the time at which the certificate was created.
479
Ian Cordasco17c89002015-08-02 21:13:59 -0500480 :param time: The :class:`datetime.datetime` object (in UTC) that marks the
Andre Caron9bbfcea2015-05-18 20:55:29 -0400481 activation time for the certificate. The certificate may not be
482 trusted clients if it is used before this time.
483
Ian Cordasco0092a0b2015-07-18 21:46:41 -0500484 .. method:: not_valid_after(time)
Andre Caron9bbfcea2015-05-18 20:55:29 -0400485
486 Sets the certificate's expiration time. This is the time from which
487 clients should no longer trust the certificate. The CA's policy will
488 determine how long the certificate should remain in use.
489
Ian Cordasco17c89002015-08-02 21:13:59 -0500490 :param time: The :class:`datetime.datetime` object (in UTC) that marks the
Andre Caron9bbfcea2015-05-18 20:55:29 -0400491 expiration time for the certificate. The certificate may not be
492 trusted clients if it is used after this time.
493
Ian Cordasco17c89002015-08-02 21:13:59 -0500494 .. method:: add_extension(extension, critical)
Andre Caron9bbfcea2015-05-18 20:55:29 -0400495
496 Adds an X.509 extension to the certificate.
497
Ian Cordasco8f571422015-08-02 11:31:08 -0500498 :param extension: The extension to add to the certificate. Can be one
499 of :class:`~cryptography.x509.BasicConstraints` or
500 :class:`~cryptography.x509.SubjectAlternativeName`.
Andre Caron9bbfcea2015-05-18 20:55:29 -0400501
Ian Cordasco17c89002015-08-02 21:13:59 -0500502 :param critical: Set to ``True`` if the extension must be understood and
503 handled by whoever reads the certificate.
504
Paul Kehrer9add80e2015-08-03 17:53:14 +0100505 .. method:: sign(private_key, algorithm, backend)
Andre Caron9bbfcea2015-05-18 20:55:29 -0400506
507 Sign the certificate using the CA's private key.
508
Ian Cordascoc5e1c252015-07-31 23:33:35 -0500509 :param private_key: The
510 :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey`,
511 :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPrivateKey` or
512 :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateKey`
513 that will be used to sign the certificate.
514
Andre Caron9bbfcea2015-05-18 20:55:29 -0400515 :param algorithm: The
516 :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` that
517 will be used to generate the signature.
518
Paul Kehrer9add80e2015-08-03 17:53:14 +0100519 :param backend: Backend that will be used to build the certificate.
520 Must support the
521 :class:`~cryptography.hazmat.backends.interfaces.X509Backend`
522 interface.
523
Andre Caron9bbfcea2015-05-18 20:55:29 -0400524
Paul Kehrer5aadb9c2015-03-11 20:48:42 -0500525X.509 CSR (Certificate Signing Request) Object
526~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600527
Paul Kehrera1a1f232015-03-15 15:34:35 -0500528.. class:: CertificateSigningRequest
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600529
530 .. versionadded:: 0.9
531
532 .. method:: public_key()
533
534 :type:
535 :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey` or
536 :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPublicKey` or
537 :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey`
538
539 The public key associated with the request.
540
541 .. doctest::
542
543 >>> from cryptography.hazmat.primitives.asymmetric import rsa
Paul Kehrera1a1f232015-03-15 15:34:35 -0500544 >>> public_key = csr.public_key()
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600545 >>> isinstance(public_key, rsa.RSAPublicKey)
546 True
547
548 .. attribute:: subject
549
550 :type: :class:`Name`
551
552 The :class:`Name` of the subject.
553
554 .. attribute:: signature_hash_algorithm
555
556 :type: :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm`
557
558 Returns the
559 :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` which
560 was used in signing this request.
561
562 .. doctest::
563
564 >>> from cryptography.hazmat.primitives import hashes
Paul Kehrera1a1f232015-03-15 15:34:35 -0500565 >>> isinstance(csr.signature_hash_algorithm, hashes.SHA1)
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600566 True
567
Paul Kehrerc4e61942015-08-01 21:21:13 +0100568 .. attribute:: extensions
569
570 :type: :class:`Extensions`
571
572 The extensions encoded in the certificate signing request.
573
574 :raises cryptography.x509.DuplicateExtension: If more than one
Paul Kehrer24283d22015-08-01 21:31:19 +0100575 extension of the same type is found within the certificate signing request.
Paul Kehrerc4e61942015-08-01 21:21:13 +0100576
Paul Kehrer24283d22015-08-01 21:31:19 +0100577 :raises cryptography.x509.UnsupportedExtension: If the certificate signing request
Paul Kehrerc4e61942015-08-01 21:21:13 +0100578 contains an extension that is not supported.
579
580 :raises cryptography.x509.UnsupportedGeneralNameType: If an extension
581 contains a general name that is not supported.
582
583 :raises UnicodeError: If an extension contains IDNA encoding that is
584 invalid or not compliant with IDNA 2008.
585
586
Andre Caron476c5df2015-05-18 10:23:28 -0400587 .. method:: public_bytes(encoding)
588
Alex Gaynord0b376b2015-07-05 13:58:12 -0400589 .. versionadded:: 1.0
590
Andre Caron476c5df2015-05-18 10:23:28 -0400591 :param encoding: The
592 :class:`~cryptography.hazmat.primitives.serialization.Encoding`
593 that will be used to serialize the certificate request.
594
595 :return bytes: The data that can be written to a file or sent
596 over the network to be signed by the certificate
597 authority.
598
Erik Trauschke2dcce902015-05-14 16:12:24 -0700599X.509 Revoked Certificate Object
Erik Trauschkec5a8d172015-05-28 10:24:25 -0700600~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Erik Trauschke2dcce902015-05-14 16:12:24 -0700601
602.. class:: RevokedCertificate
603
604 .. versionadded:: 1.0
605
606 .. attribute:: serial_number
607
608 :type: :class:`int`
609
610 An integer representing the serial number of the revoked certificate.
611
612 .. attribute:: revocation_date
613
614 :type: :class:`datetime.datetime`
615
616 A naïve datetime representing the date this certificates was revoked.
617
618 .. attribute:: extensions
619
620 :type: :class:`Extensions`
621
622 The extensions encoded in the revoked certificate.
Andre Caron476c5df2015-05-18 10:23:28 -0400623
Andre Caron0ef595f2015-05-18 13:53:43 -0400624X.509 CSR (Certificate Signing Request) Builder Object
625~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
626
627.. class:: CertificateSigningRequestBuilder
628
Andre Carond259ee52015-06-02 23:47:11 -0400629 .. versionadded:: 1.0
630
631 .. doctest::
632
633 >>> from cryptography import x509
634 >>> from cryptography.hazmat.backends import default_backend
635 >>> from cryptography.hazmat.primitives import hashes
636 >>> from cryptography.hazmat.primitives.asymmetric import rsa
637 >>> private_key = rsa.generate_private_key(
638 ... public_exponent=65537,
639 ... key_size=2048,
640 ... backend=default_backend()
641 ... )
642 >>> builder = x509.CertificateSigningRequestBuilder()
Andre Carona9a51172015-06-06 20:18:44 -0400643 >>> builder = builder.subject_name(x509.Name([
Ian Cordasco4d46eb72015-06-17 12:08:27 -0500644 ... x509.NameAttribute(x509.OID_COMMON_NAME, u'cryptography.io'),
Andre Carond259ee52015-06-02 23:47:11 -0400645 ... ]))
Ian Cordascof06b6be2015-06-21 10:09:18 -0500646 >>> builder = builder.add_extension(
Ian Cordasco0112b022015-06-16 17:51:18 -0500647 ... x509.BasicConstraints(ca=False, path_length=None), critical=True,
Andre Caron472fd692015-06-06 20:04:44 -0400648 ... )
Andre Carond259ee52015-06-02 23:47:11 -0400649 >>> request = builder.sign(
Alex Gaynorde9e5842015-06-26 20:11:23 -0400650 ... private_key, hashes.SHA256(), default_backend()
Andre Carond259ee52015-06-02 23:47:11 -0400651 ... )
652 >>> isinstance(request, x509.CertificateSigningRequest)
653 True
654
Andre Carona9a51172015-06-06 20:18:44 -0400655 .. method:: subject_name(name)
Andre Caron0ef595f2015-05-18 13:53:43 -0400656
Andre Caron341ff852015-06-06 20:14:31 -0400657 :param name: The :class:`~cryptography.x509.Name` of the certificate
658 subject.
659 :returns: A new
660 :class:`~cryptography.x509.CertificateSigningRequestBuilder`.
Andre Caron0ef595f2015-05-18 13:53:43 -0400661
Ian Cordascof06b6be2015-06-21 10:09:18 -0500662 .. method:: add_extension(extension, critical)
Andre Caron0ef595f2015-05-18 13:53:43 -0400663
Andre Caron341ff852015-06-06 20:14:31 -0400664 :param extension: The :class:`~cryptography.x509.Extension` to add to
665 the request.
Andre Caron472fd692015-06-06 20:04:44 -0400666 :param critical: Set to `True` if the extension must be understood and
667 handled by whoever reads the certificate.
Andre Caron341ff852015-06-06 20:14:31 -0400668 :returns: A new
669 :class:`~cryptography.x509.CertificateSigningRequestBuilder`.
Andre Caron0ef595f2015-05-18 13:53:43 -0400670
Alex Gaynorb3b0fbe2015-06-26 19:57:18 -0400671 .. method:: sign(private_key, algorithm, backend)
Andre Caron0ef595f2015-05-18 13:53:43 -0400672
673 :param backend: Backend that will be used to sign the request.
674 Must support the
675 :class:`~cryptography.hazmat.backends.interfaces.X509Backend`
676 interface.
677
678 :param private_key: The
Andre Caron24f9bf42015-06-06 20:14:54 -0400679 :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey`,
680 :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPrivateKey` or
681 :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateKey`
Andre Caron0ef595f2015-05-18 13:53:43 -0400682 that will be used to sign the request. When the request is
683 signed by a certificate authority, the private key's associated
684 public key will be stored in the resulting certificate.
685
686 :param algorithm: The
687 :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm`
688 that will be used to generate the request signature.
689
Andre Caron341ff852015-06-06 20:14:31 -0400690 :returns: A new
691 :class:`~cryptography.x509.CertificateSigningRequest`.
Andre Caron0ef595f2015-05-18 13:53:43 -0400692
693
Paul Kehrer719d5362015-01-01 20:03:52 -0600694.. class:: Name
695
696 .. versionadded:: 0.8
697
Paul Kehrer53d8d492015-02-13 18:47:30 -0600698 An X509 Name is an ordered list of attributes. The object is iterable to
Paul Kehrerd21596e2015-02-14 09:17:26 -0600699 get every attribute or you can use :meth:`Name.get_attributes_for_oid` to
Paul Kehrer719d5362015-01-01 20:03:52 -0600700 obtain the specific type you want. Names are sometimes represented as a
Paul Kehrer53d8d492015-02-13 18:47:30 -0600701 slash or comma delimited string (e.g. ``/CN=mydomain.com/O=My Org/C=US`` or
702 ``CN=mydomain.com, O=My Org, C=US``).
Paul Kehrer719d5362015-01-01 20:03:52 -0600703
Paul Kehrer53d8d492015-02-13 18:47:30 -0600704 .. doctest::
Paul Kehrer719d5362015-01-01 20:03:52 -0600705
Paul Kehrer8b21a4a2015-02-14 07:56:36 -0600706 >>> len(cert.subject)
Paul Kehrer53d8d492015-02-13 18:47:30 -0600707 3
Paul Kehrer8b21a4a2015-02-14 07:56:36 -0600708 >>> for attribute in cert.subject:
709 ... print(attribute)
710 <NameAttribute(oid=<ObjectIdentifier(oid=2.5.4.6, name=countryName)>, value=u'US')>
711 <NameAttribute(oid=<ObjectIdentifier(oid=2.5.4.10, name=organizationName)>, value=u'Test Certificates 2011')>
712 <NameAttribute(oid=<ObjectIdentifier(oid=2.5.4.3, name=commonName)>, value=u'Good CA')>
Paul Kehrer719d5362015-01-01 20:03:52 -0600713
Paul Kehrere901d642015-02-11 18:50:58 -0600714 .. method:: get_attributes_for_oid(oid)
Paul Kehrer719d5362015-01-01 20:03:52 -0600715
Paul Kehrere901d642015-02-11 18:50:58 -0600716 :param oid: An :class:`ObjectIdentifier` instance.
Paul Kehrer719d5362015-01-01 20:03:52 -0600717
Paul Kehrere901d642015-02-11 18:50:58 -0600718 :returns: A list of :class:`NameAttribute` instances that match the
719 OID provided. If nothing matches an empty list will be returned.
Paul Kehrer719d5362015-01-01 20:03:52 -0600720
721 .. doctest::
722
Paul Kehrere901d642015-02-11 18:50:58 -0600723 >>> cert.subject.get_attributes_for_oid(x509.OID_COMMON_NAME)
724 [<NameAttribute(oid=<ObjectIdentifier(oid=2.5.4.3, name=commonName)>, value=u'Good CA')>]
Paul Kehrerb2de9482014-12-11 14:54:48 -0600725
Paul Kehrere76cd272014-12-14 19:00:51 -0600726.. class:: Version
Paul Kehrer016e08a2014-11-26 09:41:18 -1000727
728 .. versionadded:: 0.7
729
730 An enumeration for X.509 versions.
731
732 .. attribute:: v1
733
734 For version 1 X.509 certificates.
735
736 .. attribute:: v3
737
738 For version 3 X.509 certificates.
739
Paul Kehrer806bfb22015-02-02 17:05:24 -0600740.. class:: NameAttribute
Paul Kehrer912d3fb2015-01-29 11:19:22 -0600741
742 .. versionadded:: 0.8
743
Paul Kehrer834d22f2015-02-06 11:01:07 -0600744 An X.509 name consists of a list of NameAttribute instances.
Paul Kehrer5b0a8d62015-01-30 20:05:55 -0600745
Paul Kehrer912d3fb2015-01-29 11:19:22 -0600746 .. attribute:: oid
747
748 :type: :class:`ObjectIdentifier`
749
750 The attribute OID.
751
752 .. attribute:: value
753
Paul Kehrerd5852cb2015-01-30 08:25:23 -0600754 :type: :term:`text`
Paul Kehrer912d3fb2015-01-29 11:19:22 -0600755
756 The value of the attribute.
757
758.. class:: ObjectIdentifier
759
760 .. versionadded:: 0.8
761
Paul Kehrer5b0a8d62015-01-30 20:05:55 -0600762 Object identifiers (frequently seen abbreviated as OID) identify the type
Paul Kehrer806bfb22015-02-02 17:05:24 -0600763 of a value (see: :class:`NameAttribute`).
Paul Kehrer5b0a8d62015-01-30 20:05:55 -0600764
Paul Kehrerd44f9a62015-02-04 14:47:34 -0600765 .. attribute:: dotted_string
Paul Kehrer912d3fb2015-01-29 11:19:22 -0600766
767 :type: :class:`str`
768
Paul Kehrerfedf4f42015-02-06 11:22:07 -0600769 The dotted string value of the OID (e.g. ``"2.5.4.3"``)
Paul Kehrer912d3fb2015-01-29 11:19:22 -0600770
Paul Kehrer31bdf792015-03-25 14:11:00 -0500771.. _general_name_classes:
772
773General Name Classes
774~~~~~~~~~~~~~~~~~~~~
775
776.. class:: GeneralName
777
778 .. versionadded:: 0.9
779
780 This is the generic interface that all the following classes are registered
781 against.
782
783.. class:: RFC822Name
784
785 .. versionadded:: 0.9
786
787 This corresponds to an email address. For example, ``user@example.com``.
788
789 .. attribute:: value
790
791 :type: :term:`text`
792
793.. class:: DNSName
794
795 .. versionadded:: 0.9
796
797 This corresponds to a domain name. For example, ``cryptography.io``.
798
799 .. attribute:: value
800
801 :type: :term:`text`
802
803.. class:: DirectoryName
804
805 .. versionadded:: 0.9
806
807 This corresponds to a directory name.
808
809 .. attribute:: value
810
811 :type: :class:`Name`
812
813.. class:: UniformResourceIdentifier
814
815 .. versionadded:: 0.9
816
817 This corresponds to a uniform resource identifier. For example,
Paul Kehrerb8ef82e2015-04-22 16:04:24 -0500818 ``https://cryptography.io``. The URI is parsed and IDNA decoded (see
819 :rfc:`5895`).
820
821 .. note::
822
823 URIs that do not contain ``://`` in them will not be decoded.
Paul Kehrer31bdf792015-03-25 14:11:00 -0500824
825 .. attribute:: value
826
827 :type: :term:`text`
828
829.. class:: IPAddress
830
831 .. versionadded:: 0.9
832
833 This corresponds to an IP address.
834
835 .. attribute:: value
836
Paul Kehrereb177932015-05-17 18:33:33 -0700837 :type: :class:`~ipaddress.IPv4Address`,
838 :class:`~ipaddress.IPv6Address`, :class:`~ipaddress.IPv4Network`,
839 or :class:`~ipaddress.IPv6Network`.
Paul Kehrer31bdf792015-03-25 14:11:00 -0500840
841.. class:: RegisteredID
842
843 .. versionadded:: 0.9
844
845 This corresponds to a registered ID.
846
847 .. attribute:: value
848
849 :type: :class:`ObjectIdentifier`
850
Joshua Tauberer2ee5e3c2015-07-04 20:09:46 +0000851.. class:: OtherName
852
853 .. versionadded:: 1.0
854
Joshua Tauberer18b6fc82015-07-05 21:44:51 +0000855 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 +0000856
857 .. attribute:: type_id
858
859 :type: :class:`ObjectIdentifier`
860
861 .. attribute:: value
862
863 :type: `bytes`
864
Paul Kehrer8cf26422015-03-21 09:50:24 -0500865X.509 Extensions
866~~~~~~~~~~~~~~~~
867
Paul Kehrerfbb7ac82015-03-16 19:26:29 -0500868.. class:: Extensions
869
870 .. versionadded:: 0.9
871
872 An X.509 Extensions instance is an ordered list of extensions. The object
873 is iterable to get every extension.
874
Paul Kehrerfa56a232015-03-17 13:14:03 -0500875 .. method:: get_extension_for_oid(oid)
876
877 :param oid: An :class:`ObjectIdentifier` instance.
878
879 :returns: An instance of the extension class.
880
881 :raises cryptography.x509.ExtensionNotFound: If the certificate does
882 not have the extension requested.
883
Paul Kehrerfa56a232015-03-17 13:14:03 -0500884 .. doctest::
885
886 >>> cert.extensions.get_extension_for_oid(x509.OID_BASIC_CONSTRAINTS)
887 <Extension(oid=<ObjectIdentifier(oid=2.5.29.19, name=basicConstraints)>, critical=True, value=<BasicConstraints(ca=True, path_length=None)>)>
888
Paul Kehrer8cf26422015-03-21 09:50:24 -0500889.. class:: Extension
890
891 .. versionadded:: 0.9
892
Paul Kehrer85894662015-03-22 13:19:31 -0500893 .. attribute:: oid
894
895 :type: :class:`ObjectIdentifier`
896
Paul Kehrer5553d572015-03-23 21:08:01 -0500897 The :ref:`extension OID <extension_oids>`.
Paul Kehrer8cf26422015-03-21 09:50:24 -0500898
899 .. attribute:: critical
900
901 :type: bool
902
Paul Kehrer58b75692015-03-22 23:24:58 -0500903 Determines whether a given extension is critical or not. :rfc:`5280`
904 requires that "A certificate-using system MUST reject the certificate
905 if it encounters a critical extension it does not recognize or a
906 critical extension that contains information that it cannot process".
Paul Kehrer8cf26422015-03-21 09:50:24 -0500907
Paul Kehrer85894662015-03-22 13:19:31 -0500908 .. attribute:: value
909
910 Returns an instance of the extension type corresponding to the OID.
911
Paul Kehrer14f0bd02015-08-06 11:55:18 +0100912.. class:: ExtensionType
913
914 .. versionadded:: 1.0
915
916 This is the interface against which all the following extension types are
917 registered.
918
Paul Kehrercecbbba2015-03-30 14:58:38 -0500919.. class:: KeyUsage
920
921 .. versionadded:: 0.9
922
923 The key usage extension defines the purpose of the key contained in the
924 certificate. The usage restriction might be employed when a key that could
Paul Kehrerb33de932015-08-06 23:41:05 +0100925 be used for more than one operation is to be restricted.
Paul Kehrercecbbba2015-03-30 14:58:38 -0500926
Paul Kehrer822f3d32015-08-06 11:47:32 +0100927 .. attribute:: oid
928
929 .. versionadded:: 1.0
930
931 :type: :class:`ObjectIdentifier`
932
Paul Kehrerb33de932015-08-06 23:41:05 +0100933 Returns :data:`OID_KEY_USAGE`.
Paul Kehrer822f3d32015-08-06 11:47:32 +0100934
Paul Kehrercecbbba2015-03-30 14:58:38 -0500935 .. attribute:: digital_signature
936
937 :type: bool
938
Paul Kehrer738407b2015-04-01 22:39:02 -0500939 This purpose is set to true when the subject public key is used for verifying
Paul Kehrercecbbba2015-03-30 14:58:38 -0500940 digital signatures, other than signatures on certificates
941 (``key_cert_sign``) and CRLs (``crl_sign``).
942
943 .. attribute:: content_commitment
944
945 :type: bool
946
Paul Kehrer738407b2015-04-01 22:39:02 -0500947 This purpose is set to true when the subject public key is used for verifying
Paul Kehrercecbbba2015-03-30 14:58:38 -0500948 digital signatures, other than signatures on certificates
949 (``key_cert_sign``) and CRLs (``crl_sign``). It is used to provide a
950 non-repudiation service that protects against the signing entity
951 falsely denying some action. In the case of later conflict, a
952 reliable third party may determine the authenticity of the signed
953 data. This was called ``non_repudiation`` in older revisions of the
954 X.509 specification.
955
956 .. attribute:: key_encipherment
957
958 :type: bool
959
Paul Kehrer738407b2015-04-01 22:39:02 -0500960 This purpose is set to true when the subject public key is used for
961 enciphering private or secret keys.
Paul Kehrercecbbba2015-03-30 14:58:38 -0500962
963 .. attribute:: data_encipherment
964
965 :type: bool
966
Paul Kehrer738407b2015-04-01 22:39:02 -0500967 This purpose is set to true when the subject public key is used for
968 directly enciphering raw user data without the use of an intermediate
969 symmetric cipher.
Paul Kehrercecbbba2015-03-30 14:58:38 -0500970
971 .. attribute:: key_agreement
972
973 :type: bool
974
Paul Kehrer738407b2015-04-01 22:39:02 -0500975 This purpose is set to true when the subject public key is used for key
976 agreement. For example, when a Diffie-Hellman key is to be used for
977 key management, then this purpose is set to true.
Paul Kehrercecbbba2015-03-30 14:58:38 -0500978
979 .. attribute:: key_cert_sign
980
981 :type: bool
982
Paul Kehrer738407b2015-04-01 22:39:02 -0500983 This purpose is set to true when the subject public key is used for
984 verifying signatures on public key certificates. If this purpose is set
985 to true then ``ca`` must be true in the :class:`BasicConstraints`
986 extension.
Paul Kehrercecbbba2015-03-30 14:58:38 -0500987
988 .. attribute:: crl_sign
989
990 :type: bool
991
Paul Kehrer738407b2015-04-01 22:39:02 -0500992 This purpose is set to true when the subject public key is used for
993 verifying signatures on certificate revocation lists.
Paul Kehrercecbbba2015-03-30 14:58:38 -0500994
995 .. attribute:: encipher_only
996
997 :type: bool
998
Paul Kehrer738407b2015-04-01 22:39:02 -0500999 When this purposes is set to true and the ``key_agreement`` purpose is
1000 also set, the subject public key may be used only for enciphering data
1001 while performing key agreement.
Paul Kehrercecbbba2015-03-30 14:58:38 -05001002
1003 :raises ValueError: This is raised if accessed when ``key_agreement``
1004 is false.
1005
1006 .. attribute:: decipher_only
1007
1008 :type: bool
1009
Paul Kehrer738407b2015-04-01 22:39:02 -05001010 When this purposes is set to true and the ``key_agreement`` purpose is
1011 also set, the subject public key may be used only for deciphering data
1012 while performing key agreement.
Paul Kehrercecbbba2015-03-30 14:58:38 -05001013
1014 :raises ValueError: This is raised if accessed when ``key_agreement``
1015 is false.
1016
1017
Paul Kehrer8cf26422015-03-21 09:50:24 -05001018.. class:: BasicConstraints
1019
1020 .. versionadded:: 0.9
1021
Paul Kehrer85894662015-03-22 13:19:31 -05001022 Basic constraints is an X.509 extension type that defines whether a given
Paul Kehrer8cf26422015-03-21 09:50:24 -05001023 certificate is allowed to sign additional certificates and what path
Paul Kehrerb33de932015-08-06 23:41:05 +01001024 length restrictions may exist.
Paul Kehrer8cf26422015-03-21 09:50:24 -05001025
Paul Kehrer822f3d32015-08-06 11:47:32 +01001026 .. attribute:: oid
1027
1028 .. versionadded:: 1.0
1029
1030 :type: :class:`ObjectIdentifier`
1031
Paul Kehrerb33de932015-08-06 23:41:05 +01001032 Returns :data:`OID_BASIC_CONSTRAINTS`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001033
Paul Kehrer8cf26422015-03-21 09:50:24 -05001034 .. attribute:: ca
1035
1036 :type: bool
1037
1038 Whether the certificate can sign certificates.
1039
1040 .. attribute:: path_length
1041
Paul Kehrerfd1444c2015-03-21 19:47:05 -05001042 :type: int or None
Paul Kehrer8cf26422015-03-21 09:50:24 -05001043
1044 The maximum path length for certificates subordinate to this
1045 certificate. This attribute only has meaning if ``ca`` is true.
1046 If ``ca`` is true then a path length of None means there's no
1047 restriction on the number of subordinate CAs in the certificate chain.
Alex Gaynor99c5f152015-05-03 10:01:04 -04001048 If it is zero or greater then it defines the maximum length for a
1049 subordinate CA's certificate chain. For example, a ``path_length`` of 1
1050 means the certificate can sign a subordinate CA, but the subordinate CA
1051 is not allowed to create subordinates with ``ca`` set to true.
Paul Kehrer8cf26422015-03-21 09:50:24 -05001052
Paul Kehrerffa2a152015-03-31 08:18:25 -05001053.. class:: ExtendedKeyUsage
1054
1055 .. versionadded:: 0.9
1056
1057 This extension indicates one or more purposes for which the certified
1058 public key may be used, in addition to or in place of the basic
1059 purposes indicated in the key usage extension. The object is
1060 iterable to obtain the list of :ref:`extended key usage OIDs <eku_oids>`.
1061
Paul Kehrer822f3d32015-08-06 11:47:32 +01001062 .. attribute:: oid
1063
1064 .. versionadded:: 1.0
1065
1066 :type: :class:`ObjectIdentifier`
1067
Paul Kehrerb33de932015-08-06 23:41:05 +01001068 Returns :data:`OID_EXTENDED_KEY_USAGE`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001069
1070
Paul Kehrer4a1038e2015-05-18 10:28:31 -07001071.. class:: OCSPNoCheck
1072
Paul Kehrer506a2152015-05-26 08:01:18 -05001073 .. versionadded:: 1.0
Paul Kehrer4a1038e2015-05-18 10:28:31 -07001074
1075 This presence of this extension indicates that an OCSP client can trust a
1076 responder for the lifetime of the responder's certificate. CAs issuing
1077 such a certificate should realize that a compromise of the responder's key
1078 is as serious as the compromise of a CA key used to sign CRLs, at least for
1079 the validity period of this certificate. CA's may choose to issue this type
1080 of certificate with a very short lifetime and renew it frequently. This
1081 extension is only relevant when the certificate is an authorized OCSP
1082 responder.
1083
Paul Kehrer822f3d32015-08-06 11:47:32 +01001084 .. attribute:: oid
1085
1086 .. versionadded:: 1.0
1087
1088 :type: :class:`ObjectIdentifier`
1089
Paul Kehrer3cee8722015-08-07 13:47:28 -05001090 Returns :data:`OID_OCSP_NO_CHECK`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001091
Paul Kehrere0017be2015-05-17 20:39:40 -06001092.. class:: NameConstraints
1093
1094 .. versionadded:: 1.0
1095
1096 The name constraints extension, which only has meaning in a CA certificate,
1097 defines a name space within which all subject names in certificates issued
1098 beneath the CA certificate must (or must not) be in. For specific details
1099 on the way this extension should be processed see :rfc:`5280`.
1100
Paul Kehrer822f3d32015-08-06 11:47:32 +01001101 .. attribute:: oid
1102
1103 .. versionadded:: 1.0
1104
1105 :type: :class:`ObjectIdentifier`
1106
Paul Kehrerb33de932015-08-06 23:41:05 +01001107 Returns :data:`OID_NAME_CONSTRAINTS`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001108
Paul Kehrere0017be2015-05-17 20:39:40 -06001109 .. attribute:: permitted_subtrees
1110
1111 :type: list of :class:`GeneralName` objects or None
1112
1113 The set of permitted name patterns. If a name matches this and an
1114 element in ``excluded_subtrees`` it is invalid. At least one of
1115 ``permitted_subtrees`` and ``excluded_subtrees`` will be non-None.
1116
1117 .. attribute:: excluded_subtrees
1118
1119 :type: list of :class:`GeneralName` objects or None
1120
1121 Any name matching a restriction in the ``excluded_subtrees`` field is
1122 invalid regardless of information appearing in the
1123 ``permitted_subtrees``. At least one of ``permitted_subtrees`` and
1124 ``excluded_subtrees`` will be non-None.
1125
Paul Kehrer2eb4ed92015-04-11 15:33:45 -04001126.. class:: AuthorityKeyIdentifier
1127
1128 .. versionadded:: 0.9
1129
1130 The authority key identifier extension provides a means of identifying the
1131 public key corresponding to the private key used to sign a certificate.
Paul Kehrer8c8cd722015-04-19 09:15:04 -05001132 This extension is typically used to assist in determining the appropriate
1133 certificate chain. For more information about generation and use of this
1134 extension see `RFC 5280 section 4.2.1.1`_.
Paul Kehrer2eb4ed92015-04-11 15:33:45 -04001135
Paul Kehrer822f3d32015-08-06 11:47:32 +01001136 .. attribute:: oid
1137
1138 .. versionadded:: 1.0
1139
1140 :type: :class:`ObjectIdentifier`
1141
Paul Kehrerb33de932015-08-06 23:41:05 +01001142 Returns :data:`OID_AUTHORITY_KEY_IDENTIFIER`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001143
Paul Kehrer2eb4ed92015-04-11 15:33:45 -04001144 .. attribute:: key_identifier
1145
1146 :type: bytes
1147
Paul Kehrer9104b1d2015-04-18 09:23:44 -05001148 A value derived from the public key used to verify the certificate's
Paul Kehrer8c8cd722015-04-19 09:15:04 -05001149 signature.
Paul Kehrer9104b1d2015-04-18 09:23:44 -05001150
Paul Kehrer2eb4ed92015-04-11 15:33:45 -04001151 .. attribute:: authority_cert_issuer
1152
1153 :type: :class:`Name` or None
1154
Paul Kehrer9104b1d2015-04-18 09:23:44 -05001155 The :class:`Name` of the issuer's issuer.
1156
Paul Kehrer2eb4ed92015-04-11 15:33:45 -04001157 .. attribute:: authority_cert_serial_number
1158
1159 :type: int or None
1160
Paul Kehrer9104b1d2015-04-18 09:23:44 -05001161 The serial number of the issuer's issuer.
1162
Paul Kehrer253929a2015-08-05 17:30:39 +01001163 .. classmethod:: from_issuer_public_key(public_key)
1164
1165 .. versionadded:: 1.0
1166
1167 Creates a new AuthorityKeyIdentifier instance using the public key
1168 provided to generate the appropriate digest. This should be the
1169 **issuer public key**. The resulting object will contain a
1170 :attr:`~cryptography.x509.AuthorityKeyIdentifier.key_identifier`.
1171 The generated digest is the SHA1 hash of the ``subjectPublicKey`` A
1172 SN.1 bit string. This is the first recommendation in :rfc:`5280`
1173 section 4.2.1.2.
1174
1175 :param certificate: The issuing :class:`~cryptography.x509.Certificate`.
1176
1177 .. doctest::
1178
1179 >>> from cryptography import x509
1180 >>> from cryptography.hazmat.backends import default_backend
1181 >>> cert = x509.load_pem_x509_certificate(pem_data, default_backend())
1182 >>> x509.AuthorityKeyIdentifier.from_issuer_public_key(cert.public_key())
1183 <AuthorityKeyIdentifier(key_identifier='X\x01\x84$\x1b\xbc+R\x94J=\xa5\x10r\x14Q\xf5\xaf:\xc9', authority_cert_issuer=None, authority_cert_serial_number=None)>
1184
Paul Kehrer1eb82a62015-03-31 20:00:33 -05001185.. class:: SubjectKeyIdentifier
1186
1187 .. versionadded:: 0.9
1188
1189 The subject key identifier extension provides a means of identifying
1190 certificates that contain a particular public key.
1191
Paul Kehrer822f3d32015-08-06 11:47:32 +01001192 .. attribute:: oid
1193
1194 .. versionadded:: 1.0
1195
1196 :type: :class:`ObjectIdentifier`
1197
Paul Kehrerb33de932015-08-06 23:41:05 +01001198 Returns :data:`OID_SUBJECT_KEY_IDENTIFIER`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001199
Paul Kehrer1eb82a62015-03-31 20:00:33 -05001200 .. attribute:: digest
1201
1202 :type: bytes
1203
1204 The binary value of the identifier.
1205
Paul Kehrerd4a7f062015-08-05 18:32:18 +01001206 .. classmethod:: from_public_key(public_key)
Paul Kehrerf22f6122015-08-05 12:57:13 +01001207
1208 .. versionadded:: 1.0
1209
1210 Creates a new SubjectKeyIdentifier instance using the public key
1211 provided to generate the appropriate digest. This should be the public
Paul Kehrereb9ec002015-08-08 10:03:02 -05001212 key that is in the certificate. The generated digest is the SHA1 hash
1213 of the ``subjectPublicKey`` ASN.1 bit string. This is the first
1214 recommendation in :rfc:`5280` section 4.2.1.2.
Paul Kehrerf22f6122015-08-05 12:57:13 +01001215
1216 :param public_key: One of
1217 :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey`
1218 ,
1219 :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPublicKey`
1220 , or
1221 :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey`.
1222
Paul Kehrer253929a2015-08-05 17:30:39 +01001223 .. doctest::
1224
1225 >>> from cryptography import x509
1226 >>> from cryptography.hazmat.backends import default_backend
1227 >>> cert = x509.load_pem_x509_certificate(pem_data, default_backend())
1228 >>> x509.SubjectKeyIdentifier.from_public_key(cert.public_key())
1229 <SubjectKeyIdentifier(digest='X\x01\x84$\x1b\xbc+R\x94J=\xa5\x10r\x14Q\xf5\xaf:\xc9')>
1230
Paul Kehrer31bdf792015-03-25 14:11:00 -05001231.. class:: SubjectAlternativeName
1232
1233 .. versionadded:: 0.9
1234
1235 Subject alternative name is an X.509 extension that provides a list of
1236 :ref:`general name <general_name_classes>` instances that provide a set
1237 of identities for which the certificate is valid. The object is iterable to
1238 get every element.
1239
Paul Kehrer822f3d32015-08-06 11:47:32 +01001240 .. attribute:: oid
1241
1242 .. versionadded:: 1.0
1243
1244 :type: :class:`ObjectIdentifier`
1245
Paul Kehrerb33de932015-08-06 23:41:05 +01001246 Returns :data:`OID_SUBJECT_ALTERNATIVE_NAME`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001247
Paul Kehrer31bdf792015-03-25 14:11:00 -05001248 .. method:: get_values_for_type(type)
1249
1250 :param type: A :class:`GeneralName` provider. This is one of the
1251 :ref:`general name classes <general_name_classes>`.
1252
1253 :returns: A list of values extracted from the matched general names.
Joshua Taubererd2afad32015-07-06 22:37:53 +00001254 The type of the returned values depends on the :class:`GeneralName`.
Paul Kehrer31bdf792015-03-25 14:11:00 -05001255
Paul Kehrer93ae8052015-05-02 23:18:09 -05001256 .. doctest::
1257
1258 >>> from cryptography import x509
1259 >>> from cryptography.hazmat.backends import default_backend
1260 >>> from cryptography.hazmat.primitives import hashes
1261 >>> cert = x509.load_pem_x509_certificate(cryptography_cert_pem, default_backend())
Paul Kehrerd0cd5072015-05-02 23:27:00 -05001262 >>> # Get the subjectAltName extension from the certificate
Paul Kehrer93ae8052015-05-02 23:18:09 -05001263 >>> ext = cert.extensions.get_extension_for_oid(x509.OID_SUBJECT_ALTERNATIVE_NAME)
Paul Kehrerd0cd5072015-05-02 23:27:00 -05001264 >>> # Get the dNSName entries from the SAN extension
1265 >>> ext.value.get_values_for_type(x509.DNSName)
Paul Kehrer93ae8052015-05-02 23:18:09 -05001266 [u'www.cryptography.io', u'cryptography.io']
1267
Paul Kehrer8cf26422015-03-21 09:50:24 -05001268
Paul Kehrer99125c92015-06-07 18:37:10 -05001269.. class:: IssuerAlternativeName
1270
1271 .. versionadded:: 1.0
1272
1273 Issuer alternative name is an X.509 extension that provides a list of
1274 :ref:`general name <general_name_classes>` instances that provide a set
1275 of identities for the certificate issuer. The object is iterable to
1276 get every element.
1277
Paul Kehrer822f3d32015-08-06 11:47:32 +01001278 .. attribute:: oid
1279
1280 .. versionadded:: 1.0
1281
1282 :type: :class:`ObjectIdentifier`
1283
Paul Kehrerb33de932015-08-06 23:41:05 +01001284 Returns :data:`OID_ISSUER_ALTERNATIVE_NAME`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001285
Paul Kehrer99125c92015-06-07 18:37:10 -05001286 .. method:: get_values_for_type(type)
1287
1288 :param type: A :class:`GeneralName` provider. This is one of the
1289 :ref:`general name classes <general_name_classes>`.
1290
1291 :returns: A list of values extracted from the matched general names.
1292
1293
Paul Kehrer3e6d5582015-05-02 21:57:56 -05001294.. class:: AuthorityInformationAccess
1295
1296 .. versionadded:: 0.9
1297
1298 The authority information access extension indicates how to access
1299 information and services for the issuer of the certificate in which
1300 the extension appears. Information and services may include online
1301 validation services (such as OCSP) and issuer data. It is an iterable,
1302 containing one or more :class:`AccessDescription` instances.
1303
Paul Kehrer822f3d32015-08-06 11:47:32 +01001304 .. attribute:: oid
1305
1306 .. versionadded:: 1.0
1307
1308 :type: :class:`ObjectIdentifier`
1309
Paul Kehrerb33de932015-08-06 23:41:05 +01001310 Returns :data:`OID_AUTHORITY_INFORMATION_ACCESS`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001311
Paul Kehrer3e6d5582015-05-02 21:57:56 -05001312
1313.. class:: AccessDescription
1314
Paul Kehrer5a485522015-05-06 00:29:12 -05001315 .. versionadded:: 0.9
1316
Paul Kehrer3e6d5582015-05-02 21:57:56 -05001317 .. attribute:: access_method
1318
1319 :type: :class:`ObjectIdentifier`
1320
Paul Kehrerf506bca2015-05-02 22:31:47 -05001321 The access method defines what the ``access_location`` means. It must
1322 be either :data:`OID_OCSP` or :data:`OID_CA_ISSUERS`. If it is
1323 :data:`OID_OCSP` the access location will be where to obtain OCSP
1324 information for the certificate. If it is :data:`OID_CA_ISSUERS` the
1325 access location will provide additional information about the issuing
1326 certificate.
Paul Kehrer3e6d5582015-05-02 21:57:56 -05001327
1328 .. attribute:: access_location
1329
1330 :type: :class:`GeneralName`
1331
Paul Kehrerf506bca2015-05-02 22:31:47 -05001332 Where to access the information defined by the access method.
1333
Paul Kehrer5a485522015-05-06 00:29:12 -05001334.. class:: CRLDistributionPoints
1335
1336 .. versionadded:: 0.9
1337
1338 The CRL distribution points extension identifies how CRL information is
1339 obtained. It is an iterable, containing one or more
1340 :class:`DistributionPoint` instances.
1341
Paul Kehrer822f3d32015-08-06 11:47:32 +01001342 .. attribute:: oid
1343
1344 .. versionadded:: 1.0
1345
1346 :type: :class:`ObjectIdentifier`
1347
Paul Kehrerb33de932015-08-06 23:41:05 +01001348 Returns :data:`OID_CRL_DISTRIBUTION_POINTS`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001349
Paul Kehrer5a485522015-05-06 00:29:12 -05001350.. class:: DistributionPoint
1351
1352 .. versionadded:: 0.9
1353
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05001354 .. attribute:: full_name
Paul Kehrer5a485522015-05-06 00:29:12 -05001355
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05001356 :type: list of :class:`GeneralName` instances or None
Paul Kehrer5a485522015-05-06 00:29:12 -05001357
Paul Kehrerf2c072b2015-05-09 17:04:28 -05001358 This field describes methods to retrieve the CRL. At most one of
1359 ``full_name`` or ``relative_name`` will be non-None.
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05001360
1361 .. attribute:: relative_name
1362
1363 :type: :class:`Name` or None
1364
1365 This field describes methods to retrieve the CRL relative to the CRL
Paul Kehrerf2c072b2015-05-09 17:04:28 -05001366 issuer. At most one of ``full_name`` or ``relative_name`` will be
1367 non-None.
Paul Kehrer5a485522015-05-06 00:29:12 -05001368
1369 .. attribute:: crl_issuer
1370
1371 :type: list of :class:`GeneralName` instances or None
1372
1373 Information about the issuer of the CRL.
1374
1375 .. attribute:: reasons
1376
Paul Kehrer3fd02602015-05-09 19:46:13 -05001377 :type: frozenset of :class:`ReasonFlags` or None
Paul Kehrer5a485522015-05-06 00:29:12 -05001378
1379 The reasons a given distribution point may be used for when performing
1380 revocation checks.
1381
1382.. class:: ReasonFlags
1383
1384 .. versionadded:: 0.9
1385
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05001386 An enumeration for CRL reasons.
1387
1388 .. attribute:: unspecified
1389
1390 It is unspecified why the certificate was revoked. This reason cannot
1391 be used as a reason flag in a :class:`DistributionPoint`.
Paul Kehrer5a485522015-05-06 00:29:12 -05001392
1393 .. attribute:: key_compromise
1394
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05001395 This reason indicates that the private key was compromised.
Paul Kehrer5a485522015-05-06 00:29:12 -05001396
1397 .. attribute:: ca_compromise
1398
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05001399 This reason indicates that the CA issuing the certificate was
1400 compromised.
Paul Kehrer5a485522015-05-06 00:29:12 -05001401
1402 .. attribute:: affiliation_changed
1403
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05001404 This reason indicates that the subject's name or other information has
1405 changed.
Paul Kehrer5a485522015-05-06 00:29:12 -05001406
1407 .. attribute:: superseded
1408
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05001409 This reason indicates that a certificate has been superseded.
Paul Kehrer5a485522015-05-06 00:29:12 -05001410
1411 .. attribute:: cessation_of_operation
1412
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05001413 This reason indicates that the certificate is no longer required.
Paul Kehrer5a485522015-05-06 00:29:12 -05001414
1415 .. attribute:: certificate_hold
1416
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05001417 This reason indicates that the certificate is on hold.
Paul Kehrer5a485522015-05-06 00:29:12 -05001418
1419 .. attribute:: privilege_withdrawn
1420
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05001421 This reason indicates that the privilege granted by this certificate
1422 have been withdrawn.
Paul Kehrer5a485522015-05-06 00:29:12 -05001423
1424 .. attribute:: aa_compromise
1425
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05001426 When an attribute authority has been compromised.
1427
1428 .. attribute:: remove_from_crl
1429
1430 This reason indicates that the certificate was on hold and should be
1431 removed from the CRL. This reason cannot be used as a reason flag
1432 in a :class:`DistributionPoint`.
Paul Kehrer5a485522015-05-06 00:29:12 -05001433
Paul Kehrer16fae762015-05-01 23:14:20 -05001434.. class:: InhibitAnyPolicy
1435
1436 .. versionadded:: 1.0
1437
1438 The inhibit ``anyPolicy`` extension indicates that the special OID
1439 :data:`OID_ANY_POLICY`, is not considered an explicit match for other
1440 :class:`CertificatePolicies` except when it appears in an intermediate
1441 self-issued CA certificate. The value indicates the number of additional
1442 non-self-issued certificates that may appear in the path before
1443 :data:`OID_ANY_POLICY` is no longer permitted. For example, a value
1444 of one indicates that :data:`OID_ANY_POLICY` may be processed in
1445 certificates issued by the subject of this certificate, but not in
1446 additional certificates in the path.
1447
Paul Kehrer822f3d32015-08-06 11:47:32 +01001448 .. attribute:: oid
1449
1450 .. versionadded:: 1.0
1451
1452 :type: :class:`ObjectIdentifier`
1453
Paul Kehrerb33de932015-08-06 23:41:05 +01001454 Returns :data:`OID_INHIBIT_ANY_POLICY`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001455
Paul Kehrer16fae762015-05-01 23:14:20 -05001456 .. attribute:: skip_certs
1457
1458 :type: int
1459
Paul Kehrer0d210922015-04-28 17:31:07 -05001460.. class:: CertificatePolicies
1461
1462 .. versionadded:: 0.9
1463
Paul Kehrer2e879742015-05-02 23:09:56 -05001464 The certificate policies extension is an iterable, containing one or more
1465 :class:`PolicyInformation` instances.
Paul Kehrer0d210922015-04-28 17:31:07 -05001466
Paul Kehrer822f3d32015-08-06 11:47:32 +01001467 .. attribute:: oid
1468
1469 .. versionadded:: 1.0
1470
1471 :type: :class:`ObjectIdentifier`
1472
Paul Kehrerb33de932015-08-06 23:41:05 +01001473 Returns :data:`OID_CERTIFICATE_POLICIES`.
Paul Kehrer822f3d32015-08-06 11:47:32 +01001474
Paul Kehrer0d210922015-04-28 17:31:07 -05001475Certificate Policies Classes
1476~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1477
1478These classes may be present within a :class:`CertificatePolicies` instance.
1479
1480.. class:: PolicyInformation
1481
1482 .. versionadded:: 0.9
1483
1484 Contains a policy identifier and an optional list of qualifiers.
1485
1486 .. attribute:: policy_identifier
1487
1488 :type: :class:`ObjectIdentifier`
1489
1490 .. attribute:: policy_qualifiers
1491
1492 :type: list
1493
Paul Kehrerba35b3b2015-05-10 13:07:59 -05001494 A list consisting of :term:`text` and/or :class:`UserNotice` objects.
Paul Kehrer3f8ddeb2015-05-11 00:25:36 -05001495 If the value is text it is a pointer to the practice statement
1496 published by the certificate authority. If it is a user notice it is
1497 meant for display to the relying party when the certificate is
1498 used.
Paul Kehrer2e879742015-05-02 23:09:56 -05001499
Paul Kehrer0d210922015-04-28 17:31:07 -05001500.. class:: UserNotice
1501
1502 .. versionadded:: 0.9
1503
Paul Kehrer2e879742015-05-02 23:09:56 -05001504 User notices are intended for display to a relying party when a certificate
1505 is used. In practice, few if any UIs expose this data and it is a rarely
1506 encoded component.
1507
Paul Kehrer0d210922015-04-28 17:31:07 -05001508 .. attribute:: notice_reference
1509
1510 :type: :class:`NoticeReference` or None
1511
Paul Kehrer2e879742015-05-02 23:09:56 -05001512 The notice reference field names an organization and identifies,
1513 by number, a particular statement prepared by that organization.
1514
Paul Kehrer0d210922015-04-28 17:31:07 -05001515 .. attribute:: explicit_text
1516
Paul Kehrer2e879742015-05-02 23:09:56 -05001517 This field includes an arbitrary textual statement directly in the
1518 certificate.
1519
Paul Kehrer0d210922015-04-28 17:31:07 -05001520 :type: :term:`text`
1521
1522.. class:: NoticeReference
1523
Paul Kehrer2e879742015-05-02 23:09:56 -05001524 Notice reference can name an organization and provide information about
1525 notices related to the certificate. For example, it might identify the
1526 organization name and notice number 1. Application software could
1527 have a notice file containing the current set of notices for the named
1528 organization; the application would then extract the notice text from the
1529 file and display it. In practice this is rarely seen.
1530
Paul Kehrer0d210922015-04-28 17:31:07 -05001531 .. versionadded:: 0.9
1532
1533 .. attribute:: organization
1534
Paul Kehrer66c61702015-05-12 16:39:18 -05001535 :type: :term:`text`
Paul Kehrer0d210922015-04-28 17:31:07 -05001536
Paul Kehrer3f8ddeb2015-05-11 00:25:36 -05001537 .. attribute:: notice_numbers
Paul Kehrer0d210922015-04-28 17:31:07 -05001538
Paul Kehrer66c61702015-05-12 16:39:18 -05001539 :type: list
Paul Kehrer0d210922015-04-28 17:31:07 -05001540
Paul Kehrer66c61702015-05-12 16:39:18 -05001541 A list of integers.
Paul Kehrer0d210922015-04-28 17:31:07 -05001542
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001543Object Identifiers
1544~~~~~~~~~~~~~~~~~~
1545
Paul Kehrer4bb46492015-02-07 16:59:14 -06001546X.509 elements are frequently identified by :class:`ObjectIdentifier`
1547instances. The following common OIDs are available as constants.
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001548
Paul Kehrer56da2a52015-02-11 23:35:07 -06001549Name OIDs
1550~~~~~~~~~
1551
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001552.. data:: OID_COMMON_NAME
1553
Paul Kehrerfb5ac9e2015-02-07 16:29:37 -06001554 Corresponds to the dotted string ``"2.5.4.3"``. Historically the domain
1555 name would be encoded here for server certificates. :rfc:`2818` deprecates
1556 this practice and names of that type should now be located in a
Paul Kehrer4bb46492015-02-07 16:59:14 -06001557 SubjectAlternativeName extension. This OID is typically seen in X.509 names.
Paul Kehrer858b9b72015-02-05 09:50:31 -06001558
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001559.. data:: OID_COUNTRY_NAME
1560
Paul Kehrer4bb46492015-02-07 16:59:14 -06001561 Corresponds to the dotted string ``"2.5.4.6"``. This OID is typically seen
1562 in X.509 names.
Paul Kehrer858b9b72015-02-05 09:50:31 -06001563
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001564.. data:: OID_LOCALITY_NAME
1565
Paul Kehrer4bb46492015-02-07 16:59:14 -06001566 Corresponds to the dotted string ``"2.5.4.7"``. This OID is typically seen
1567 in X.509 names.
Paul Kehrer858b9b72015-02-05 09:50:31 -06001568
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001569.. data:: OID_STATE_OR_PROVINCE_NAME
1570
Paul Kehrer4bb46492015-02-07 16:59:14 -06001571 Corresponds to the dotted string ``"2.5.4.8"``. This OID is typically seen
1572 in X.509 names.
Paul Kehrer858b9b72015-02-05 09:50:31 -06001573
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001574.. data:: OID_ORGANIZATION_NAME
1575
Paul Kehrer4bb46492015-02-07 16:59:14 -06001576 Corresponds to the dotted string ``"2.5.4.10"``. This OID is typically seen
1577 in X.509 names.
Paul Kehrer858b9b72015-02-05 09:50:31 -06001578
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001579.. data:: OID_ORGANIZATIONAL_UNIT_NAME
1580
Paul Kehrer4bb46492015-02-07 16:59:14 -06001581 Corresponds to the dotted string ``"2.5.4.11"``. This OID is typically seen
1582 in X.509 names.
Paul Kehrer858b9b72015-02-05 09:50:31 -06001583
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001584.. data:: OID_SERIAL_NUMBER
1585
Paul Kehrerfb5ac9e2015-02-07 16:29:37 -06001586 Corresponds to the dotted string ``"2.5.4.5"``. This is distinct from the
1587 serial number of the certificate itself (which can be obtained with
Paul Kehrer4bb46492015-02-07 16:59:14 -06001588 :func:`Certificate.serial`). This OID is typically seen in X.509 names.
Paul Kehrer858b9b72015-02-05 09:50:31 -06001589
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001590.. data:: OID_SURNAME
1591
Paul Kehrer4bb46492015-02-07 16:59:14 -06001592 Corresponds to the dotted string ``"2.5.4.4"``. This OID is typically seen
1593 in X.509 names.
Paul Kehrer858b9b72015-02-05 09:50:31 -06001594
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001595.. data:: OID_GIVEN_NAME
1596
Paul Kehrer4bb46492015-02-07 16:59:14 -06001597 Corresponds to the dotted string ``"2.5.4.42"``. This OID is typically seen
1598 in X.509 names.
Paul Kehrer858b9b72015-02-05 09:50:31 -06001599
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001600.. data:: OID_TITLE
1601
Paul Kehrer4bb46492015-02-07 16:59:14 -06001602 Corresponds to the dotted string ``"2.5.4.12"``. This OID is typically seen
1603 in X.509 names.
Paul Kehrer858b9b72015-02-05 09:50:31 -06001604
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001605.. data:: OID_GENERATION_QUALIFIER
1606
Paul Kehrer4bb46492015-02-07 16:59:14 -06001607 Corresponds to the dotted string ``"2.5.4.44"``. This OID is typically seen
1608 in X.509 names.
Paul Kehrer858b9b72015-02-05 09:50:31 -06001609
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001610.. data:: OID_DN_QUALIFIER
1611
Paul Kehrerfb5ac9e2015-02-07 16:29:37 -06001612 Corresponds to the dotted string ``"2.5.4.46"``. This specifies
1613 disambiguating information to add to the relative distinguished name of an
Paul Kehrer4bb46492015-02-07 16:59:14 -06001614 entry. See :rfc:`2256`. This OID is typically seen in X.509 names.
Paul Kehrer858b9b72015-02-05 09:50:31 -06001615
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001616.. data:: OID_PSEUDONYM
1617
Paul Kehrer4bb46492015-02-07 16:59:14 -06001618 Corresponds to the dotted string ``"2.5.4.65"``. This OID is typically seen
1619 in X.509 names.
Paul Kehrer858b9b72015-02-05 09:50:31 -06001620
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001621.. data:: OID_DOMAIN_COMPONENT
1622
Paul Kehrerfb5ac9e2015-02-07 16:29:37 -06001623 Corresponds to the dotted string ``"0.9.2342.19200300.100.1.25"``. A string
Paul Kehrer4bb46492015-02-07 16:59:14 -06001624 holding one component of a domain name. See :rfc:`4519`. This OID is
1625 typically seen in X.509 names.
Paul Kehrer858b9b72015-02-05 09:50:31 -06001626
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001627.. data:: OID_EMAIL_ADDRESS
1628
Paul Kehrer4bb46492015-02-07 16:59:14 -06001629 Corresponds to the dotted string ``"1.2.840.113549.1.9.1"``. This OID is
1630 typically seen in X.509 names.
Paul Kehrer858b9b72015-02-05 09:50:31 -06001631
Paul Kehrer56da2a52015-02-11 23:35:07 -06001632Signature Algorithm OIDs
1633~~~~~~~~~~~~~~~~~~~~~~~~
1634
Paul Kehrer1a7ba872015-02-19 18:09:05 -06001635.. data:: OID_RSA_WITH_MD5
Paul Kehrer56da2a52015-02-11 23:35:07 -06001636
1637 Corresponds to the dotted string ``"1.2.840.113549.1.1.4"``. This is
1638 an MD5 digest signed by an RSA key.
1639
Paul Kehrer1a7ba872015-02-19 18:09:05 -06001640.. data:: OID_RSA_WITH_SHA1
Paul Kehrer56da2a52015-02-11 23:35:07 -06001641
1642 Corresponds to the dotted string ``"1.2.840.113549.1.1.5"``. This is
1643 a SHA1 digest signed by an RSA key.
1644
Paul Kehrer1a7ba872015-02-19 18:09:05 -06001645.. data:: OID_RSA_WITH_SHA224
Paul Kehrer56da2a52015-02-11 23:35:07 -06001646
1647 Corresponds to the dotted string ``"1.2.840.113549.1.1.14"``. This is
1648 a SHA224 digest signed by an RSA key.
1649
Paul Kehrer1a7ba872015-02-19 18:09:05 -06001650.. data:: OID_RSA_WITH_SHA256
Paul Kehrer56da2a52015-02-11 23:35:07 -06001651
1652 Corresponds to the dotted string ``"1.2.840.113549.1.1.11"``. This is
1653 a SHA256 digest signed by an RSA key.
1654
Paul Kehrer1a7ba872015-02-19 18:09:05 -06001655.. data:: OID_RSA_WITH_SHA384
Paul Kehrer56da2a52015-02-11 23:35:07 -06001656
1657 Corresponds to the dotted string ``"1.2.840.113549.1.1.12"``. This is
1658 a SHA384 digest signed by an RSA key.
1659
Paul Kehrer1a7ba872015-02-19 18:09:05 -06001660.. data:: OID_RSA_WITH_SHA512
Paul Kehrer56da2a52015-02-11 23:35:07 -06001661
1662 Corresponds to the dotted string ``"1.2.840.113549.1.1.13"``. This is
1663 a SHA512 digest signed by an RSA key.
1664
Alex Gaynor3aadabf2015-06-23 22:06:21 -04001665.. data:: OID_ECDSA_WITH_SHA1
1666
1667 Corresponds to the dotted string ``"1.2.840.10045.4.1"``. This is a SHA1
1668 digest signed by an ECDSA key.
1669
Paul Kehrer56da2a52015-02-11 23:35:07 -06001670.. data:: OID_ECDSA_WITH_SHA224
1671
1672 Corresponds to the dotted string ``"1.2.840.10045.4.3.1"``. This is
1673 a SHA224 digest signed by an ECDSA key.
1674
1675.. data:: OID_ECDSA_WITH_SHA256
1676
1677 Corresponds to the dotted string ``"1.2.840.10045.4.3.2"``. This is
1678 a SHA256 digest signed by an ECDSA key.
1679
1680.. data:: OID_ECDSA_WITH_SHA384
1681
1682 Corresponds to the dotted string ``"1.2.840.10045.4.3.3"``. This is
1683 a SHA384 digest signed by an ECDSA key.
1684
1685.. data:: OID_ECDSA_WITH_SHA512
1686
1687 Corresponds to the dotted string ``"1.2.840.10045.4.3.4"``. This is
1688 a SHA512 digest signed by an ECDSA key.
1689
1690.. data:: OID_DSA_WITH_SHA1
1691
1692 Corresponds to the dotted string ``"1.2.840.10040.4.3"``. This is
1693 a SHA1 digest signed by a DSA key.
1694
1695.. data:: OID_DSA_WITH_SHA224
1696
1697 Corresponds to the dotted string ``"2.16.840.1.101.3.4.3.1"``. This is
1698 a SHA224 digest signed by a DSA key.
1699
1700.. data:: OID_DSA_WITH_SHA256
1701
Paul Kehrerfbb7ac82015-03-16 19:26:29 -05001702 Corresponds to the dotted string ``"2.16.840.1.101.3.4.3.2"``. This is
Paul Kehrer56da2a52015-02-11 23:35:07 -06001703 a SHA256 digest signed by a DSA key.
1704
Paul Kehrerffa2a152015-03-31 08:18:25 -05001705.. _eku_oids:
1706
Paul Kehrere1513fa2015-03-30 23:08:17 -05001707Extended Key Usage OIDs
1708~~~~~~~~~~~~~~~~~~~~~~~
1709
1710.. data:: OID_SERVER_AUTH
1711
1712 Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.1"``. This is used to
1713 denote that a certificate may be used for TLS web server authentication.
1714
1715.. data:: OID_CLIENT_AUTH
1716
1717 Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.2"``. This is used to
1718 denote that a certificate may be used for TLS web client authentication.
1719
1720.. data:: OID_CODE_SIGNING
1721
1722 Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.3"``. This is used to
1723 denote that a certificate may be used for code signing.
1724
1725.. data:: OID_EMAIL_PROTECTION
1726
1727 Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.4"``. This is used to
1728 denote that a certificate may be used for email protection.
1729
1730.. data:: OID_TIME_STAMPING
1731
1732 Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.8"``. This is used to
1733 denote that a certificate may be used for time stamping.
1734
1735.. data:: OID_OCSP_SIGNING
1736
1737 Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.9"``. This is used to
1738 denote that a certificate may be used for signing OCSP responses.
1739
Paul Kehrer3e6d5582015-05-02 21:57:56 -05001740Authority Information Access OIDs
1741~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1742
1743.. data:: OID_OCSP
1744
1745 Corresponds to the dotted string ``"1.3.6.1.5.5.7.48.1"``. Used as the
1746 identifier for OCSP data in :class:`AccessDescription` objects.
1747
1748.. data:: OID_CA_ISSUERS
1749
1750 Corresponds to the dotted string ``"1.3.6.1.5.5.7.48.2"``. Used as the
1751 identifier for CA issuer data in :class:`AccessDescription` objects.
1752
Paul Kehrer2e879742015-05-02 23:09:56 -05001753Policy Qualifier OIDs
1754~~~~~~~~~~~~~~~~~~~~~
1755
1756.. data:: OID_CPS_QUALIFIER
1757
Paul Kehrerba35b3b2015-05-10 13:07:59 -05001758 Corresponds to the dotted string ``"1.3.6.1.5.5.7.2.1"``.
Paul Kehrer2e879742015-05-02 23:09:56 -05001759
1760.. data:: OID_CPS_USER_NOTICE
1761
Paul Kehrerba35b3b2015-05-10 13:07:59 -05001762 Corresponds to the dotted string ``"1.3.6.1.5.5.7.2.2"``.
Paul Kehrer2e879742015-05-02 23:09:56 -05001763
Paul Kehrer16fae762015-05-01 23:14:20 -05001764.. data:: OID_ANY_POLICY
1765
1766 Corresponds to the dotted string ``"2.5.29.32.0"``.
1767
Paul Kehrer5553d572015-03-23 21:08:01 -05001768.. _extension_oids:
1769
Paul Kehrer2bb94642015-03-21 09:54:17 -05001770Extension OIDs
1771~~~~~~~~~~~~~~
1772
1773.. data:: OID_BASIC_CONSTRAINTS
1774
1775 Corresponds to the dotted string ``"2.5.29.19"``. The identifier for the
Paul Kehrer611d3d32015-03-22 13:31:18 -05001776 :class:`BasicConstraints` extension type.
Paul Kehrer2bb94642015-03-21 09:54:17 -05001777
Paul Kehrercecbbba2015-03-30 14:58:38 -05001778.. data:: OID_KEY_USAGE
1779
1780 Corresponds to the dotted string ``"2.5.29.15"``. The identifier for the
1781 :class:`KeyUsage` extension type.
1782
Paul Kehrerd4f632e2015-05-12 08:25:42 -05001783.. data:: OID_SUBJECT_ALTERNATIVE_NAME
1784
1785 Corresponds to the dotted string ``"2.5.29.17"``. The identifier for the
1786 :class:`SubjectAlternativeName` extension type.
1787
Paul Kehrer99125c92015-06-07 18:37:10 -05001788.. data:: OID_ISSUER_ALTERNATIVE_NAME
1789
1790 Corresponds to the dotted string ``"2.5.29.18"``. The identifier for the
1791 :class:`IssuerAlternativeName` extension type.
1792
Paul Kehrerd4f632e2015-05-12 08:25:42 -05001793.. data:: OID_SUBJECT_KEY_IDENTIFIER
1794
1795 Corresponds to the dotted string ``"2.5.29.14"``. The identifier for the
1796 :class:`SubjectKeyIdentifier` extension type.
1797
Paul Kehrere0017be2015-05-17 20:39:40 -06001798.. data:: OID_NAME_CONSTRAINTS
1799
1800 Corresponds to the dotted string ``"2.5.29.30"``. The identifier for the
1801 :class:`NameConstraints` extension type.
1802
Paul Kehrerd4f632e2015-05-12 08:25:42 -05001803.. data:: OID_CRL_DISTRIBUTION_POINTS
1804
1805 Corresponds to the dotted string ``"2.5.29.31"``. The identifier for the
1806 :class:`CRLDistributionPoints` extension type.
1807
1808.. data:: OID_CERTIFICATE_POLICIES
1809
1810 Corresponds to the dotted string ``"2.5.29.32"``. The identifier for the
1811 :class:`CertificatePolicies` extension type.
1812
1813.. data:: OID_AUTHORITY_KEY_IDENTIFIER
1814
1815 Corresponds to the dotted string ``"2.5.29.35"``. The identifier for the
1816 :class:`AuthorityKeyIdentifier` extension type.
1817
1818.. data:: OID_EXTENDED_KEY_USAGE
1819
1820 Corresponds to the dotted string ``"2.5.29.37"``. The identifier for the
1821 :class:`ExtendedKeyUsage` extension type.
1822
1823.. data:: OID_AUTHORITY_INFORMATION_ACCESS
1824
1825 Corresponds to the dotted string ``"1.3.6.1.5.5.7.1.1"``. The identifier
1826 for the :class:`AuthorityInformationAccess` extension type.
Paul Kehrer56da2a52015-02-11 23:35:07 -06001827
Paul Kehrerb33de932015-08-06 23:41:05 +01001828.. data:: OID_INHIBIT_ANY_POLICY
1829
1830 Corresponds to the dotted string ``"2.5.29.54"``. The identifier
1831 for the :class:`InhibitAnyPolicy` extension type.
1832
Paul Kehrer4a1038e2015-05-18 10:28:31 -07001833.. data:: OID_OCSP_NO_CHECK
1834
1835 Corresponds to the dotted string ``"1.3.6.1.5.5.7.48.1.5"``. The identifier
1836 for the :class:`OCSPNoCheck` extension type.
1837
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001838Exceptions
1839~~~~~~~~~~
1840
Paul Kehrere76cd272014-12-14 19:00:51 -06001841.. class:: InvalidVersion
Paul Kehrera68fd332014-11-27 07:08:40 -10001842
1843 This is raised when an X.509 certificate has an invalid version number.
Paul Kehrer016e08a2014-11-26 09:41:18 -10001844
Paul Kehrerd5cccf72014-12-15 17:20:33 -06001845 .. attribute:: parsed_version
1846
Paul Kehrerbbffc402014-12-17 13:33:55 -06001847 :type: int
1848
1849 Returns the raw version that was parsed from the certificate.
Paul Kehrerd5cccf72014-12-15 17:20:33 -06001850
Paul Kehrerfbb7ac82015-03-16 19:26:29 -05001851.. class:: DuplicateExtension
1852
1853 This is raised when more than one X.509 extension of the same type is
1854 found within a certificate.
1855
1856 .. attribute:: oid
1857
1858 :type: :class:`ObjectIdentifier`
1859
1860 Returns the OID.
1861
1862.. class:: UnsupportedExtension
1863
1864 This is raised when a certificate contains an unsupported extension type.
1865
1866 .. attribute:: oid
1867
1868 :type: :class:`ObjectIdentifier`
1869
1870 Returns the OID.
1871
Paul Kehrerfa56a232015-03-17 13:14:03 -05001872.. class:: ExtensionNotFound
1873
1874 This is raised when calling :meth:`Extensions.get_extension_for_oid` with
1875 an extension OID that is not present in the certificate.
1876
1877 .. attribute:: oid
1878
1879 :type: :class:`ObjectIdentifier`
1880
1881 Returns the OID.
1882
Paul Kehrer9089c912015-04-20 22:15:20 -05001883.. class:: UnsupportedGeneralNameType
1884
1885 This is raised when a certificate contains an unsupported general name
1886 type in an extension.
1887
Paul Kehrerbed07352015-04-21 08:31:10 -05001888 .. attribute:: type
1889
Paul Kehrer0a621bf2015-04-22 09:22:56 -05001890 :type: int
1891
1892 The integer value of the unsupported type. The complete list of
1893 types can be found in `RFC 5280 section 4.2.1.6`_.
Paul Kehrerbed07352015-04-21 08:31:10 -05001894
Paul Kehrer016e08a2014-11-26 09:41:18 -10001895
Paul Kehrerc7c9a432015-04-19 09:20:13 -05001896.. _`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 -05001897.. _`RFC 5280 section 4.2.1.6`: https://tools.ietf.org/html/rfc5280#section-4.2.1.6