blob: 44d53a455b90567dd0b60bbd037425188dcd5cf0 [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
6X.509 is an ITU-T standard for a `public key infrastructure`_. X.509v3 is
Paul Kehrera68fd332014-11-27 07:08:40 -10007defined in :rfc:`5280` (which obsoletes :rfc:`2459` and :rfc:`3280`). X.509
8certificates are commonly used in protocols like `TLS`_.
Paul Kehrer016e08a2014-11-26 09:41:18 -10009
Paul Kehrerb2de9482014-12-11 14:54:48 -060010
11Loading Certificates
12~~~~~~~~~~~~~~~~~~~~
Paul Kehrer016e08a2014-11-26 09:41:18 -100013
14.. function:: load_pem_x509_certificate(data, backend)
15
16 .. versionadded:: 0.7
17
Paul Kehrere76cd272014-12-14 19:00:51 -060018 Deserialize a certificate from PEM encoded data. PEM certificates are
19 base64 decoded and have delimiters that look like
20 ``-----BEGIN CERTIFICATE-----``.
Paul Kehrer016e08a2014-11-26 09:41:18 -100021
22 :param bytes data: The PEM encoded certificate data.
23
24 :param backend: A backend supporting the
25 :class:`~cryptography.hazmat.backends.interfaces.X509Backend`
26 interface.
27
Paul Kehrere76cd272014-12-14 19:00:51 -060028 :returns: An instance of :class:`~cryptography.x509.Certificate`.
Paul Kehrer016e08a2014-11-26 09:41:18 -100029
30.. function:: load_der_x509_certificate(data, backend)
31
32 .. versionadded:: 0.7
33
Paul Kehrere76cd272014-12-14 19:00:51 -060034 Deserialize a certificate from DER encoded data. DER is a binary format
Paul Kehrer92aac382014-12-15 16:25:28 -060035 and is commonly found in files with the ``.cer`` extension (although file
36 extensions are not a guarantee of encoding type).
Paul Kehrer016e08a2014-11-26 09:41:18 -100037
38 :param bytes data: The DER encoded certificate data.
39
40 :param backend: A backend supporting the
41 :class:`~cryptography.hazmat.backends.interfaces.X509Backend`
42 interface.
43
Paul Kehrere76cd272014-12-14 19:00:51 -060044 :returns: An instance of :class:`~cryptography.x509.Certificate`.
Paul Kehrer016e08a2014-11-26 09:41:18 -100045
46.. testsetup::
47
48 pem_data = b"""
49 -----BEGIN CERTIFICATE-----
50 MIIDfDCCAmSgAwIBAgIBAjANBgkqhkiG9w0BAQsFADBFMQswCQYDVQQGEwJVUzEf
51 MB0GA1UEChMWVGVzdCBDZXJ0aWZpY2F0ZXMgMjAxMTEVMBMGA1UEAxMMVHJ1c3Qg
52 QW5jaG9yMB4XDTEwMDEwMTA4MzAwMFoXDTMwMTIzMTA4MzAwMFowQDELMAkGA1UE
53 BhMCVVMxHzAdBgNVBAoTFlRlc3QgQ2VydGlmaWNhdGVzIDIwMTExEDAOBgNVBAMT
54 B0dvb2QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCQWJpHYo37
55 Xfb7oJSPe+WvfTlzIG21WQ7MyMbGtK/m8mejCzR6c+f/pJhEH/OcDSMsXq8h5kXa
56 BGqWK+vSwD/Pzp5OYGptXmGPcthDtAwlrafkGOS4GqIJ8+k9XGKs+vQUXJKsOk47
57 RuzD6PZupq4s16xaLVqYbUC26UcY08GpnoLNHJZS/EmXw1ZZ3d4YZjNlpIpWFNHn
58 UGmdiGKXUPX/9H0fVjIAaQwjnGAbpgyCumWgzIwPpX+ElFOUr3z7BoVnFKhIXze+
59 VmQGSWxZxvWDUN90Ul0tLEpLgk3OVxUB4VUGuf15OJOpgo1xibINPmWt14Vda2N9
60 yrNKloJGZNqLAgMBAAGjfDB6MB8GA1UdIwQYMBaAFOR9X9FclYYILAWuvnW2ZafZ
61 XahmMB0GA1UdDgQWBBRYAYQkG7wrUpRKPaUQchRR9a86yTAOBgNVHQ8BAf8EBAMC
62 AQYwFwYDVR0gBBAwDjAMBgpghkgBZQMCATABMA8GA1UdEwEB/wQFMAMBAf8wDQYJ
63 KoZIhvcNAQELBQADggEBADWHlxbmdTXNwBL/llwhQqwnazK7CC2WsXBBqgNPWj7m
64 tvQ+aLG8/50Qc2Sun7o2VnwF9D18UUe8Gj3uPUYH+oSI1vDdyKcjmMbKRU4rk0eo
65 3UHNDXwqIVc9CQS9smyV+x1HCwL4TTrq+LXLKx/qVij0Yqk+UJfAtrg2jnYKXsCu
66 FMBQQnWCGrwa1g1TphRp/RmYHnMynYFmZrXtzFz+U9XEA7C+gPq4kqDI/iVfIT1s
67 6lBtdB50lrDVwl2oYfAvW/6sC2se2QleZidUmrziVNP4oEeXINokU6T6p//HM1FG
68 QYw2jOvpKcKtWCSAnegEbgsGYzATKjmPJPJ0npHFqzM=
69 -----END CERTIFICATE-----
70 """.strip()
71
72.. doctest::
73
Paul Kehrercc8a26e2014-12-16 12:40:16 -060074 >>> from cryptography import x509
Paul Kehrer016e08a2014-11-26 09:41:18 -100075 >>> from cryptography.hazmat.backends import default_backend
Paul Kehrercc8a26e2014-12-16 12:40:16 -060076 >>> cert = x509.load_pem_x509_certificate(pem_data, default_backend())
Paul Kehrer016e08a2014-11-26 09:41:18 -100077 >>> cert.serial
78 2
79
Paul Kehrere76cd272014-12-14 19:00:51 -060080X.509 Certificate Object
81~~~~~~~~~~~~~~~~~~~~~~~~
Paul Kehrerb2de9482014-12-11 14:54:48 -060082
Paul Kehrere76cd272014-12-14 19:00:51 -060083.. class:: Certificate
Paul Kehrerb2de9482014-12-11 14:54:48 -060084
85 .. versionadded:: 0.7
86
87 .. attribute:: version
88
Paul Kehrere76cd272014-12-14 19:00:51 -060089 :type: :class:`~cryptography.x509.Version`
Paul Kehrerb2de9482014-12-11 14:54:48 -060090
Paul Kehrere76cd272014-12-14 19:00:51 -060091 The certificate version as an enumeration. Version 3 certificates are
92 the latest version and also the only type you should see in practice.
Paul Kehrerb2de9482014-12-11 14:54:48 -060093
Alex Gaynor89c4dc82014-12-16 16:49:33 -080094 :raises cryptography.x509.InvalidVersion: If the version in the
Alex Gaynor6d7ab4c2014-12-16 16:50:33 -080095 certificate is not a known
96 :class:`X.509 version <cryptography.x509.Version>`.
Paul Kehrer92aac382014-12-15 16:25:28 -060097
Paul Kehrercc8a26e2014-12-16 12:40:16 -060098 .. doctest::
99
100 >>> cert.version
101 <Version.v3: 2>
102
Paul Kehrerb2de9482014-12-11 14:54:48 -0600103 .. method:: fingerprint(algorithm)
104
105 :param algorithm: The
Paul Kehrer601278a2015-02-12 12:51:00 -0600106 :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm`
Paul Kehrerb2de9482014-12-11 14:54:48 -0600107 that will be used to generate the fingerprint.
108
109 :return bytes: The fingerprint using the supplied hash algorithm as
110 bytes.
111
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600112 .. doctest::
113
114 >>> from cryptography.hazmat.primitives import hashes
115 >>> cert.fingerprint(hashes.SHA256())
Paul Kehrer78a81502014-12-16 14:47:52 -0600116 '\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 -0600117
Paul Kehrerb2de9482014-12-11 14:54:48 -0600118 .. attribute:: serial
119
120 :type: int
121
122 The serial as a Python integer.
123
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600124 .. doctest::
125
126 >>> cert.serial
127 2
128
Paul Kehrerb2de9482014-12-11 14:54:48 -0600129 .. method:: public_key()
130
131 :type:
Alex Stapletonf79c2312014-12-30 12:50:14 +0000132 :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey` or
Paul Kehrer45efdbc2015-02-12 10:58:22 -0600133 :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPublicKey` or
134 :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey`
Paul Kehrerb2de9482014-12-11 14:54:48 -0600135
136 The public key associated with the certificate.
137
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600138 .. doctest::
139
Alex Stapletonf79c2312014-12-30 12:50:14 +0000140 >>> from cryptography.hazmat.primitives.asymmetric import rsa
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600141 >>> public_key = cert.public_key()
Alex Stapletonf79c2312014-12-30 12:50:14 +0000142 >>> isinstance(public_key, rsa.RSAPublicKey)
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600143 True
144
Paul Kehrerb2de9482014-12-11 14:54:48 -0600145 .. attribute:: not_valid_before
146
147 :type: :class:`datetime.datetime`
148
Paul Kehrer78a81502014-12-16 14:47:52 -0600149 A naïve datetime representing the beginning of the validity period for
150 the certificate in UTC. This value is inclusive.
Paul Kehrerb2de9482014-12-11 14:54:48 -0600151
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600152 .. doctest::
153
154 >>> cert.not_valid_before
155 datetime.datetime(2010, 1, 1, 8, 30)
156
Paul Kehrerb2de9482014-12-11 14:54:48 -0600157 .. attribute:: not_valid_after
158
159 :type: :class:`datetime.datetime`
160
Paul Kehrer78a81502014-12-16 14:47:52 -0600161 A naïve datetime representing the end of the validity period for the
162 certificate in UTC. This value is inclusive.
Paul Kehrerb2de9482014-12-11 14:54:48 -0600163
Paul Kehrercc8a26e2014-12-16 12:40:16 -0600164 .. doctest::
165
166 >>> cert.not_valid_after
167 datetime.datetime(2030, 12, 31, 8, 30)
168
Paul Kehrer719d5362015-01-01 20:03:52 -0600169 .. attribute:: issuer
170
171 .. versionadded:: 0.8
172
173 :type: :class:`Name`
174
175 The :class:`Name` of the issuer.
176
177 .. attribute:: subject
178
179 .. versionadded:: 0.8
180
181 :type: :class:`Name`
182
183 The :class:`Name` of the subject.
184
Paul Kehrer8802a5b2015-02-13 12:06:57 -0600185 .. attribute:: signature_hash_algorithm
Paul Kehrer56da2a52015-02-11 23:35:07 -0600186
Paul Kehrer8802a5b2015-02-13 12:06:57 -0600187 :type: :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm`
Paul Kehrer56da2a52015-02-11 23:35:07 -0600188
Paul Kehrere612ec72015-02-16 14:33:35 -0600189 Returns the
Paul Kehrer71d40c62015-02-19 08:21:04 -0600190 :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` which
Paul Kehrer1a7ba872015-02-19 18:09:05 -0600191 was used in signing this certificate.
Paul Kehrer56da2a52015-02-11 23:35:07 -0600192
193 .. doctest::
194
Paul Kehrer8802a5b2015-02-13 12:06:57 -0600195 >>> from cryptography.hazmat.primitives import hashes
196 >>> isinstance(cert.signature_hash_algorithm, hashes.SHA256)
197 True
Paul Kehrer719d5362015-01-01 20:03:52 -0600198
Paul Kehrerfbb7ac82015-03-16 19:26:29 -0500199 .. attribute:: extensions
200
201 :type: :class:`Extensions`
202
203 The extensions encoded in the certificate.
204
205 :raises cryptography.x509.DuplicateExtension: If more than one
206 extension of the same type is found within the certificate.
207
Paul Kehrer719d5362015-01-01 20:03:52 -0600208.. class:: Name
209
210 .. versionadded:: 0.8
211
Paul Kehrer53d8d492015-02-13 18:47:30 -0600212 An X509 Name is an ordered list of attributes. The object is iterable to
Paul Kehrerd21596e2015-02-14 09:17:26 -0600213 get every attribute or you can use :meth:`Name.get_attributes_for_oid` to
Paul Kehrer719d5362015-01-01 20:03:52 -0600214 obtain the specific type you want. Names are sometimes represented as a
Paul Kehrer53d8d492015-02-13 18:47:30 -0600215 slash or comma delimited string (e.g. ``/CN=mydomain.com/O=My Org/C=US`` or
216 ``CN=mydomain.com, O=My Org, C=US``).
Paul Kehrer719d5362015-01-01 20:03:52 -0600217
Paul Kehrer53d8d492015-02-13 18:47:30 -0600218 .. doctest::
Paul Kehrer719d5362015-01-01 20:03:52 -0600219
Paul Kehrer8b21a4a2015-02-14 07:56:36 -0600220 >>> len(cert.subject)
Paul Kehrer53d8d492015-02-13 18:47:30 -0600221 3
Paul Kehrer8b21a4a2015-02-14 07:56:36 -0600222 >>> for attribute in cert.subject:
223 ... print(attribute)
224 <NameAttribute(oid=<ObjectIdentifier(oid=2.5.4.6, name=countryName)>, value=u'US')>
225 <NameAttribute(oid=<ObjectIdentifier(oid=2.5.4.10, name=organizationName)>, value=u'Test Certificates 2011')>
226 <NameAttribute(oid=<ObjectIdentifier(oid=2.5.4.3, name=commonName)>, value=u'Good CA')>
Paul Kehrer719d5362015-01-01 20:03:52 -0600227
Paul Kehrere901d642015-02-11 18:50:58 -0600228 .. method:: get_attributes_for_oid(oid)
Paul Kehrer719d5362015-01-01 20:03:52 -0600229
Paul Kehrere901d642015-02-11 18:50:58 -0600230 :param oid: An :class:`ObjectIdentifier` instance.
Paul Kehrer719d5362015-01-01 20:03:52 -0600231
Paul Kehrere901d642015-02-11 18:50:58 -0600232 :returns: A list of :class:`NameAttribute` instances that match the
233 OID provided. If nothing matches an empty list will be returned.
Paul Kehrer719d5362015-01-01 20:03:52 -0600234
235 .. doctest::
236
Paul Kehrere901d642015-02-11 18:50:58 -0600237 >>> cert.subject.get_attributes_for_oid(x509.OID_COMMON_NAME)
238 [<NameAttribute(oid=<ObjectIdentifier(oid=2.5.4.3, name=commonName)>, value=u'Good CA')>]
Paul Kehrerb2de9482014-12-11 14:54:48 -0600239
Paul Kehrere76cd272014-12-14 19:00:51 -0600240.. class:: Version
Paul Kehrer016e08a2014-11-26 09:41:18 -1000241
242 .. versionadded:: 0.7
243
244 An enumeration for X.509 versions.
245
246 .. attribute:: v1
247
248 For version 1 X.509 certificates.
249
250 .. attribute:: v3
251
252 For version 3 X.509 certificates.
253
Paul Kehrer806bfb22015-02-02 17:05:24 -0600254.. class:: NameAttribute
Paul Kehrer912d3fb2015-01-29 11:19:22 -0600255
256 .. versionadded:: 0.8
257
Paul Kehrer834d22f2015-02-06 11:01:07 -0600258 An X.509 name consists of a list of NameAttribute instances.
Paul Kehrer5b0a8d62015-01-30 20:05:55 -0600259
Paul Kehrer912d3fb2015-01-29 11:19:22 -0600260 .. attribute:: oid
261
262 :type: :class:`ObjectIdentifier`
263
264 The attribute OID.
265
266 .. attribute:: value
267
Paul Kehrerd5852cb2015-01-30 08:25:23 -0600268 :type: :term:`text`
Paul Kehrer912d3fb2015-01-29 11:19:22 -0600269
270 The value of the attribute.
271
272.. class:: ObjectIdentifier
273
274 .. versionadded:: 0.8
275
Paul Kehrer5b0a8d62015-01-30 20:05:55 -0600276 Object identifiers (frequently seen abbreviated as OID) identify the type
Paul Kehrer806bfb22015-02-02 17:05:24 -0600277 of a value (see: :class:`NameAttribute`).
Paul Kehrer5b0a8d62015-01-30 20:05:55 -0600278
Paul Kehrerd44f9a62015-02-04 14:47:34 -0600279 .. attribute:: dotted_string
Paul Kehrer912d3fb2015-01-29 11:19:22 -0600280
281 :type: :class:`str`
282
Paul Kehrerfedf4f42015-02-06 11:22:07 -0600283 The dotted string value of the OID (e.g. ``"2.5.4.3"``)
Paul Kehrer912d3fb2015-01-29 11:19:22 -0600284
Paul Kehrer8cf26422015-03-21 09:50:24 -0500285X.509 Extensions
286~~~~~~~~~~~~~~~~
287
Paul Kehrerfbb7ac82015-03-16 19:26:29 -0500288.. class:: Extensions
289
290 .. versionadded:: 0.9
291
292 An X.509 Extensions instance is an ordered list of extensions. The object
293 is iterable to get every extension.
294
Paul Kehrer8cf26422015-03-21 09:50:24 -0500295.. class:: Extension
296
297 .. versionadded:: 0.9
298
Paul Kehrer85894662015-03-22 13:19:31 -0500299 .. attribute:: oid
300
301 :type: :class:`ObjectIdentifier`
302
Paul Kehrer5553d572015-03-23 21:08:01 -0500303 The :ref:`extension OID <extension_oids>`.
Paul Kehrer8cf26422015-03-21 09:50:24 -0500304
305 .. attribute:: critical
306
307 :type: bool
308
Paul Kehrer58b75692015-03-22 23:24:58 -0500309 Determines whether a given extension is critical or not. :rfc:`5280`
310 requires that "A certificate-using system MUST reject the certificate
311 if it encounters a critical extension it does not recognize or a
312 critical extension that contains information that it cannot process".
Paul Kehrer8cf26422015-03-21 09:50:24 -0500313
Paul Kehrer85894662015-03-22 13:19:31 -0500314 .. attribute:: value
315
316 Returns an instance of the extension type corresponding to the OID.
317
Paul Kehrer8cf26422015-03-21 09:50:24 -0500318.. class:: BasicConstraints
319
320 .. versionadded:: 0.9
321
Paul Kehrer85894662015-03-22 13:19:31 -0500322 Basic constraints is an X.509 extension type that defines whether a given
Paul Kehrer8cf26422015-03-21 09:50:24 -0500323 certificate is allowed to sign additional certificates and what path
Paul Kehrer85894662015-03-22 13:19:31 -0500324 length restrictions may exist. It corresponds to
325 :data:`OID_BASIC_CONSTRAINTS`.
Paul Kehrer8cf26422015-03-21 09:50:24 -0500326
327 .. attribute:: ca
328
329 :type: bool
330
331 Whether the certificate can sign certificates.
332
333 .. attribute:: path_length
334
Paul Kehrerfd1444c2015-03-21 19:47:05 -0500335 :type: int or None
Paul Kehrer8cf26422015-03-21 09:50:24 -0500336
337 The maximum path length for certificates subordinate to this
338 certificate. This attribute only has meaning if ``ca`` is true.
339 If ``ca`` is true then a path length of None means there's no
340 restriction on the number of subordinate CAs in the certificate chain.
341 If it is zero or greater then that number defines the maximum length.
342 For example, a ``path_length`` of 1 means the certificate can sign a
343 subordinate CA, but the subordinate CA is not allowed to create
Paul Kehrerfd1444c2015-03-21 19:47:05 -0500344 subordinates with ``ca`` set to true.
Paul Kehrer8cf26422015-03-21 09:50:24 -0500345
346
Paul Kehrer912d3fb2015-01-29 11:19:22 -0600347Object Identifiers
348~~~~~~~~~~~~~~~~~~
349
Paul Kehrer4bb46492015-02-07 16:59:14 -0600350X.509 elements are frequently identified by :class:`ObjectIdentifier`
351instances. The following common OIDs are available as constants.
Paul Kehrer912d3fb2015-01-29 11:19:22 -0600352
Paul Kehrer56da2a52015-02-11 23:35:07 -0600353Name OIDs
354~~~~~~~~~
355
Paul Kehrer912d3fb2015-01-29 11:19:22 -0600356.. data:: OID_COMMON_NAME
357
Paul Kehrerfb5ac9e2015-02-07 16:29:37 -0600358 Corresponds to the dotted string ``"2.5.4.3"``. Historically the domain
359 name would be encoded here for server certificates. :rfc:`2818` deprecates
360 this practice and names of that type should now be located in a
Paul Kehrer4bb46492015-02-07 16:59:14 -0600361 SubjectAlternativeName extension. This OID is typically seen in X.509 names.
Paul Kehrer858b9b72015-02-05 09:50:31 -0600362
Paul Kehrer912d3fb2015-01-29 11:19:22 -0600363.. data:: OID_COUNTRY_NAME
364
Paul Kehrer4bb46492015-02-07 16:59:14 -0600365 Corresponds to the dotted string ``"2.5.4.6"``. This OID is typically seen
366 in X.509 names.
Paul Kehrer858b9b72015-02-05 09:50:31 -0600367
Paul Kehrer912d3fb2015-01-29 11:19:22 -0600368.. data:: OID_LOCALITY_NAME
369
Paul Kehrer4bb46492015-02-07 16:59:14 -0600370 Corresponds to the dotted string ``"2.5.4.7"``. This OID is typically seen
371 in X.509 names.
Paul Kehrer858b9b72015-02-05 09:50:31 -0600372
Paul Kehrer912d3fb2015-01-29 11:19:22 -0600373.. data:: OID_STATE_OR_PROVINCE_NAME
374
Paul Kehrer4bb46492015-02-07 16:59:14 -0600375 Corresponds to the dotted string ``"2.5.4.8"``. This OID is typically seen
376 in X.509 names.
Paul Kehrer858b9b72015-02-05 09:50:31 -0600377
Paul Kehrer912d3fb2015-01-29 11:19:22 -0600378.. data:: OID_ORGANIZATION_NAME
379
Paul Kehrer4bb46492015-02-07 16:59:14 -0600380 Corresponds to the dotted string ``"2.5.4.10"``. This OID is typically seen
381 in X.509 names.
Paul Kehrer858b9b72015-02-05 09:50:31 -0600382
Paul Kehrer912d3fb2015-01-29 11:19:22 -0600383.. data:: OID_ORGANIZATIONAL_UNIT_NAME
384
Paul Kehrer4bb46492015-02-07 16:59:14 -0600385 Corresponds to the dotted string ``"2.5.4.11"``. This OID is typically seen
386 in X.509 names.
Paul Kehrer858b9b72015-02-05 09:50:31 -0600387
Paul Kehrer912d3fb2015-01-29 11:19:22 -0600388.. data:: OID_SERIAL_NUMBER
389
Paul Kehrerfb5ac9e2015-02-07 16:29:37 -0600390 Corresponds to the dotted string ``"2.5.4.5"``. This is distinct from the
391 serial number of the certificate itself (which can be obtained with
Paul Kehrer4bb46492015-02-07 16:59:14 -0600392 :func:`Certificate.serial`). This OID is typically seen in X.509 names.
Paul Kehrer858b9b72015-02-05 09:50:31 -0600393
Paul Kehrer912d3fb2015-01-29 11:19:22 -0600394.. data:: OID_SURNAME
395
Paul Kehrer4bb46492015-02-07 16:59:14 -0600396 Corresponds to the dotted string ``"2.5.4.4"``. This OID is typically seen
397 in X.509 names.
Paul Kehrer858b9b72015-02-05 09:50:31 -0600398
Paul Kehrer912d3fb2015-01-29 11:19:22 -0600399.. data:: OID_GIVEN_NAME
400
Paul Kehrer4bb46492015-02-07 16:59:14 -0600401 Corresponds to the dotted string ``"2.5.4.42"``. This OID is typically seen
402 in X.509 names.
Paul Kehrer858b9b72015-02-05 09:50:31 -0600403
Paul Kehrer912d3fb2015-01-29 11:19:22 -0600404.. data:: OID_TITLE
405
Paul Kehrer4bb46492015-02-07 16:59:14 -0600406 Corresponds to the dotted string ``"2.5.4.12"``. This OID is typically seen
407 in X.509 names.
Paul Kehrer858b9b72015-02-05 09:50:31 -0600408
Paul Kehrer912d3fb2015-01-29 11:19:22 -0600409.. data:: OID_GENERATION_QUALIFIER
410
Paul Kehrer4bb46492015-02-07 16:59:14 -0600411 Corresponds to the dotted string ``"2.5.4.44"``. This OID is typically seen
412 in X.509 names.
Paul Kehrer858b9b72015-02-05 09:50:31 -0600413
Paul Kehrer912d3fb2015-01-29 11:19:22 -0600414.. data:: OID_DN_QUALIFIER
415
Paul Kehrerfb5ac9e2015-02-07 16:29:37 -0600416 Corresponds to the dotted string ``"2.5.4.46"``. This specifies
417 disambiguating information to add to the relative distinguished name of an
Paul Kehrer4bb46492015-02-07 16:59:14 -0600418 entry. See :rfc:`2256`. This OID is typically seen in X.509 names.
Paul Kehrer858b9b72015-02-05 09:50:31 -0600419
Paul Kehrer912d3fb2015-01-29 11:19:22 -0600420.. data:: OID_PSEUDONYM
421
Paul Kehrer4bb46492015-02-07 16:59:14 -0600422 Corresponds to the dotted string ``"2.5.4.65"``. This OID is typically seen
423 in X.509 names.
Paul Kehrer858b9b72015-02-05 09:50:31 -0600424
Paul Kehrer912d3fb2015-01-29 11:19:22 -0600425.. data:: OID_DOMAIN_COMPONENT
426
Paul Kehrerfb5ac9e2015-02-07 16:29:37 -0600427 Corresponds to the dotted string ``"0.9.2342.19200300.100.1.25"``. A string
Paul Kehrer4bb46492015-02-07 16:59:14 -0600428 holding one component of a domain name. See :rfc:`4519`. This OID is
429 typically seen in X.509 names.
Paul Kehrer858b9b72015-02-05 09:50:31 -0600430
Paul Kehrer912d3fb2015-01-29 11:19:22 -0600431.. data:: OID_EMAIL_ADDRESS
432
Paul Kehrer4bb46492015-02-07 16:59:14 -0600433 Corresponds to the dotted string ``"1.2.840.113549.1.9.1"``. This OID is
434 typically seen in X.509 names.
Paul Kehrer858b9b72015-02-05 09:50:31 -0600435
Paul Kehrer56da2a52015-02-11 23:35:07 -0600436Signature Algorithm OIDs
437~~~~~~~~~~~~~~~~~~~~~~~~
438
Paul Kehrer1a7ba872015-02-19 18:09:05 -0600439.. data:: OID_RSA_WITH_MD5
Paul Kehrer56da2a52015-02-11 23:35:07 -0600440
441 Corresponds to the dotted string ``"1.2.840.113549.1.1.4"``. This is
442 an MD5 digest signed by an RSA key.
443
Paul Kehrer1a7ba872015-02-19 18:09:05 -0600444.. data:: OID_RSA_WITH_SHA1
Paul Kehrer56da2a52015-02-11 23:35:07 -0600445
446 Corresponds to the dotted string ``"1.2.840.113549.1.1.5"``. This is
447 a SHA1 digest signed by an RSA key.
448
Paul Kehrer1a7ba872015-02-19 18:09:05 -0600449.. data:: OID_RSA_WITH_SHA224
Paul Kehrer56da2a52015-02-11 23:35:07 -0600450
451 Corresponds to the dotted string ``"1.2.840.113549.1.1.14"``. This is
452 a SHA224 digest signed by an RSA key.
453
Paul Kehrer1a7ba872015-02-19 18:09:05 -0600454.. data:: OID_RSA_WITH_SHA256
Paul Kehrer56da2a52015-02-11 23:35:07 -0600455
456 Corresponds to the dotted string ``"1.2.840.113549.1.1.11"``. This is
457 a SHA256 digest signed by an RSA key.
458
Paul Kehrer1a7ba872015-02-19 18:09:05 -0600459.. data:: OID_RSA_WITH_SHA384
Paul Kehrer56da2a52015-02-11 23:35:07 -0600460
461 Corresponds to the dotted string ``"1.2.840.113549.1.1.12"``. This is
462 a SHA384 digest signed by an RSA key.
463
Paul Kehrer1a7ba872015-02-19 18:09:05 -0600464.. data:: OID_RSA_WITH_SHA512
Paul Kehrer56da2a52015-02-11 23:35:07 -0600465
466 Corresponds to the dotted string ``"1.2.840.113549.1.1.13"``. This is
467 a SHA512 digest signed by an RSA key.
468
469.. data:: OID_ECDSA_WITH_SHA224
470
471 Corresponds to the dotted string ``"1.2.840.10045.4.3.1"``. This is
472 a SHA224 digest signed by an ECDSA key.
473
474.. data:: OID_ECDSA_WITH_SHA256
475
476 Corresponds to the dotted string ``"1.2.840.10045.4.3.2"``. This is
477 a SHA256 digest signed by an ECDSA key.
478
479.. data:: OID_ECDSA_WITH_SHA384
480
481 Corresponds to the dotted string ``"1.2.840.10045.4.3.3"``. This is
482 a SHA384 digest signed by an ECDSA key.
483
484.. data:: OID_ECDSA_WITH_SHA512
485
486 Corresponds to the dotted string ``"1.2.840.10045.4.3.4"``. This is
487 a SHA512 digest signed by an ECDSA key.
488
489.. data:: OID_DSA_WITH_SHA1
490
491 Corresponds to the dotted string ``"1.2.840.10040.4.3"``. This is
492 a SHA1 digest signed by a DSA key.
493
494.. data:: OID_DSA_WITH_SHA224
495
496 Corresponds to the dotted string ``"2.16.840.1.101.3.4.3.1"``. This is
497 a SHA224 digest signed by a DSA key.
498
499.. data:: OID_DSA_WITH_SHA256
500
Paul Kehrerfbb7ac82015-03-16 19:26:29 -0500501 Corresponds to the dotted string ``"2.16.840.1.101.3.4.3.2"``. This is
Paul Kehrer56da2a52015-02-11 23:35:07 -0600502 a SHA256 digest signed by a DSA key.
503
Paul Kehrer5553d572015-03-23 21:08:01 -0500504.. _extension_oids:
505
Paul Kehrer2bb94642015-03-21 09:54:17 -0500506Extension OIDs
507~~~~~~~~~~~~~~
508
509.. data:: OID_BASIC_CONSTRAINTS
510
511 Corresponds to the dotted string ``"2.5.29.19"``. The identifier for the
Paul Kehrer611d3d32015-03-22 13:31:18 -0500512 :class:`BasicConstraints` extension type.
Paul Kehrer2bb94642015-03-21 09:54:17 -0500513
Paul Kehrer56da2a52015-02-11 23:35:07 -0600514
Paul Kehrer912d3fb2015-01-29 11:19:22 -0600515Exceptions
516~~~~~~~~~~
517
Paul Kehrere76cd272014-12-14 19:00:51 -0600518.. class:: InvalidVersion
Paul Kehrera68fd332014-11-27 07:08:40 -1000519
520 This is raised when an X.509 certificate has an invalid version number.
Paul Kehrer016e08a2014-11-26 09:41:18 -1000521
Paul Kehrerd5cccf72014-12-15 17:20:33 -0600522 .. attribute:: parsed_version
523
Paul Kehrerbbffc402014-12-17 13:33:55 -0600524 :type: int
525
526 Returns the raw version that was parsed from the certificate.
Paul Kehrerd5cccf72014-12-15 17:20:33 -0600527
Paul Kehrerfbb7ac82015-03-16 19:26:29 -0500528.. class:: DuplicateExtension
529
530 This is raised when more than one X.509 extension of the same type is
531 found within a certificate.
532
533 .. attribute:: oid
534
535 :type: :class:`ObjectIdentifier`
536
537 Returns the OID.
538
539.. class:: UnsupportedExtension
540
541 This is raised when a certificate contains an unsupported extension type.
542
543 .. attribute:: oid
544
545 :type: :class:`ObjectIdentifier`
546
547 Returns the OID.
548
Paul Kehrer016e08a2014-11-26 09:41:18 -1000549
550.. _`public key infrastructure`: https://en.wikipedia.org/wiki/Public_key_infrastructure
Paul Kehrera68fd332014-11-27 07:08:40 -1000551.. _`TLS`: https://en.wikipedia.org/wiki/Transport_Layer_Security