blob: 7e84b4923d3bb7b9853e52bab4461256b0f1e6bc [file] [log] [blame]
Paul Kehrer016e08a2014-11-26 09:41:18 -10001X.509
2=====
3
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 Kehrerd3dafbd2015-03-15 16:24:18 -050089X.509 is an ITU-T standard for a `public key infrastructure`_. X.509v3 is
90defined in :rfc:`5280` (which obsoletes :rfc:`2459` and :rfc:`3280`). X.509
91certificates are commonly used in protocols like `TLS`_.
Paul Kehrerb2de9482014-12-11 14:54:48 -060092
93Loading Certificates
94~~~~~~~~~~~~~~~~~~~~
Paul Kehrer016e08a2014-11-26 09:41:18 -100095
96.. function:: load_pem_x509_certificate(data, backend)
97
98 .. versionadded:: 0.7
99
Paul Kehrere76cd272014-12-14 19:00:51 -0600100 Deserialize a certificate from PEM encoded data. PEM certificates are
101 base64 decoded and have delimiters that look like
102 ``-----BEGIN CERTIFICATE-----``.
Paul Kehrer016e08a2014-11-26 09:41:18 -1000103
104 :param bytes data: The PEM encoded certificate data.
105
106 :param backend: A backend supporting the
107 :class:`~cryptography.hazmat.backends.interfaces.X509Backend`
108 interface.
109
Paul Kehrere76cd272014-12-14 19:00:51 -0600110 :returns: An instance of :class:`~cryptography.x509.Certificate`.
Paul Kehrer016e08a2014-11-26 09:41:18 -1000111
112.. function:: load_der_x509_certificate(data, backend)
113
114 .. versionadded:: 0.7
115
Paul Kehrere76cd272014-12-14 19:00:51 -0600116 Deserialize a certificate from DER encoded data. DER is a binary format
Paul Kehrer92aac382014-12-15 16:25:28 -0600117 and is commonly found in files with the ``.cer`` extension (although file
118 extensions are not a guarantee of encoding type).
Paul Kehrer016e08a2014-11-26 09:41:18 -1000119
120 :param bytes data: The DER encoded certificate data.
121
122 :param backend: A backend supporting the
123 :class:`~cryptography.hazmat.backends.interfaces.X509Backend`
124 interface.
125
Paul Kehrere76cd272014-12-14 19:00:51 -0600126 :returns: An instance of :class:`~cryptography.x509.Certificate`.
Paul Kehrer016e08a2014-11-26 09:41:18 -1000127
Paul Kehrer016e08a2014-11-26 09:41:18 -1000128.. doctest::
129
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600130 >>> from cryptography import x509
Paul Kehrer016e08a2014-11-26 09:41:18 -1000131 >>> from cryptography.hazmat.backends import default_backend
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600132 >>> cert = x509.load_pem_x509_certificate(pem_data, default_backend())
Paul Kehrer016e08a2014-11-26 09:41:18 -1000133 >>> cert.serial
134 2
135
Paul Kehrera1a1f232015-03-15 15:34:35 -0500136Loading Certificate Signing Requests
137~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600138
Paul Kehrer31e39882015-03-11 11:37:04 -0500139.. function:: load_pem_x509_csr(data, backend)
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600140
141 .. versionadded:: 0.9
142
Paul Kehrera1a1f232015-03-15 15:34:35 -0500143 Deserialize a certificate signing request (CSR) from PEM encoded data. PEM
Paul Kehrer5aadb9c2015-03-11 20:48:42 -0500144 requests are base64 decoded and have delimiters that look like
Paul Kehrerd3dafbd2015-03-15 16:24:18 -0500145 ``-----BEGIN CERTIFICATE REQUEST-----``. This format is also known as
146 PKCS#10.
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600147
148 :param bytes data: The PEM encoded request data.
149
150 :param backend: A backend supporting the
151 :class:`~cryptography.hazmat.backends.interfaces.X509Backend`
152 interface.
153
Paul Kehrera1a1f232015-03-15 15:34:35 -0500154 :returns: An instance of
155 :class:`~cryptography.x509.CertificateSigningRequest`.
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600156
Paul Kehrer1effb6e2015-03-30 15:05:59 -0500157.. function:: load_der_x509_csr(data, backend)
158
159 .. versionadded:: 0.9
160
161 Deserialize a certificate signing request (CSR) from DER encoded data. DER
162 is a binary format and is not commonly used with CSRs.
163
164 :param bytes data: The DER encoded request data.
165
166 :param backend: A backend supporting the
167 :class:`~cryptography.hazmat.backends.interfaces.X509Backend`
168 interface.
169
170 :returns: An instance of
171 :class:`~cryptography.x509.CertificateSigningRequest`.
172
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600173.. doctest::
174
175 >>> from cryptography import x509
176 >>> from cryptography.hazmat.backends import default_backend
177 >>> from cryptography.hazmat.primitives import hashes
Paul Kehrera1a1f232015-03-15 15:34:35 -0500178 >>> csr = x509.load_pem_x509_csr(pem_req_data, default_backend())
179 >>> isinstance(csr.signature_hash_algorithm, hashes.SHA1)
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600180 True
181
Paul Kehrere76cd272014-12-14 19:00:51 -0600182X.509 Certificate Object
183~~~~~~~~~~~~~~~~~~~~~~~~
Paul Kehrerb2de9482014-12-11 14:54:48 -0600184
Paul Kehrere76cd272014-12-14 19:00:51 -0600185.. class:: Certificate
Paul Kehrerb2de9482014-12-11 14:54:48 -0600186
187 .. versionadded:: 0.7
188
189 .. attribute:: version
190
Paul Kehrere76cd272014-12-14 19:00:51 -0600191 :type: :class:`~cryptography.x509.Version`
Paul Kehrerb2de9482014-12-11 14:54:48 -0600192
Paul Kehrere76cd272014-12-14 19:00:51 -0600193 The certificate version as an enumeration. Version 3 certificates are
194 the latest version and also the only type you should see in practice.
Paul Kehrerb2de9482014-12-11 14:54:48 -0600195
Alex Gaynor89c4dc82014-12-16 16:49:33 -0800196 :raises cryptography.x509.InvalidVersion: If the version in the
Alex Gaynor6d7ab4c2014-12-16 16:50:33 -0800197 certificate is not a known
198 :class:`X.509 version <cryptography.x509.Version>`.
Paul Kehrer92aac382014-12-15 16:25:28 -0600199
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600200 .. doctest::
201
202 >>> cert.version
203 <Version.v3: 2>
204
Paul Kehrerb2de9482014-12-11 14:54:48 -0600205 .. method:: fingerprint(algorithm)
206
207 :param algorithm: The
Paul Kehrer601278a2015-02-12 12:51:00 -0600208 :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm`
Paul Kehrerb2de9482014-12-11 14:54:48 -0600209 that will be used to generate the fingerprint.
210
Erik Trauschke2dcce902015-05-14 16:12:24 -0700211 :return bytes: The fingerprint using the supplied hash algorithm, as
Paul Kehrerb2de9482014-12-11 14:54:48 -0600212 bytes.
213
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600214 .. doctest::
215
216 >>> from cryptography.hazmat.primitives import hashes
217 >>> cert.fingerprint(hashes.SHA256())
Paul Kehrer78a81502014-12-16 14:47:52 -0600218 '\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 -0600219
Paul Kehrerb2de9482014-12-11 14:54:48 -0600220 .. attribute:: serial
221
222 :type: int
223
224 The serial as a Python integer.
225
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600226 .. doctest::
227
228 >>> cert.serial
229 2
230
Paul Kehrerb2de9482014-12-11 14:54:48 -0600231 .. method:: public_key()
232
233 :type:
Alex Stapletonf79c2312014-12-30 12:50:14 +0000234 :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey` or
Paul Kehrer45efdbc2015-02-12 10:58:22 -0600235 :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPublicKey` or
236 :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey`
Paul Kehrerb2de9482014-12-11 14:54:48 -0600237
238 The public key associated with the certificate.
239
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600240 .. doctest::
241
Alex Stapletonf79c2312014-12-30 12:50:14 +0000242 >>> from cryptography.hazmat.primitives.asymmetric import rsa
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600243 >>> public_key = cert.public_key()
Alex Stapletonf79c2312014-12-30 12:50:14 +0000244 >>> isinstance(public_key, rsa.RSAPublicKey)
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600245 True
246
Paul Kehrerb2de9482014-12-11 14:54:48 -0600247 .. attribute:: not_valid_before
248
249 :type: :class:`datetime.datetime`
250
Paul Kehrer78a81502014-12-16 14:47:52 -0600251 A naïve datetime representing the beginning of the validity period for
252 the certificate in UTC. This value is inclusive.
Paul Kehrerb2de9482014-12-11 14:54:48 -0600253
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600254 .. doctest::
255
256 >>> cert.not_valid_before
257 datetime.datetime(2010, 1, 1, 8, 30)
258
Paul Kehrerb2de9482014-12-11 14:54:48 -0600259 .. attribute:: not_valid_after
260
261 :type: :class:`datetime.datetime`
262
Paul Kehrer78a81502014-12-16 14:47:52 -0600263 A naïve datetime representing the end of the validity period for the
264 certificate in UTC. This value is inclusive.
Paul Kehrerb2de9482014-12-11 14:54:48 -0600265
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600266 .. doctest::
267
268 >>> cert.not_valid_after
269 datetime.datetime(2030, 12, 31, 8, 30)
270
Paul Kehrer719d5362015-01-01 20:03:52 -0600271 .. attribute:: issuer
272
273 .. versionadded:: 0.8
274
275 :type: :class:`Name`
276
277 The :class:`Name` of the issuer.
278
279 .. attribute:: subject
280
281 .. versionadded:: 0.8
282
283 :type: :class:`Name`
284
285 The :class:`Name` of the subject.
286
Paul Kehrer8802a5b2015-02-13 12:06:57 -0600287 .. attribute:: signature_hash_algorithm
Paul Kehrer56da2a52015-02-11 23:35:07 -0600288
Paul Kehrer8802a5b2015-02-13 12:06:57 -0600289 :type: :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm`
Paul Kehrer56da2a52015-02-11 23:35:07 -0600290
Paul Kehrere612ec72015-02-16 14:33:35 -0600291 Returns the
Paul Kehrer71d40c62015-02-19 08:21:04 -0600292 :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` which
Paul Kehrer1a7ba872015-02-19 18:09:05 -0600293 was used in signing this certificate.
Paul Kehrer56da2a52015-02-11 23:35:07 -0600294
295 .. doctest::
296
Paul Kehrer8802a5b2015-02-13 12:06:57 -0600297 >>> from cryptography.hazmat.primitives import hashes
298 >>> isinstance(cert.signature_hash_algorithm, hashes.SHA256)
299 True
Paul Kehrer719d5362015-01-01 20:03:52 -0600300
Paul Kehrerfbb7ac82015-03-16 19:26:29 -0500301 .. attribute:: extensions
302
303 :type: :class:`Extensions`
304
305 The extensions encoded in the certificate.
306
307 :raises cryptography.x509.DuplicateExtension: If more than one
308 extension of the same type is found within the certificate.
309
Paul Kehrerd8fc0be2015-04-21 08:31:10 -0500310 :raises cryptography.x509.UnsupportedExtension: If the certificate
311 contains an extension that is not supported.
312
Paul Kehrerbed07352015-04-21 08:31:10 -0500313 :raises cryptography.x509.UnsupportedGeneralNameType: If an extension
314 contains a general name that is not supported.
315
Paul Kehrerb8968812015-05-15 09:01:34 -0700316 :raises UnicodeError: If an extension contains IDNA encoding that is
317 invalid or not compliant with IDNA 2008.
318
Paul Kehrerfa56a232015-03-17 13:14:03 -0500319 .. doctest::
320
321 >>> for ext in cert.extensions:
322 ... print(ext)
Paul Kehrerd774de92015-05-03 10:52:25 -0500323 <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 -0400324 <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 -0400325 <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 -0500326 <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 -0500327 <Extension(oid=<ObjectIdentifier(oid=2.5.29.19, name=basicConstraints)>, critical=True, value=<BasicConstraints(ca=True, path_length=None)>)>
328
Andre Carona8aded62015-05-19 20:11:57 -0400329 .. method:: public_bytes(encoding)
330
331 :param encoding: The
332 :class:`~cryptography.hazmat.primitives.serialization.Encoding`
333 that will be used to serialize the certificate.
334
335 :return bytes: The data that can be written to a file or sent
336 over the network to be verified by clients.
337
Erik Trauschke2dcce902015-05-14 16:12:24 -0700338X.509 CRL (Certificate Revocation List) Object
339~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
340
341.. class:: CertificateRevocationList
342
343 .. versionadded:: 1.0
344
345 .. method:: fingerprint(algorithm)
346
347 :param algorithm: The
348 :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm`
349 that will be used to generate the fingerprint.
350
351 :return bytes: The fingerprint using the supplied hash algorithm, as
352 bytes.
353
354 .. attribute:: signature_hash_algorithm
355
356 :type: :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm`
357
358 Returns the
359 :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` which
360 was used in signing this CRL.
361
362 .. attribute:: issuer
363
364 :type: :class:`Name`
365
366 The :class:`Name` of the issuer.
367
368 .. attribute:: next_update
369
370 :type: :class:`datetime.datetime`
371
372 A naïve datetime representing when the next update to this CRL is
373 expected.
374
375 .. attribute:: last_update
376
377 :type: :class:`datetime.datetime`
378
379 A naïve datetime representing when the this CRL was last updated.
380
Erik Trauschkeabb7b6e2015-05-27 15:07:35 -0700381 .. attribute:: revoked_certificates
Erik Trauschke2dcce902015-05-14 16:12:24 -0700382
383 :type: list of :class:`RevokedCertificate`
384
385 The revoked certificates listed in this CRL.
386
387 .. attribute:: extensions
388
389 :type: :class:`Extensions`
390
391 The extensions encoded in the CRL.
392
Erik Trauschkeabb7b6e2015-05-27 15:07:35 -0700393 .. method:: verify(public_key)
Erik Trauschke2dcce902015-05-14 16:12:24 -0700394
Erik Trauschkeabb7b6e2015-05-27 15:07:35 -0700395 :param public_key: The
Erik Trauschke2dcce902015-05-14 16:12:24 -0700396 :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey` or
397 :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPublicKey` or
398 :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey`
399 that will be used to verify the CRL.
400
401 :return boolean: The result of the verification as boolean value.
402
Paul Kehrer5aadb9c2015-03-11 20:48:42 -0500403X.509 CSR (Certificate Signing Request) Object
404~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600405
Paul Kehrera1a1f232015-03-15 15:34:35 -0500406.. class:: CertificateSigningRequest
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600407
408 .. versionadded:: 0.9
409
410 .. method:: public_key()
411
412 :type:
413 :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey` or
414 :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPublicKey` or
415 :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey`
416
417 The public key associated with the request.
418
419 .. doctest::
420
421 >>> from cryptography.hazmat.primitives.asymmetric import rsa
Paul Kehrera1a1f232015-03-15 15:34:35 -0500422 >>> public_key = csr.public_key()
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600423 >>> isinstance(public_key, rsa.RSAPublicKey)
424 True
425
426 .. attribute:: subject
427
428 :type: :class:`Name`
429
430 The :class:`Name` of the subject.
431
432 .. attribute:: signature_hash_algorithm
433
434 :type: :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm`
435
436 Returns the
437 :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` which
438 was used in signing this request.
439
440 .. doctest::
441
442 >>> from cryptography.hazmat.primitives import hashes
Paul Kehrera1a1f232015-03-15 15:34:35 -0500443 >>> isinstance(csr.signature_hash_algorithm, hashes.SHA1)
Paul Kehrerdc480ad2015-02-23 12:14:54 -0600444 True
445
Andre Caron476c5df2015-05-18 10:23:28 -0400446 .. method:: public_bytes(encoding)
447
448 :param encoding: The
449 :class:`~cryptography.hazmat.primitives.serialization.Encoding`
450 that will be used to serialize the certificate request.
451
452 :return bytes: The data that can be written to a file or sent
453 over the network to be signed by the certificate
454 authority.
455
Erik Trauschke2dcce902015-05-14 16:12:24 -0700456X.509 Revoked Certificate Object
457~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
458
459.. class:: RevokedCertificate
460
461 .. versionadded:: 1.0
462
463 .. attribute:: serial_number
464
465 :type: :class:`int`
466
467 An integer representing the serial number of the revoked certificate.
468
469 .. attribute:: revocation_date
470
471 :type: :class:`datetime.datetime`
472
473 A naïve datetime representing the date this certificates was revoked.
474
475 .. attribute:: extensions
476
477 :type: :class:`Extensions`
478
479 The extensions encoded in the revoked certificate.
Andre Caron476c5df2015-05-18 10:23:28 -0400480
Paul Kehrer719d5362015-01-01 20:03:52 -0600481.. class:: Name
482
483 .. versionadded:: 0.8
484
Paul Kehrer53d8d492015-02-13 18:47:30 -0600485 An X509 Name is an ordered list of attributes. The object is iterable to
Paul Kehrerd21596e2015-02-14 09:17:26 -0600486 get every attribute or you can use :meth:`Name.get_attributes_for_oid` to
Paul Kehrer719d5362015-01-01 20:03:52 -0600487 obtain the specific type you want. Names are sometimes represented as a
Paul Kehrer53d8d492015-02-13 18:47:30 -0600488 slash or comma delimited string (e.g. ``/CN=mydomain.com/O=My Org/C=US`` or
489 ``CN=mydomain.com, O=My Org, C=US``).
Paul Kehrer719d5362015-01-01 20:03:52 -0600490
Paul Kehrer53d8d492015-02-13 18:47:30 -0600491 .. doctest::
Paul Kehrer719d5362015-01-01 20:03:52 -0600492
Paul Kehrer8b21a4a2015-02-14 07:56:36 -0600493 >>> len(cert.subject)
Paul Kehrer53d8d492015-02-13 18:47:30 -0600494 3
Paul Kehrer8b21a4a2015-02-14 07:56:36 -0600495 >>> for attribute in cert.subject:
496 ... print(attribute)
497 <NameAttribute(oid=<ObjectIdentifier(oid=2.5.4.6, name=countryName)>, value=u'US')>
498 <NameAttribute(oid=<ObjectIdentifier(oid=2.5.4.10, name=organizationName)>, value=u'Test Certificates 2011')>
499 <NameAttribute(oid=<ObjectIdentifier(oid=2.5.4.3, name=commonName)>, value=u'Good CA')>
Paul Kehrer719d5362015-01-01 20:03:52 -0600500
Paul Kehrere901d642015-02-11 18:50:58 -0600501 .. method:: get_attributes_for_oid(oid)
Paul Kehrer719d5362015-01-01 20:03:52 -0600502
Paul Kehrere901d642015-02-11 18:50:58 -0600503 :param oid: An :class:`ObjectIdentifier` instance.
Paul Kehrer719d5362015-01-01 20:03:52 -0600504
Paul Kehrere901d642015-02-11 18:50:58 -0600505 :returns: A list of :class:`NameAttribute` instances that match the
506 OID provided. If nothing matches an empty list will be returned.
Paul Kehrer719d5362015-01-01 20:03:52 -0600507
508 .. doctest::
509
Paul Kehrere901d642015-02-11 18:50:58 -0600510 >>> cert.subject.get_attributes_for_oid(x509.OID_COMMON_NAME)
511 [<NameAttribute(oid=<ObjectIdentifier(oid=2.5.4.3, name=commonName)>, value=u'Good CA')>]
Paul Kehrerb2de9482014-12-11 14:54:48 -0600512
Paul Kehrere76cd272014-12-14 19:00:51 -0600513.. class:: Version
Paul Kehrer016e08a2014-11-26 09:41:18 -1000514
515 .. versionadded:: 0.7
516
517 An enumeration for X.509 versions.
518
519 .. attribute:: v1
520
521 For version 1 X.509 certificates.
522
523 .. attribute:: v3
524
525 For version 3 X.509 certificates.
526
Paul Kehrer806bfb22015-02-02 17:05:24 -0600527.. class:: NameAttribute
Paul Kehrer912d3fb2015-01-29 11:19:22 -0600528
529 .. versionadded:: 0.8
530
Paul Kehrer834d22f2015-02-06 11:01:07 -0600531 An X.509 name consists of a list of NameAttribute instances.
Paul Kehrer5b0a8d62015-01-30 20:05:55 -0600532
Paul Kehrer912d3fb2015-01-29 11:19:22 -0600533 .. attribute:: oid
534
535 :type: :class:`ObjectIdentifier`
536
537 The attribute OID.
538
539 .. attribute:: value
540
Paul Kehrerd5852cb2015-01-30 08:25:23 -0600541 :type: :term:`text`
Paul Kehrer912d3fb2015-01-29 11:19:22 -0600542
543 The value of the attribute.
544
545.. class:: ObjectIdentifier
546
547 .. versionadded:: 0.8
548
Paul Kehrer5b0a8d62015-01-30 20:05:55 -0600549 Object identifiers (frequently seen abbreviated as OID) identify the type
Paul Kehrer806bfb22015-02-02 17:05:24 -0600550 of a value (see: :class:`NameAttribute`).
Paul Kehrer5b0a8d62015-01-30 20:05:55 -0600551
Paul Kehrerd44f9a62015-02-04 14:47:34 -0600552 .. attribute:: dotted_string
Paul Kehrer912d3fb2015-01-29 11:19:22 -0600553
554 :type: :class:`str`
555
Paul Kehrerfedf4f42015-02-06 11:22:07 -0600556 The dotted string value of the OID (e.g. ``"2.5.4.3"``)
Paul Kehrer912d3fb2015-01-29 11:19:22 -0600557
Paul Kehrer31bdf792015-03-25 14:11:00 -0500558.. _general_name_classes:
559
560General Name Classes
561~~~~~~~~~~~~~~~~~~~~
562
563.. class:: GeneralName
564
565 .. versionadded:: 0.9
566
567 This is the generic interface that all the following classes are registered
568 against.
569
570.. class:: RFC822Name
571
572 .. versionadded:: 0.9
573
574 This corresponds to an email address. For example, ``user@example.com``.
575
576 .. attribute:: value
577
578 :type: :term:`text`
579
580.. class:: DNSName
581
582 .. versionadded:: 0.9
583
584 This corresponds to a domain name. For example, ``cryptography.io``.
585
586 .. attribute:: value
587
588 :type: :term:`text`
589
590.. class:: DirectoryName
591
592 .. versionadded:: 0.9
593
594 This corresponds to a directory name.
595
596 .. attribute:: value
597
598 :type: :class:`Name`
599
600.. class:: UniformResourceIdentifier
601
602 .. versionadded:: 0.9
603
604 This corresponds to a uniform resource identifier. For example,
Paul Kehrerb8ef82e2015-04-22 16:04:24 -0500605 ``https://cryptography.io``. The URI is parsed and IDNA decoded (see
606 :rfc:`5895`).
607
608 .. note::
609
610 URIs that do not contain ``://`` in them will not be decoded.
Paul Kehrer31bdf792015-03-25 14:11:00 -0500611
612 .. attribute:: value
613
614 :type: :term:`text`
615
616.. class:: IPAddress
617
618 .. versionadded:: 0.9
619
620 This corresponds to an IP address.
621
622 .. attribute:: value
623
Paul Kehrereb177932015-05-17 18:33:33 -0700624 :type: :class:`~ipaddress.IPv4Address`,
625 :class:`~ipaddress.IPv6Address`, :class:`~ipaddress.IPv4Network`,
626 or :class:`~ipaddress.IPv6Network`.
Paul Kehrer31bdf792015-03-25 14:11:00 -0500627
628.. class:: RegisteredID
629
630 .. versionadded:: 0.9
631
632 This corresponds to a registered ID.
633
634 .. attribute:: value
635
636 :type: :class:`ObjectIdentifier`
637
Paul Kehrer8cf26422015-03-21 09:50:24 -0500638X.509 Extensions
639~~~~~~~~~~~~~~~~
640
Paul Kehrerfbb7ac82015-03-16 19:26:29 -0500641.. class:: Extensions
642
643 .. versionadded:: 0.9
644
645 An X.509 Extensions instance is an ordered list of extensions. The object
646 is iterable to get every extension.
647
Paul Kehrerfa56a232015-03-17 13:14:03 -0500648 .. method:: get_extension_for_oid(oid)
649
650 :param oid: An :class:`ObjectIdentifier` instance.
651
652 :returns: An instance of the extension class.
653
654 :raises cryptography.x509.ExtensionNotFound: If the certificate does
655 not have the extension requested.
656
Paul Kehrerfa56a232015-03-17 13:14:03 -0500657 .. doctest::
658
659 >>> cert.extensions.get_extension_for_oid(x509.OID_BASIC_CONSTRAINTS)
660 <Extension(oid=<ObjectIdentifier(oid=2.5.29.19, name=basicConstraints)>, critical=True, value=<BasicConstraints(ca=True, path_length=None)>)>
661
Paul Kehrer8cf26422015-03-21 09:50:24 -0500662.. class:: Extension
663
664 .. versionadded:: 0.9
665
Paul Kehrer85894662015-03-22 13:19:31 -0500666 .. attribute:: oid
667
668 :type: :class:`ObjectIdentifier`
669
Paul Kehrer5553d572015-03-23 21:08:01 -0500670 The :ref:`extension OID <extension_oids>`.
Paul Kehrer8cf26422015-03-21 09:50:24 -0500671
672 .. attribute:: critical
673
674 :type: bool
675
Paul Kehrer58b75692015-03-22 23:24:58 -0500676 Determines whether a given extension is critical or not. :rfc:`5280`
677 requires that "A certificate-using system MUST reject the certificate
678 if it encounters a critical extension it does not recognize or a
679 critical extension that contains information that it cannot process".
Paul Kehrer8cf26422015-03-21 09:50:24 -0500680
Paul Kehrer85894662015-03-22 13:19:31 -0500681 .. attribute:: value
682
683 Returns an instance of the extension type corresponding to the OID.
684
Paul Kehrercecbbba2015-03-30 14:58:38 -0500685.. class:: KeyUsage
686
687 .. versionadded:: 0.9
688
689 The key usage extension defines the purpose of the key contained in the
690 certificate. The usage restriction might be employed when a key that could
691 be used for more than one operation is to be restricted. It corresponds to
692 :data:`OID_KEY_USAGE`.
693
694 .. attribute:: digital_signature
695
696 :type: bool
697
Paul Kehrer738407b2015-04-01 22:39:02 -0500698 This purpose is set to true when the subject public key is used for verifying
Paul Kehrercecbbba2015-03-30 14:58:38 -0500699 digital signatures, other than signatures on certificates
700 (``key_cert_sign``) and CRLs (``crl_sign``).
701
702 .. attribute:: content_commitment
703
704 :type: bool
705
Paul Kehrer738407b2015-04-01 22:39:02 -0500706 This purpose is set to true when the subject public key is used for verifying
Paul Kehrercecbbba2015-03-30 14:58:38 -0500707 digital signatures, other than signatures on certificates
708 (``key_cert_sign``) and CRLs (``crl_sign``). It is used to provide a
709 non-repudiation service that protects against the signing entity
710 falsely denying some action. In the case of later conflict, a
711 reliable third party may determine the authenticity of the signed
712 data. This was called ``non_repudiation`` in older revisions of the
713 X.509 specification.
714
715 .. attribute:: key_encipherment
716
717 :type: bool
718
Paul Kehrer738407b2015-04-01 22:39:02 -0500719 This purpose is set to true when the subject public key is used for
720 enciphering private or secret keys.
Paul Kehrercecbbba2015-03-30 14:58:38 -0500721
722 .. attribute:: data_encipherment
723
724 :type: bool
725
Paul Kehrer738407b2015-04-01 22:39:02 -0500726 This purpose is set to true when the subject public key is used for
727 directly enciphering raw user data without the use of an intermediate
728 symmetric cipher.
Paul Kehrercecbbba2015-03-30 14:58:38 -0500729
730 .. attribute:: key_agreement
731
732 :type: bool
733
Paul Kehrer738407b2015-04-01 22:39:02 -0500734 This purpose is set to true when the subject public key is used for key
735 agreement. For example, when a Diffie-Hellman key is to be used for
736 key management, then this purpose is set to true.
Paul Kehrercecbbba2015-03-30 14:58:38 -0500737
738 .. attribute:: key_cert_sign
739
740 :type: bool
741
Paul Kehrer738407b2015-04-01 22:39:02 -0500742 This purpose is set to true when the subject public key is used for
743 verifying signatures on public key certificates. If this purpose is set
744 to true then ``ca`` must be true in the :class:`BasicConstraints`
745 extension.
Paul Kehrercecbbba2015-03-30 14:58:38 -0500746
747 .. attribute:: crl_sign
748
749 :type: bool
750
Paul Kehrer738407b2015-04-01 22:39:02 -0500751 This purpose is set to true when the subject public key is used for
752 verifying signatures on certificate revocation lists.
Paul Kehrercecbbba2015-03-30 14:58:38 -0500753
754 .. attribute:: encipher_only
755
756 :type: bool
757
Paul Kehrer738407b2015-04-01 22:39:02 -0500758 When this purposes is set to true and the ``key_agreement`` purpose is
759 also set, the subject public key may be used only for enciphering data
760 while performing key agreement.
Paul Kehrercecbbba2015-03-30 14:58:38 -0500761
762 :raises ValueError: This is raised if accessed when ``key_agreement``
763 is false.
764
765 .. attribute:: decipher_only
766
767 :type: bool
768
Paul Kehrer738407b2015-04-01 22:39:02 -0500769 When this purposes is set to true and the ``key_agreement`` purpose is
770 also set, the subject public key may be used only for deciphering data
771 while performing key agreement.
Paul Kehrercecbbba2015-03-30 14:58:38 -0500772
773 :raises ValueError: This is raised if accessed when ``key_agreement``
774 is false.
775
776
Paul Kehrer8cf26422015-03-21 09:50:24 -0500777.. class:: BasicConstraints
778
779 .. versionadded:: 0.9
780
Paul Kehrer85894662015-03-22 13:19:31 -0500781 Basic constraints is an X.509 extension type that defines whether a given
Paul Kehrer8cf26422015-03-21 09:50:24 -0500782 certificate is allowed to sign additional certificates and what path
Paul Kehrer85894662015-03-22 13:19:31 -0500783 length restrictions may exist. It corresponds to
784 :data:`OID_BASIC_CONSTRAINTS`.
Paul Kehrer8cf26422015-03-21 09:50:24 -0500785
786 .. attribute:: ca
787
788 :type: bool
789
790 Whether the certificate can sign certificates.
791
792 .. attribute:: path_length
793
Paul Kehrerfd1444c2015-03-21 19:47:05 -0500794 :type: int or None
Paul Kehrer8cf26422015-03-21 09:50:24 -0500795
796 The maximum path length for certificates subordinate to this
797 certificate. This attribute only has meaning if ``ca`` is true.
798 If ``ca`` is true then a path length of None means there's no
799 restriction on the number of subordinate CAs in the certificate chain.
Alex Gaynor99c5f152015-05-03 10:01:04 -0400800 If it is zero or greater then it defines the maximum length for a
801 subordinate CA's certificate chain. For example, a ``path_length`` of 1
802 means the certificate can sign a subordinate CA, but the subordinate CA
803 is not allowed to create subordinates with ``ca`` set to true.
Paul Kehrer8cf26422015-03-21 09:50:24 -0500804
Paul Kehrerffa2a152015-03-31 08:18:25 -0500805.. class:: ExtendedKeyUsage
806
807 .. versionadded:: 0.9
808
809 This extension indicates one or more purposes for which the certified
810 public key may be used, in addition to or in place of the basic
811 purposes indicated in the key usage extension. The object is
812 iterable to obtain the list of :ref:`extended key usage OIDs <eku_oids>`.
813
Paul Kehrer4a1038e2015-05-18 10:28:31 -0700814.. class:: OCSPNoCheck
815
816 .. versionadded:: 0.10
817
818 This presence of this extension indicates that an OCSP client can trust a
819 responder for the lifetime of the responder's certificate. CAs issuing
820 such a certificate should realize that a compromise of the responder's key
821 is as serious as the compromise of a CA key used to sign CRLs, at least for
822 the validity period of this certificate. CA's may choose to issue this type
823 of certificate with a very short lifetime and renew it frequently. This
824 extension is only relevant when the certificate is an authorized OCSP
825 responder.
826
Paul Kehrer2eb4ed92015-04-11 15:33:45 -0400827.. class:: AuthorityKeyIdentifier
828
829 .. versionadded:: 0.9
830
831 The authority key identifier extension provides a means of identifying the
832 public key corresponding to the private key used to sign a certificate.
Paul Kehrer8c8cd722015-04-19 09:15:04 -0500833 This extension is typically used to assist in determining the appropriate
834 certificate chain. For more information about generation and use of this
835 extension see `RFC 5280 section 4.2.1.1`_.
Paul Kehrer2eb4ed92015-04-11 15:33:45 -0400836
837 .. attribute:: key_identifier
838
839 :type: bytes
840
Paul Kehrer9104b1d2015-04-18 09:23:44 -0500841 A value derived from the public key used to verify the certificate's
Paul Kehrer8c8cd722015-04-19 09:15:04 -0500842 signature.
Paul Kehrer9104b1d2015-04-18 09:23:44 -0500843
Paul Kehrer2eb4ed92015-04-11 15:33:45 -0400844 .. attribute:: authority_cert_issuer
845
846 :type: :class:`Name` or None
847
Paul Kehrer9104b1d2015-04-18 09:23:44 -0500848 The :class:`Name` of the issuer's issuer.
849
Paul Kehrer2eb4ed92015-04-11 15:33:45 -0400850 .. attribute:: authority_cert_serial_number
851
852 :type: int or None
853
Paul Kehrer9104b1d2015-04-18 09:23:44 -0500854 The serial number of the issuer's issuer.
855
Paul Kehrer1eb82a62015-03-31 20:00:33 -0500856.. class:: SubjectKeyIdentifier
857
858 .. versionadded:: 0.9
859
860 The subject key identifier extension provides a means of identifying
861 certificates that contain a particular public key.
862
863 .. attribute:: digest
864
865 :type: bytes
866
867 The binary value of the identifier.
868
Paul Kehrer31bdf792015-03-25 14:11:00 -0500869.. class:: SubjectAlternativeName
870
871 .. versionadded:: 0.9
872
873 Subject alternative name is an X.509 extension that provides a list of
874 :ref:`general name <general_name_classes>` instances that provide a set
875 of identities for which the certificate is valid. The object is iterable to
876 get every element.
877
878 .. method:: get_values_for_type(type)
879
880 :param type: A :class:`GeneralName` provider. This is one of the
881 :ref:`general name classes <general_name_classes>`.
882
883 :returns: A list of values extracted from the matched general names.
884
Paul Kehrer93ae8052015-05-02 23:18:09 -0500885 .. doctest::
886
887 >>> from cryptography import x509
888 >>> from cryptography.hazmat.backends import default_backend
889 >>> from cryptography.hazmat.primitives import hashes
890 >>> cert = x509.load_pem_x509_certificate(cryptography_cert_pem, default_backend())
Paul Kehrerd0cd5072015-05-02 23:27:00 -0500891 >>> # Get the subjectAltName extension from the certificate
Paul Kehrer93ae8052015-05-02 23:18:09 -0500892 >>> ext = cert.extensions.get_extension_for_oid(x509.OID_SUBJECT_ALTERNATIVE_NAME)
Paul Kehrerd0cd5072015-05-02 23:27:00 -0500893 >>> # Get the dNSName entries from the SAN extension
894 >>> ext.value.get_values_for_type(x509.DNSName)
Paul Kehrer93ae8052015-05-02 23:18:09 -0500895 [u'www.cryptography.io', u'cryptography.io']
896
Paul Kehrer8cf26422015-03-21 09:50:24 -0500897
Paul Kehrer3e6d5582015-05-02 21:57:56 -0500898.. class:: AuthorityInformationAccess
899
900 .. versionadded:: 0.9
901
902 The authority information access extension indicates how to access
903 information and services for the issuer of the certificate in which
904 the extension appears. Information and services may include online
905 validation services (such as OCSP) and issuer data. It is an iterable,
906 containing one or more :class:`AccessDescription` instances.
907
908
909.. class:: AccessDescription
910
Paul Kehrer5a485522015-05-06 00:29:12 -0500911 .. versionadded:: 0.9
912
Paul Kehrer3e6d5582015-05-02 21:57:56 -0500913 .. attribute:: access_method
914
915 :type: :class:`ObjectIdentifier`
916
Paul Kehrerf506bca2015-05-02 22:31:47 -0500917 The access method defines what the ``access_location`` means. It must
918 be either :data:`OID_OCSP` or :data:`OID_CA_ISSUERS`. If it is
919 :data:`OID_OCSP` the access location will be where to obtain OCSP
920 information for the certificate. If it is :data:`OID_CA_ISSUERS` the
921 access location will provide additional information about the issuing
922 certificate.
Paul Kehrer3e6d5582015-05-02 21:57:56 -0500923
924 .. attribute:: access_location
925
926 :type: :class:`GeneralName`
927
Paul Kehrerf506bca2015-05-02 22:31:47 -0500928 Where to access the information defined by the access method.
929
Paul Kehrer5a485522015-05-06 00:29:12 -0500930.. class:: CRLDistributionPoints
931
932 .. versionadded:: 0.9
933
934 The CRL distribution points extension identifies how CRL information is
935 obtained. It is an iterable, containing one or more
936 :class:`DistributionPoint` instances.
937
938.. class:: DistributionPoint
939
940 .. versionadded:: 0.9
941
Paul Kehrer4e8dacd2015-05-09 10:38:23 -0500942 .. attribute:: full_name
Paul Kehrer5a485522015-05-06 00:29:12 -0500943
Paul Kehrer4e8dacd2015-05-09 10:38:23 -0500944 :type: list of :class:`GeneralName` instances or None
Paul Kehrer5a485522015-05-06 00:29:12 -0500945
Paul Kehrerf2c072b2015-05-09 17:04:28 -0500946 This field describes methods to retrieve the CRL. At most one of
947 ``full_name`` or ``relative_name`` will be non-None.
Paul Kehrer4e8dacd2015-05-09 10:38:23 -0500948
949 .. attribute:: relative_name
950
951 :type: :class:`Name` or None
952
953 This field describes methods to retrieve the CRL relative to the CRL
Paul Kehrerf2c072b2015-05-09 17:04:28 -0500954 issuer. At most one of ``full_name`` or ``relative_name`` will be
955 non-None.
Paul Kehrer5a485522015-05-06 00:29:12 -0500956
957 .. attribute:: crl_issuer
958
959 :type: list of :class:`GeneralName` instances or None
960
961 Information about the issuer of the CRL.
962
963 .. attribute:: reasons
964
Paul Kehrer3fd02602015-05-09 19:46:13 -0500965 :type: frozenset of :class:`ReasonFlags` or None
Paul Kehrer5a485522015-05-06 00:29:12 -0500966
967 The reasons a given distribution point may be used for when performing
968 revocation checks.
969
970.. class:: ReasonFlags
971
972 .. versionadded:: 0.9
973
Paul Kehrer4e8dacd2015-05-09 10:38:23 -0500974 An enumeration for CRL reasons.
975
976 .. attribute:: unspecified
977
978 It is unspecified why the certificate was revoked. This reason cannot
979 be used as a reason flag in a :class:`DistributionPoint`.
Paul Kehrer5a485522015-05-06 00:29:12 -0500980
981 .. attribute:: key_compromise
982
Paul Kehrer4e8dacd2015-05-09 10:38:23 -0500983 This reason indicates that the private key was compromised.
Paul Kehrer5a485522015-05-06 00:29:12 -0500984
985 .. attribute:: ca_compromise
986
Paul Kehrer4e8dacd2015-05-09 10:38:23 -0500987 This reason indicates that the CA issuing the certificate was
988 compromised.
Paul Kehrer5a485522015-05-06 00:29:12 -0500989
990 .. attribute:: affiliation_changed
991
Paul Kehrer4e8dacd2015-05-09 10:38:23 -0500992 This reason indicates that the subject's name or other information has
993 changed.
Paul Kehrer5a485522015-05-06 00:29:12 -0500994
995 .. attribute:: superseded
996
Paul Kehrer4e8dacd2015-05-09 10:38:23 -0500997 This reason indicates that a certificate has been superseded.
Paul Kehrer5a485522015-05-06 00:29:12 -0500998
999 .. attribute:: cessation_of_operation
1000
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05001001 This reason indicates that the certificate is no longer required.
Paul Kehrer5a485522015-05-06 00:29:12 -05001002
1003 .. attribute:: certificate_hold
1004
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05001005 This reason indicates that the certificate is on hold.
Paul Kehrer5a485522015-05-06 00:29:12 -05001006
1007 .. attribute:: privilege_withdrawn
1008
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05001009 This reason indicates that the privilege granted by this certificate
1010 have been withdrawn.
Paul Kehrer5a485522015-05-06 00:29:12 -05001011
1012 .. attribute:: aa_compromise
1013
Paul Kehrer4e8dacd2015-05-09 10:38:23 -05001014 When an attribute authority has been compromised.
1015
1016 .. attribute:: remove_from_crl
1017
1018 This reason indicates that the certificate was on hold and should be
1019 removed from the CRL. This reason cannot be used as a reason flag
1020 in a :class:`DistributionPoint`.
Paul Kehrer5a485522015-05-06 00:29:12 -05001021
Paul Kehrer0d210922015-04-28 17:31:07 -05001022.. class:: CertificatePolicies
1023
1024 .. versionadded:: 0.9
1025
Paul Kehrer2e879742015-05-02 23:09:56 -05001026 The certificate policies extension is an iterable, containing one or more
1027 :class:`PolicyInformation` instances.
Paul Kehrer0d210922015-04-28 17:31:07 -05001028
1029Certificate Policies Classes
1030~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1031
1032These classes may be present within a :class:`CertificatePolicies` instance.
1033
1034.. class:: PolicyInformation
1035
1036 .. versionadded:: 0.9
1037
1038 Contains a policy identifier and an optional list of qualifiers.
1039
1040 .. attribute:: policy_identifier
1041
1042 :type: :class:`ObjectIdentifier`
1043
1044 .. attribute:: policy_qualifiers
1045
1046 :type: list
1047
Paul Kehrerba35b3b2015-05-10 13:07:59 -05001048 A list consisting of :term:`text` and/or :class:`UserNotice` objects.
Paul Kehrer3f8ddeb2015-05-11 00:25:36 -05001049 If the value is text it is a pointer to the practice statement
1050 published by the certificate authority. If it is a user notice it is
1051 meant for display to the relying party when the certificate is
1052 used.
Paul Kehrer2e879742015-05-02 23:09:56 -05001053
Paul Kehrer0d210922015-04-28 17:31:07 -05001054.. class:: UserNotice
1055
1056 .. versionadded:: 0.9
1057
Paul Kehrer2e879742015-05-02 23:09:56 -05001058 User notices are intended for display to a relying party when a certificate
1059 is used. In practice, few if any UIs expose this data and it is a rarely
1060 encoded component.
1061
Paul Kehrer0d210922015-04-28 17:31:07 -05001062 .. attribute:: notice_reference
1063
1064 :type: :class:`NoticeReference` or None
1065
Paul Kehrer2e879742015-05-02 23:09:56 -05001066 The notice reference field names an organization and identifies,
1067 by number, a particular statement prepared by that organization.
1068
Paul Kehrer0d210922015-04-28 17:31:07 -05001069 .. attribute:: explicit_text
1070
Paul Kehrer2e879742015-05-02 23:09:56 -05001071 This field includes an arbitrary textual statement directly in the
1072 certificate.
1073
Paul Kehrer0d210922015-04-28 17:31:07 -05001074 :type: :term:`text`
1075
1076.. class:: NoticeReference
1077
Paul Kehrer2e879742015-05-02 23:09:56 -05001078 Notice reference can name an organization and provide information about
1079 notices related to the certificate. For example, it might identify the
1080 organization name and notice number 1. Application software could
1081 have a notice file containing the current set of notices for the named
1082 organization; the application would then extract the notice text from the
1083 file and display it. In practice this is rarely seen.
1084
Paul Kehrer0d210922015-04-28 17:31:07 -05001085 .. versionadded:: 0.9
1086
1087 .. attribute:: organization
1088
Paul Kehrer66c61702015-05-12 16:39:18 -05001089 :type: :term:`text`
Paul Kehrer0d210922015-04-28 17:31:07 -05001090
Paul Kehrer3f8ddeb2015-05-11 00:25:36 -05001091 .. attribute:: notice_numbers
Paul Kehrer0d210922015-04-28 17:31:07 -05001092
Paul Kehrer66c61702015-05-12 16:39:18 -05001093 :type: list
Paul Kehrer0d210922015-04-28 17:31:07 -05001094
Paul Kehrer66c61702015-05-12 16:39:18 -05001095 A list of integers.
Paul Kehrer0d210922015-04-28 17:31:07 -05001096
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001097Object Identifiers
1098~~~~~~~~~~~~~~~~~~
1099
Paul Kehrer4bb46492015-02-07 16:59:14 -06001100X.509 elements are frequently identified by :class:`ObjectIdentifier`
1101instances. The following common OIDs are available as constants.
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001102
Paul Kehrer56da2a52015-02-11 23:35:07 -06001103Name OIDs
1104~~~~~~~~~
1105
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001106.. data:: OID_COMMON_NAME
1107
Paul Kehrerfb5ac9e2015-02-07 16:29:37 -06001108 Corresponds to the dotted string ``"2.5.4.3"``. Historically the domain
1109 name would be encoded here for server certificates. :rfc:`2818` deprecates
1110 this practice and names of that type should now be located in a
Paul Kehrer4bb46492015-02-07 16:59:14 -06001111 SubjectAlternativeName extension. This OID is typically seen in X.509 names.
Paul Kehrer858b9b72015-02-05 09:50:31 -06001112
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001113.. data:: OID_COUNTRY_NAME
1114
Paul Kehrer4bb46492015-02-07 16:59:14 -06001115 Corresponds to the dotted string ``"2.5.4.6"``. This OID is typically seen
1116 in X.509 names.
Paul Kehrer858b9b72015-02-05 09:50:31 -06001117
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001118.. data:: OID_LOCALITY_NAME
1119
Paul Kehrer4bb46492015-02-07 16:59:14 -06001120 Corresponds to the dotted string ``"2.5.4.7"``. This OID is typically seen
1121 in X.509 names.
Paul Kehrer858b9b72015-02-05 09:50:31 -06001122
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001123.. data:: OID_STATE_OR_PROVINCE_NAME
1124
Paul Kehrer4bb46492015-02-07 16:59:14 -06001125 Corresponds to the dotted string ``"2.5.4.8"``. This OID is typically seen
1126 in X.509 names.
Paul Kehrer858b9b72015-02-05 09:50:31 -06001127
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001128.. data:: OID_ORGANIZATION_NAME
1129
Paul Kehrer4bb46492015-02-07 16:59:14 -06001130 Corresponds to the dotted string ``"2.5.4.10"``. This OID is typically seen
1131 in X.509 names.
Paul Kehrer858b9b72015-02-05 09:50:31 -06001132
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001133.. data:: OID_ORGANIZATIONAL_UNIT_NAME
1134
Paul Kehrer4bb46492015-02-07 16:59:14 -06001135 Corresponds to the dotted string ``"2.5.4.11"``. This OID is typically seen
1136 in X.509 names.
Paul Kehrer858b9b72015-02-05 09:50:31 -06001137
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001138.. data:: OID_SERIAL_NUMBER
1139
Paul Kehrerfb5ac9e2015-02-07 16:29:37 -06001140 Corresponds to the dotted string ``"2.5.4.5"``. This is distinct from the
1141 serial number of the certificate itself (which can be obtained with
Paul Kehrer4bb46492015-02-07 16:59:14 -06001142 :func:`Certificate.serial`). This OID is typically seen in X.509 names.
Paul Kehrer858b9b72015-02-05 09:50:31 -06001143
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001144.. data:: OID_SURNAME
1145
Paul Kehrer4bb46492015-02-07 16:59:14 -06001146 Corresponds to the dotted string ``"2.5.4.4"``. This OID is typically seen
1147 in X.509 names.
Paul Kehrer858b9b72015-02-05 09:50:31 -06001148
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001149.. data:: OID_GIVEN_NAME
1150
Paul Kehrer4bb46492015-02-07 16:59:14 -06001151 Corresponds to the dotted string ``"2.5.4.42"``. This OID is typically seen
1152 in X.509 names.
Paul Kehrer858b9b72015-02-05 09:50:31 -06001153
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001154.. data:: OID_TITLE
1155
Paul Kehrer4bb46492015-02-07 16:59:14 -06001156 Corresponds to the dotted string ``"2.5.4.12"``. This OID is typically seen
1157 in X.509 names.
Paul Kehrer858b9b72015-02-05 09:50:31 -06001158
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001159.. data:: OID_GENERATION_QUALIFIER
1160
Paul Kehrer4bb46492015-02-07 16:59:14 -06001161 Corresponds to the dotted string ``"2.5.4.44"``. This OID is typically seen
1162 in X.509 names.
Paul Kehrer858b9b72015-02-05 09:50:31 -06001163
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001164.. data:: OID_DN_QUALIFIER
1165
Paul Kehrerfb5ac9e2015-02-07 16:29:37 -06001166 Corresponds to the dotted string ``"2.5.4.46"``. This specifies
1167 disambiguating information to add to the relative distinguished name of an
Paul Kehrer4bb46492015-02-07 16:59:14 -06001168 entry. See :rfc:`2256`. This OID is typically seen in X.509 names.
Paul Kehrer858b9b72015-02-05 09:50:31 -06001169
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001170.. data:: OID_PSEUDONYM
1171
Paul Kehrer4bb46492015-02-07 16:59:14 -06001172 Corresponds to the dotted string ``"2.5.4.65"``. This OID is typically seen
1173 in X.509 names.
Paul Kehrer858b9b72015-02-05 09:50:31 -06001174
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001175.. data:: OID_DOMAIN_COMPONENT
1176
Paul Kehrerfb5ac9e2015-02-07 16:29:37 -06001177 Corresponds to the dotted string ``"0.9.2342.19200300.100.1.25"``. A string
Paul Kehrer4bb46492015-02-07 16:59:14 -06001178 holding one component of a domain name. See :rfc:`4519`. This OID is
1179 typically seen in X.509 names.
Paul Kehrer858b9b72015-02-05 09:50:31 -06001180
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001181.. data:: OID_EMAIL_ADDRESS
1182
Paul Kehrer4bb46492015-02-07 16:59:14 -06001183 Corresponds to the dotted string ``"1.2.840.113549.1.9.1"``. This OID is
1184 typically seen in X.509 names.
Paul Kehrer858b9b72015-02-05 09:50:31 -06001185
Paul Kehrer56da2a52015-02-11 23:35:07 -06001186Signature Algorithm OIDs
1187~~~~~~~~~~~~~~~~~~~~~~~~
1188
Paul Kehrer1a7ba872015-02-19 18:09:05 -06001189.. data:: OID_RSA_WITH_MD5
Paul Kehrer56da2a52015-02-11 23:35:07 -06001190
1191 Corresponds to the dotted string ``"1.2.840.113549.1.1.4"``. This is
1192 an MD5 digest signed by an RSA key.
1193
Paul Kehrer1a7ba872015-02-19 18:09:05 -06001194.. data:: OID_RSA_WITH_SHA1
Paul Kehrer56da2a52015-02-11 23:35:07 -06001195
1196 Corresponds to the dotted string ``"1.2.840.113549.1.1.5"``. This is
1197 a SHA1 digest signed by an RSA key.
1198
Paul Kehrer1a7ba872015-02-19 18:09:05 -06001199.. data:: OID_RSA_WITH_SHA224
Paul Kehrer56da2a52015-02-11 23:35:07 -06001200
1201 Corresponds to the dotted string ``"1.2.840.113549.1.1.14"``. This is
1202 a SHA224 digest signed by an RSA key.
1203
Paul Kehrer1a7ba872015-02-19 18:09:05 -06001204.. data:: OID_RSA_WITH_SHA256
Paul Kehrer56da2a52015-02-11 23:35:07 -06001205
1206 Corresponds to the dotted string ``"1.2.840.113549.1.1.11"``. This is
1207 a SHA256 digest signed by an RSA key.
1208
Paul Kehrer1a7ba872015-02-19 18:09:05 -06001209.. data:: OID_RSA_WITH_SHA384
Paul Kehrer56da2a52015-02-11 23:35:07 -06001210
1211 Corresponds to the dotted string ``"1.2.840.113549.1.1.12"``. This is
1212 a SHA384 digest signed by an RSA key.
1213
Paul Kehrer1a7ba872015-02-19 18:09:05 -06001214.. data:: OID_RSA_WITH_SHA512
Paul Kehrer56da2a52015-02-11 23:35:07 -06001215
1216 Corresponds to the dotted string ``"1.2.840.113549.1.1.13"``. This is
1217 a SHA512 digest signed by an RSA key.
1218
1219.. data:: OID_ECDSA_WITH_SHA224
1220
1221 Corresponds to the dotted string ``"1.2.840.10045.4.3.1"``. This is
1222 a SHA224 digest signed by an ECDSA key.
1223
1224.. data:: OID_ECDSA_WITH_SHA256
1225
1226 Corresponds to the dotted string ``"1.2.840.10045.4.3.2"``. This is
1227 a SHA256 digest signed by an ECDSA key.
1228
1229.. data:: OID_ECDSA_WITH_SHA384
1230
1231 Corresponds to the dotted string ``"1.2.840.10045.4.3.3"``. This is
1232 a SHA384 digest signed by an ECDSA key.
1233
1234.. data:: OID_ECDSA_WITH_SHA512
1235
1236 Corresponds to the dotted string ``"1.2.840.10045.4.3.4"``. This is
1237 a SHA512 digest signed by an ECDSA key.
1238
1239.. data:: OID_DSA_WITH_SHA1
1240
1241 Corresponds to the dotted string ``"1.2.840.10040.4.3"``. This is
1242 a SHA1 digest signed by a DSA key.
1243
1244.. data:: OID_DSA_WITH_SHA224
1245
1246 Corresponds to the dotted string ``"2.16.840.1.101.3.4.3.1"``. This is
1247 a SHA224 digest signed by a DSA key.
1248
1249.. data:: OID_DSA_WITH_SHA256
1250
Paul Kehrerfbb7ac82015-03-16 19:26:29 -05001251 Corresponds to the dotted string ``"2.16.840.1.101.3.4.3.2"``. This is
Paul Kehrer56da2a52015-02-11 23:35:07 -06001252 a SHA256 digest signed by a DSA key.
1253
Paul Kehrerffa2a152015-03-31 08:18:25 -05001254.. _eku_oids:
1255
Paul Kehrere1513fa2015-03-30 23:08:17 -05001256Extended Key Usage OIDs
1257~~~~~~~~~~~~~~~~~~~~~~~
1258
1259.. data:: OID_SERVER_AUTH
1260
1261 Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.1"``. This is used to
1262 denote that a certificate may be used for TLS web server authentication.
1263
1264.. data:: OID_CLIENT_AUTH
1265
1266 Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.2"``. This is used to
1267 denote that a certificate may be used for TLS web client authentication.
1268
1269.. data:: OID_CODE_SIGNING
1270
1271 Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.3"``. This is used to
1272 denote that a certificate may be used for code signing.
1273
1274.. data:: OID_EMAIL_PROTECTION
1275
1276 Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.4"``. This is used to
1277 denote that a certificate may be used for email protection.
1278
1279.. data:: OID_TIME_STAMPING
1280
1281 Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.8"``. This is used to
1282 denote that a certificate may be used for time stamping.
1283
1284.. data:: OID_OCSP_SIGNING
1285
1286 Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.9"``. This is used to
1287 denote that a certificate may be used for signing OCSP responses.
1288
Paul Kehrer3e6d5582015-05-02 21:57:56 -05001289Authority Information Access OIDs
1290~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1291
1292.. data:: OID_OCSP
1293
1294 Corresponds to the dotted string ``"1.3.6.1.5.5.7.48.1"``. Used as the
1295 identifier for OCSP data in :class:`AccessDescription` objects.
1296
1297.. data:: OID_CA_ISSUERS
1298
1299 Corresponds to the dotted string ``"1.3.6.1.5.5.7.48.2"``. Used as the
1300 identifier for CA issuer data in :class:`AccessDescription` objects.
1301
Paul Kehrer2e879742015-05-02 23:09:56 -05001302Policy Qualifier OIDs
1303~~~~~~~~~~~~~~~~~~~~~
1304
1305.. data:: OID_CPS_QUALIFIER
1306
Paul Kehrerba35b3b2015-05-10 13:07:59 -05001307 Corresponds to the dotted string ``"1.3.6.1.5.5.7.2.1"``.
Paul Kehrer2e879742015-05-02 23:09:56 -05001308
1309.. data:: OID_CPS_USER_NOTICE
1310
Paul Kehrerba35b3b2015-05-10 13:07:59 -05001311 Corresponds to the dotted string ``"1.3.6.1.5.5.7.2.2"``.
Paul Kehrer2e879742015-05-02 23:09:56 -05001312
Paul Kehrer5553d572015-03-23 21:08:01 -05001313.. _extension_oids:
1314
Paul Kehrer2bb94642015-03-21 09:54:17 -05001315Extension OIDs
1316~~~~~~~~~~~~~~
1317
1318.. data:: OID_BASIC_CONSTRAINTS
1319
1320 Corresponds to the dotted string ``"2.5.29.19"``. The identifier for the
Paul Kehrer611d3d32015-03-22 13:31:18 -05001321 :class:`BasicConstraints` extension type.
Paul Kehrer2bb94642015-03-21 09:54:17 -05001322
Paul Kehrercecbbba2015-03-30 14:58:38 -05001323.. data:: OID_KEY_USAGE
1324
1325 Corresponds to the dotted string ``"2.5.29.15"``. The identifier for the
1326 :class:`KeyUsage` extension type.
1327
Paul Kehrerd4f632e2015-05-12 08:25:42 -05001328.. data:: OID_SUBJECT_ALTERNATIVE_NAME
1329
1330 Corresponds to the dotted string ``"2.5.29.17"``. The identifier for the
1331 :class:`SubjectAlternativeName` extension type.
1332
1333.. data:: OID_SUBJECT_KEY_IDENTIFIER
1334
1335 Corresponds to the dotted string ``"2.5.29.14"``. The identifier for the
1336 :class:`SubjectKeyIdentifier` extension type.
1337
1338.. data:: OID_CRL_DISTRIBUTION_POINTS
1339
1340 Corresponds to the dotted string ``"2.5.29.31"``. The identifier for the
1341 :class:`CRLDistributionPoints` extension type.
1342
1343.. data:: OID_CERTIFICATE_POLICIES
1344
1345 Corresponds to the dotted string ``"2.5.29.32"``. The identifier for the
1346 :class:`CertificatePolicies` extension type.
1347
1348.. data:: OID_AUTHORITY_KEY_IDENTIFIER
1349
1350 Corresponds to the dotted string ``"2.5.29.35"``. The identifier for the
1351 :class:`AuthorityKeyIdentifier` extension type.
1352
1353.. data:: OID_EXTENDED_KEY_USAGE
1354
1355 Corresponds to the dotted string ``"2.5.29.37"``. The identifier for the
1356 :class:`ExtendedKeyUsage` extension type.
1357
1358.. data:: OID_AUTHORITY_INFORMATION_ACCESS
1359
1360 Corresponds to the dotted string ``"1.3.6.1.5.5.7.1.1"``. The identifier
1361 for the :class:`AuthorityInformationAccess` extension type.
Paul Kehrer56da2a52015-02-11 23:35:07 -06001362
Paul Kehrer4a1038e2015-05-18 10:28:31 -07001363.. data:: OID_OCSP_NO_CHECK
1364
1365 Corresponds to the dotted string ``"1.3.6.1.5.5.7.48.1.5"``. The identifier
1366 for the :class:`OCSPNoCheck` extension type.
1367
Paul Kehrer912d3fb2015-01-29 11:19:22 -06001368Exceptions
1369~~~~~~~~~~
1370
Paul Kehrere76cd272014-12-14 19:00:51 -06001371.. class:: InvalidVersion
Paul Kehrera68fd332014-11-27 07:08:40 -10001372
1373 This is raised when an X.509 certificate has an invalid version number.
Paul Kehrer016e08a2014-11-26 09:41:18 -10001374
Paul Kehrerd5cccf72014-12-15 17:20:33 -06001375 .. attribute:: parsed_version
1376
Paul Kehrerbbffc402014-12-17 13:33:55 -06001377 :type: int
1378
1379 Returns the raw version that was parsed from the certificate.
Paul Kehrerd5cccf72014-12-15 17:20:33 -06001380
Paul Kehrerfbb7ac82015-03-16 19:26:29 -05001381.. class:: DuplicateExtension
1382
1383 This is raised when more than one X.509 extension of the same type is
1384 found within a certificate.
1385
1386 .. attribute:: oid
1387
1388 :type: :class:`ObjectIdentifier`
1389
1390 Returns the OID.
1391
1392.. class:: UnsupportedExtension
1393
1394 This is raised when a certificate contains an unsupported extension type.
1395
1396 .. attribute:: oid
1397
1398 :type: :class:`ObjectIdentifier`
1399
1400 Returns the OID.
1401
Paul Kehrerfa56a232015-03-17 13:14:03 -05001402.. class:: ExtensionNotFound
1403
1404 This is raised when calling :meth:`Extensions.get_extension_for_oid` with
1405 an extension OID that is not present in the certificate.
1406
1407 .. attribute:: oid
1408
1409 :type: :class:`ObjectIdentifier`
1410
1411 Returns the OID.
1412
Paul Kehrer9089c912015-04-20 22:15:20 -05001413.. class:: UnsupportedGeneralNameType
1414
1415 This is raised when a certificate contains an unsupported general name
1416 type in an extension.
1417
Paul Kehrerbed07352015-04-21 08:31:10 -05001418 .. attribute:: type
1419
Paul Kehrer0a621bf2015-04-22 09:22:56 -05001420 :type: int
1421
1422 The integer value of the unsupported type. The complete list of
1423 types can be found in `RFC 5280 section 4.2.1.6`_.
Paul Kehrerbed07352015-04-21 08:31:10 -05001424
Paul Kehrer016e08a2014-11-26 09:41:18 -10001425
1426.. _`public key infrastructure`: https://en.wikipedia.org/wiki/Public_key_infrastructure
Paul Kehrera68fd332014-11-27 07:08:40 -10001427.. _`TLS`: https://en.wikipedia.org/wiki/Transport_Layer_Security
Paul Kehrerc7c9a432015-04-19 09:20:13 -05001428.. _`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 -05001429.. _`RFC 5280 section 4.2.1.6`: https://tools.ietf.org/html/rfc5280#section-4.2.1.6