Paul Kehrer | 016e08a | 2014-11-26 09:41:18 -1000 | [diff] [blame] | 1 | X.509 |
| 2 | ===== |
| 3 | |
Paul Kehrer | a9d78c1 | 2014-11-26 10:59:03 -1000 | [diff] [blame] | 4 | .. currentmodule:: cryptography.x509 |
Paul Kehrer | 016e08a | 2014-11-26 09:41:18 -1000 | [diff] [blame] | 5 | |
| 6 | X.509 is an ITU-T standard for a `public key infrastructure`_. X.509v3 is |
Paul Kehrer | a68fd33 | 2014-11-27 07:08:40 -1000 | [diff] [blame] | 7 | defined in :rfc:`5280` (which obsoletes :rfc:`2459` and :rfc:`3280`). X.509 |
| 8 | certificates are commonly used in protocols like `TLS`_. |
Paul Kehrer | 016e08a | 2014-11-26 09:41:18 -1000 | [diff] [blame] | 9 | |
Paul Kehrer | b2de948 | 2014-12-11 14:54:48 -0600 | [diff] [blame] | 10 | |
| 11 | Loading Certificates |
| 12 | ~~~~~~~~~~~~~~~~~~~~ |
Paul Kehrer | 016e08a | 2014-11-26 09:41:18 -1000 | [diff] [blame] | 13 | |
| 14 | .. function:: load_pem_x509_certificate(data, backend) |
| 15 | |
| 16 | .. versionadded:: 0.7 |
| 17 | |
Paul Kehrer | e76cd27 | 2014-12-14 19:00:51 -0600 | [diff] [blame] | 18 | Deserialize a certificate from PEM encoded data. PEM certificates are |
| 19 | base64 decoded and have delimiters that look like |
| 20 | ``-----BEGIN CERTIFICATE-----``. |
Paul Kehrer | 016e08a | 2014-11-26 09:41:18 -1000 | [diff] [blame] | 21 | |
| 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 Kehrer | e76cd27 | 2014-12-14 19:00:51 -0600 | [diff] [blame] | 28 | :returns: An instance of :class:`~cryptography.x509.Certificate`. |
Paul Kehrer | 016e08a | 2014-11-26 09:41:18 -1000 | [diff] [blame] | 29 | |
| 30 | .. function:: load_der_x509_certificate(data, backend) |
| 31 | |
| 32 | .. versionadded:: 0.7 |
| 33 | |
Paul Kehrer | e76cd27 | 2014-12-14 19:00:51 -0600 | [diff] [blame] | 34 | Deserialize a certificate from DER encoded data. DER is a binary format |
Paul Kehrer | 92aac38 | 2014-12-15 16:25:28 -0600 | [diff] [blame] | 35 | and is commonly found in files with the ``.cer`` extension (although file |
| 36 | extensions are not a guarantee of encoding type). |
Paul Kehrer | 016e08a | 2014-11-26 09:41:18 -1000 | [diff] [blame] | 37 | |
| 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 Kehrer | e76cd27 | 2014-12-14 19:00:51 -0600 | [diff] [blame] | 44 | :returns: An instance of :class:`~cryptography.x509.Certificate`. |
Paul Kehrer | 016e08a | 2014-11-26 09:41:18 -1000 | [diff] [blame] | 45 | |
| 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 Kehrer | cc8a26e | 2014-12-16 12:40:16 -0600 | [diff] [blame] | 74 | >>> from cryptography import x509 |
Paul Kehrer | 016e08a | 2014-11-26 09:41:18 -1000 | [diff] [blame] | 75 | >>> from cryptography.hazmat.backends import default_backend |
Paul Kehrer | cc8a26e | 2014-12-16 12:40:16 -0600 | [diff] [blame] | 76 | >>> cert = x509.load_pem_x509_certificate(pem_data, default_backend()) |
Paul Kehrer | 016e08a | 2014-11-26 09:41:18 -1000 | [diff] [blame] | 77 | >>> cert.serial |
| 78 | 2 |
| 79 | |
Paul Kehrer | dc480ad | 2015-02-23 12:14:54 -0600 | [diff] [blame] | 80 | Loading Certificate Requests |
| 81 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 82 | |
| 83 | .. function:: load_pem_x509_request(data, backend) |
| 84 | |
| 85 | .. versionadded:: 0.9 |
| 86 | |
| 87 | Deserialize a certificate request from PEM encoded data. PEM requests are |
| 88 | base64 decoded and have delimiters that look like |
| 89 | ``-----BEGIN CERTIFICATE REQUEST-----``. This is also known as PKCS#10 |
| 90 | format. |
| 91 | |
| 92 | :param bytes data: The PEM encoded request data. |
| 93 | |
| 94 | :param backend: A backend supporting the |
| 95 | :class:`~cryptography.hazmat.backends.interfaces.X509Backend` |
| 96 | interface. |
| 97 | |
| 98 | :returns: An instance of :class:`~cryptography.x509.Request`. |
| 99 | |
| 100 | .. testsetup:: |
| 101 | |
| 102 | pem_req_data = b""" |
| 103 | -----BEGIN CERTIFICATE REQUEST----- |
| 104 | MIIC0zCCAbsCAQAwWTELMAkGA1UEBhMCVVMxETAPBgNVBAgMCElsbGlub2lzMRAw |
| 105 | DgYDVQQHDAdDaGljYWdvMREwDwYDVQQKDAhyNTA5IExMQzESMBAGA1UEAwwJaGVs |
| 106 | bG8uY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqhZx+Mo9VRd9 |
| 107 | vsnWWa6NBCws21rZ0+1B/JGgB4hDsZS7iDE4Bj5z4idheFRtl8bBbdjPknq7BfoF |
| 108 | 8v15Zq/Zv7i2xMSDL+LUrTBZezRd4bRTGqCm6YJ5EYkhqdcqeZleHCFImguHoq1J |
| 109 | Fh0+kObQrTHXw3ZP57a3o1IvyIUA3nNoCBL0QQhwBXaDXOojMKNR+bqB5ve8GS1y |
| 110 | Elr0AM/+cJsfaIahNQUgFKx3Eu3GeEOMKYOAG1lycgdQdmTUybLrT3U7vkClTseM |
| 111 | xHg1r5En7ALjONIhqRuq3rddYahrP8HXozb3zUy3cJ7P6IeaosuvNzvMXOX9P6HD |
| 112 | Ha9urDAJ1wIDAQABoDUwMwYJKoZIhvcNAQkOMSYwJDAiBgNVHREEGzAZggl3b3Js |
| 113 | ZC5jb22CDHdoYXRldmVyLmNvbTANBgkqhkiG9w0BAQUFAAOCAQEAS4Ro6h+z52SK |
| 114 | YSLCYARpnEu/rmh4jdqndt8naqcNb6uLx9mlKZ2W9on9XDjnSdQD9q+ZP5aZfESw |
| 115 | R0+rJhW9ZrNa/g1pt6M24ihclHYDAxYMWxT1z/TXXGM3TmZZ6gfYlNE1kkBuODHa |
| 116 | UYsR/1Ht1E1EsmmUimt2n+zQR2K8T9Coa+boaUW/GsTEuz1aaJAkj5ZvTDiIhRG4 |
| 117 | AOCqFZOLAQmCCNgJnnspD9hDz/Ons085LF5wnYjN4/Nsk5tS6AGs3xjZ3jPoOGGn |
| 118 | 82WQ9m4dBGoVDZXsobVTaN592JEYwN5iu72zRn7Einb4V4H5y3yD2dD4yWPlt4pk |
| 119 | 5wFkeYsZEA== |
| 120 | -----END CERTIFICATE REQUEST----- |
| 121 | """.strip() |
| 122 | |
| 123 | .. doctest:: |
| 124 | |
| 125 | >>> from cryptography import x509 |
| 126 | >>> from cryptography.hazmat.backends import default_backend |
| 127 | >>> from cryptography.hazmat.primitives import hashes |
| 128 | >>> request = x509.load_pem_x509_request(pem_req_data, default_backend()) |
| 129 | >>> isinstance(request.signature_hash_algorithm, hashes.SHA1) |
| 130 | True |
| 131 | |
Paul Kehrer | e76cd27 | 2014-12-14 19:00:51 -0600 | [diff] [blame] | 132 | X.509 Certificate Object |
| 133 | ~~~~~~~~~~~~~~~~~~~~~~~~ |
Paul Kehrer | b2de948 | 2014-12-11 14:54:48 -0600 | [diff] [blame] | 134 | |
Paul Kehrer | e76cd27 | 2014-12-14 19:00:51 -0600 | [diff] [blame] | 135 | .. class:: Certificate |
Paul Kehrer | b2de948 | 2014-12-11 14:54:48 -0600 | [diff] [blame] | 136 | |
| 137 | .. versionadded:: 0.7 |
| 138 | |
| 139 | .. attribute:: version |
| 140 | |
Paul Kehrer | e76cd27 | 2014-12-14 19:00:51 -0600 | [diff] [blame] | 141 | :type: :class:`~cryptography.x509.Version` |
Paul Kehrer | b2de948 | 2014-12-11 14:54:48 -0600 | [diff] [blame] | 142 | |
Paul Kehrer | e76cd27 | 2014-12-14 19:00:51 -0600 | [diff] [blame] | 143 | The certificate version as an enumeration. Version 3 certificates are |
| 144 | the latest version and also the only type you should see in practice. |
Paul Kehrer | b2de948 | 2014-12-11 14:54:48 -0600 | [diff] [blame] | 145 | |
Alex Gaynor | 89c4dc8 | 2014-12-16 16:49:33 -0800 | [diff] [blame] | 146 | :raises cryptography.x509.InvalidVersion: If the version in the |
Alex Gaynor | 6d7ab4c | 2014-12-16 16:50:33 -0800 | [diff] [blame] | 147 | certificate is not a known |
| 148 | :class:`X.509 version <cryptography.x509.Version>`. |
Paul Kehrer | 92aac38 | 2014-12-15 16:25:28 -0600 | [diff] [blame] | 149 | |
Paul Kehrer | cc8a26e | 2014-12-16 12:40:16 -0600 | [diff] [blame] | 150 | .. doctest:: |
| 151 | |
| 152 | >>> cert.version |
| 153 | <Version.v3: 2> |
| 154 | |
Paul Kehrer | b2de948 | 2014-12-11 14:54:48 -0600 | [diff] [blame] | 155 | .. method:: fingerprint(algorithm) |
| 156 | |
| 157 | :param algorithm: The |
Paul Kehrer | 601278a | 2015-02-12 12:51:00 -0600 | [diff] [blame] | 158 | :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` |
Paul Kehrer | b2de948 | 2014-12-11 14:54:48 -0600 | [diff] [blame] | 159 | that will be used to generate the fingerprint. |
| 160 | |
| 161 | :return bytes: The fingerprint using the supplied hash algorithm as |
| 162 | bytes. |
| 163 | |
Paul Kehrer | cc8a26e | 2014-12-16 12:40:16 -0600 | [diff] [blame] | 164 | .. doctest:: |
| 165 | |
| 166 | >>> from cryptography.hazmat.primitives import hashes |
| 167 | >>> cert.fingerprint(hashes.SHA256()) |
Paul Kehrer | 78a8150 | 2014-12-16 14:47:52 -0600 | [diff] [blame] | 168 | '\x86\xd2\x187Gc\xfc\xe7}[+E9\x8d\xb4\x8f\x10\xe5S\xda\x18u\xbe}a\x03\x08[\xac\xa04?' |
Paul Kehrer | cc8a26e | 2014-12-16 12:40:16 -0600 | [diff] [blame] | 169 | |
Paul Kehrer | b2de948 | 2014-12-11 14:54:48 -0600 | [diff] [blame] | 170 | .. attribute:: serial |
| 171 | |
| 172 | :type: int |
| 173 | |
| 174 | The serial as a Python integer. |
| 175 | |
Paul Kehrer | cc8a26e | 2014-12-16 12:40:16 -0600 | [diff] [blame] | 176 | .. doctest:: |
| 177 | |
| 178 | >>> cert.serial |
| 179 | 2 |
| 180 | |
Paul Kehrer | b2de948 | 2014-12-11 14:54:48 -0600 | [diff] [blame] | 181 | .. method:: public_key() |
| 182 | |
| 183 | :type: |
Alex Stapleton | f79c231 | 2014-12-30 12:50:14 +0000 | [diff] [blame] | 184 | :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey` or |
Paul Kehrer | 45efdbc | 2015-02-12 10:58:22 -0600 | [diff] [blame] | 185 | :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPublicKey` or |
| 186 | :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey` |
Paul Kehrer | b2de948 | 2014-12-11 14:54:48 -0600 | [diff] [blame] | 187 | |
| 188 | The public key associated with the certificate. |
| 189 | |
Paul Kehrer | cc8a26e | 2014-12-16 12:40:16 -0600 | [diff] [blame] | 190 | .. doctest:: |
| 191 | |
Alex Stapleton | f79c231 | 2014-12-30 12:50:14 +0000 | [diff] [blame] | 192 | >>> from cryptography.hazmat.primitives.asymmetric import rsa |
Paul Kehrer | cc8a26e | 2014-12-16 12:40:16 -0600 | [diff] [blame] | 193 | >>> public_key = cert.public_key() |
Alex Stapleton | f79c231 | 2014-12-30 12:50:14 +0000 | [diff] [blame] | 194 | >>> isinstance(public_key, rsa.RSAPublicKey) |
Paul Kehrer | cc8a26e | 2014-12-16 12:40:16 -0600 | [diff] [blame] | 195 | True |
| 196 | |
Paul Kehrer | b2de948 | 2014-12-11 14:54:48 -0600 | [diff] [blame] | 197 | .. attribute:: not_valid_before |
| 198 | |
| 199 | :type: :class:`datetime.datetime` |
| 200 | |
Paul Kehrer | 78a8150 | 2014-12-16 14:47:52 -0600 | [diff] [blame] | 201 | A naïve datetime representing the beginning of the validity period for |
| 202 | the certificate in UTC. This value is inclusive. |
Paul Kehrer | b2de948 | 2014-12-11 14:54:48 -0600 | [diff] [blame] | 203 | |
Paul Kehrer | cc8a26e | 2014-12-16 12:40:16 -0600 | [diff] [blame] | 204 | .. doctest:: |
| 205 | |
| 206 | >>> cert.not_valid_before |
| 207 | datetime.datetime(2010, 1, 1, 8, 30) |
| 208 | |
Paul Kehrer | b2de948 | 2014-12-11 14:54:48 -0600 | [diff] [blame] | 209 | .. attribute:: not_valid_after |
| 210 | |
| 211 | :type: :class:`datetime.datetime` |
| 212 | |
Paul Kehrer | 78a8150 | 2014-12-16 14:47:52 -0600 | [diff] [blame] | 213 | A naïve datetime representing the end of the validity period for the |
| 214 | certificate in UTC. This value is inclusive. |
Paul Kehrer | b2de948 | 2014-12-11 14:54:48 -0600 | [diff] [blame] | 215 | |
Paul Kehrer | cc8a26e | 2014-12-16 12:40:16 -0600 | [diff] [blame] | 216 | .. doctest:: |
| 217 | |
| 218 | >>> cert.not_valid_after |
| 219 | datetime.datetime(2030, 12, 31, 8, 30) |
| 220 | |
Paul Kehrer | 719d536 | 2015-01-01 20:03:52 -0600 | [diff] [blame] | 221 | .. attribute:: issuer |
| 222 | |
| 223 | .. versionadded:: 0.8 |
| 224 | |
| 225 | :type: :class:`Name` |
| 226 | |
| 227 | The :class:`Name` of the issuer. |
| 228 | |
| 229 | .. attribute:: subject |
| 230 | |
| 231 | .. versionadded:: 0.8 |
| 232 | |
| 233 | :type: :class:`Name` |
| 234 | |
| 235 | The :class:`Name` of the subject. |
| 236 | |
Paul Kehrer | 8802a5b | 2015-02-13 12:06:57 -0600 | [diff] [blame] | 237 | .. attribute:: signature_hash_algorithm |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 238 | |
Paul Kehrer | 8802a5b | 2015-02-13 12:06:57 -0600 | [diff] [blame] | 239 | :type: :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 240 | |
Paul Kehrer | e612ec7 | 2015-02-16 14:33:35 -0600 | [diff] [blame] | 241 | Returns the |
Paul Kehrer | 71d40c6 | 2015-02-19 08:21:04 -0600 | [diff] [blame] | 242 | :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` which |
Paul Kehrer | 1a7ba87 | 2015-02-19 18:09:05 -0600 | [diff] [blame] | 243 | was used in signing this certificate. |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 244 | |
| 245 | .. doctest:: |
| 246 | |
Paul Kehrer | 8802a5b | 2015-02-13 12:06:57 -0600 | [diff] [blame] | 247 | >>> from cryptography.hazmat.primitives import hashes |
| 248 | >>> isinstance(cert.signature_hash_algorithm, hashes.SHA256) |
| 249 | True |
Paul Kehrer | 719d536 | 2015-01-01 20:03:52 -0600 | [diff] [blame] | 250 | |
Paul Kehrer | fbb7ac8 | 2015-03-16 19:26:29 -0500 | [diff] [blame] | 251 | .. attribute:: extensions |
| 252 | |
| 253 | :type: :class:`Extensions` |
| 254 | |
| 255 | The extensions encoded in the certificate. |
| 256 | |
| 257 | :raises cryptography.x509.DuplicateExtension: If more than one |
| 258 | extension of the same type is found within the certificate. |
| 259 | |
Paul Kehrer | fa56a23 | 2015-03-17 13:14:03 -0500 | [diff] [blame] | 260 | .. doctest:: |
| 261 | |
| 262 | >>> for ext in cert.extensions: |
| 263 | ... print(ext) |
| 264 | <Extension(oid=<ObjectIdentifier(oid=2.5.29.19, name=basicConstraints)>, critical=True, value=<BasicConstraints(ca=True, path_length=None)>)> |
| 265 | |
Paul Kehrer | dc480ad | 2015-02-23 12:14:54 -0600 | [diff] [blame] | 266 | X.509 Certificate Request Object |
| 267 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 268 | |
| 269 | .. class:: Request |
| 270 | |
| 271 | .. versionadded:: 0.9 |
| 272 | |
| 273 | .. method:: public_key() |
| 274 | |
| 275 | :type: |
| 276 | :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey` or |
| 277 | :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPublicKey` or |
| 278 | :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey` |
| 279 | |
| 280 | The public key associated with the request. |
| 281 | |
| 282 | .. doctest:: |
| 283 | |
| 284 | >>> from cryptography.hazmat.primitives.asymmetric import rsa |
| 285 | >>> public_key = request.public_key() |
| 286 | >>> isinstance(public_key, rsa.RSAPublicKey) |
| 287 | True |
| 288 | |
| 289 | .. attribute:: subject |
| 290 | |
| 291 | :type: :class:`Name` |
| 292 | |
| 293 | The :class:`Name` of the subject. |
| 294 | |
| 295 | .. attribute:: signature_hash_algorithm |
| 296 | |
| 297 | :type: :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` |
| 298 | |
| 299 | Returns the |
| 300 | :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` which |
| 301 | was used in signing this request. |
| 302 | |
| 303 | .. doctest:: |
| 304 | |
| 305 | >>> from cryptography.hazmat.primitives import hashes |
| 306 | >>> isinstance(request.signature_hash_algorithm, hashes.SHA1) |
| 307 | True |
| 308 | |
Paul Kehrer | 719d536 | 2015-01-01 20:03:52 -0600 | [diff] [blame] | 309 | .. class:: Name |
| 310 | |
| 311 | .. versionadded:: 0.8 |
| 312 | |
Paul Kehrer | 53d8d49 | 2015-02-13 18:47:30 -0600 | [diff] [blame] | 313 | An X509 Name is an ordered list of attributes. The object is iterable to |
Paul Kehrer | d21596e | 2015-02-14 09:17:26 -0600 | [diff] [blame] | 314 | get every attribute or you can use :meth:`Name.get_attributes_for_oid` to |
Paul Kehrer | 719d536 | 2015-01-01 20:03:52 -0600 | [diff] [blame] | 315 | obtain the specific type you want. Names are sometimes represented as a |
Paul Kehrer | 53d8d49 | 2015-02-13 18:47:30 -0600 | [diff] [blame] | 316 | slash or comma delimited string (e.g. ``/CN=mydomain.com/O=My Org/C=US`` or |
| 317 | ``CN=mydomain.com, O=My Org, C=US``). |
Paul Kehrer | 719d536 | 2015-01-01 20:03:52 -0600 | [diff] [blame] | 318 | |
Paul Kehrer | 53d8d49 | 2015-02-13 18:47:30 -0600 | [diff] [blame] | 319 | .. doctest:: |
Paul Kehrer | 719d536 | 2015-01-01 20:03:52 -0600 | [diff] [blame] | 320 | |
Paul Kehrer | 8b21a4a | 2015-02-14 07:56:36 -0600 | [diff] [blame] | 321 | >>> len(cert.subject) |
Paul Kehrer | 53d8d49 | 2015-02-13 18:47:30 -0600 | [diff] [blame] | 322 | 3 |
Paul Kehrer | 8b21a4a | 2015-02-14 07:56:36 -0600 | [diff] [blame] | 323 | >>> for attribute in cert.subject: |
| 324 | ... print(attribute) |
| 325 | <NameAttribute(oid=<ObjectIdentifier(oid=2.5.4.6, name=countryName)>, value=u'US')> |
| 326 | <NameAttribute(oid=<ObjectIdentifier(oid=2.5.4.10, name=organizationName)>, value=u'Test Certificates 2011')> |
| 327 | <NameAttribute(oid=<ObjectIdentifier(oid=2.5.4.3, name=commonName)>, value=u'Good CA')> |
Paul Kehrer | 719d536 | 2015-01-01 20:03:52 -0600 | [diff] [blame] | 328 | |
Paul Kehrer | e901d64 | 2015-02-11 18:50:58 -0600 | [diff] [blame] | 329 | .. method:: get_attributes_for_oid(oid) |
Paul Kehrer | 719d536 | 2015-01-01 20:03:52 -0600 | [diff] [blame] | 330 | |
Paul Kehrer | e901d64 | 2015-02-11 18:50:58 -0600 | [diff] [blame] | 331 | :param oid: An :class:`ObjectIdentifier` instance. |
Paul Kehrer | 719d536 | 2015-01-01 20:03:52 -0600 | [diff] [blame] | 332 | |
Paul Kehrer | e901d64 | 2015-02-11 18:50:58 -0600 | [diff] [blame] | 333 | :returns: A list of :class:`NameAttribute` instances that match the |
| 334 | OID provided. If nothing matches an empty list will be returned. |
Paul Kehrer | 719d536 | 2015-01-01 20:03:52 -0600 | [diff] [blame] | 335 | |
| 336 | .. doctest:: |
| 337 | |
Paul Kehrer | e901d64 | 2015-02-11 18:50:58 -0600 | [diff] [blame] | 338 | >>> cert.subject.get_attributes_for_oid(x509.OID_COMMON_NAME) |
| 339 | [<NameAttribute(oid=<ObjectIdentifier(oid=2.5.4.3, name=commonName)>, value=u'Good CA')>] |
Paul Kehrer | b2de948 | 2014-12-11 14:54:48 -0600 | [diff] [blame] | 340 | |
Paul Kehrer | e76cd27 | 2014-12-14 19:00:51 -0600 | [diff] [blame] | 341 | .. class:: Version |
Paul Kehrer | 016e08a | 2014-11-26 09:41:18 -1000 | [diff] [blame] | 342 | |
| 343 | .. versionadded:: 0.7 |
| 344 | |
| 345 | An enumeration for X.509 versions. |
| 346 | |
| 347 | .. attribute:: v1 |
| 348 | |
| 349 | For version 1 X.509 certificates. |
| 350 | |
| 351 | .. attribute:: v3 |
| 352 | |
| 353 | For version 3 X.509 certificates. |
| 354 | |
Paul Kehrer | 806bfb2 | 2015-02-02 17:05:24 -0600 | [diff] [blame] | 355 | .. class:: NameAttribute |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 356 | |
| 357 | .. versionadded:: 0.8 |
| 358 | |
Paul Kehrer | 834d22f | 2015-02-06 11:01:07 -0600 | [diff] [blame] | 359 | An X.509 name consists of a list of NameAttribute instances. |
Paul Kehrer | 5b0a8d6 | 2015-01-30 20:05:55 -0600 | [diff] [blame] | 360 | |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 361 | .. attribute:: oid |
| 362 | |
| 363 | :type: :class:`ObjectIdentifier` |
| 364 | |
| 365 | The attribute OID. |
| 366 | |
| 367 | .. attribute:: value |
| 368 | |
Paul Kehrer | d5852cb | 2015-01-30 08:25:23 -0600 | [diff] [blame] | 369 | :type: :term:`text` |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 370 | |
| 371 | The value of the attribute. |
| 372 | |
| 373 | .. class:: ObjectIdentifier |
| 374 | |
| 375 | .. versionadded:: 0.8 |
| 376 | |
Paul Kehrer | 5b0a8d6 | 2015-01-30 20:05:55 -0600 | [diff] [blame] | 377 | Object identifiers (frequently seen abbreviated as OID) identify the type |
Paul Kehrer | 806bfb2 | 2015-02-02 17:05:24 -0600 | [diff] [blame] | 378 | of a value (see: :class:`NameAttribute`). |
Paul Kehrer | 5b0a8d6 | 2015-01-30 20:05:55 -0600 | [diff] [blame] | 379 | |
Paul Kehrer | d44f9a6 | 2015-02-04 14:47:34 -0600 | [diff] [blame] | 380 | .. attribute:: dotted_string |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 381 | |
| 382 | :type: :class:`str` |
| 383 | |
Paul Kehrer | fedf4f4 | 2015-02-06 11:22:07 -0600 | [diff] [blame] | 384 | The dotted string value of the OID (e.g. ``"2.5.4.3"``) |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 385 | |
Paul Kehrer | 8cf2642 | 2015-03-21 09:50:24 -0500 | [diff] [blame] | 386 | X.509 Extensions |
| 387 | ~~~~~~~~~~~~~~~~ |
| 388 | |
Paul Kehrer | fbb7ac8 | 2015-03-16 19:26:29 -0500 | [diff] [blame] | 389 | .. class:: Extensions |
| 390 | |
| 391 | .. versionadded:: 0.9 |
| 392 | |
| 393 | An X.509 Extensions instance is an ordered list of extensions. The object |
| 394 | is iterable to get every extension. |
| 395 | |
Paul Kehrer | fa56a23 | 2015-03-17 13:14:03 -0500 | [diff] [blame] | 396 | .. method:: get_extension_for_oid(oid) |
| 397 | |
| 398 | :param oid: An :class:`ObjectIdentifier` instance. |
| 399 | |
| 400 | :returns: An instance of the extension class. |
| 401 | |
| 402 | :raises cryptography.x509.ExtensionNotFound: If the certificate does |
| 403 | not have the extension requested. |
| 404 | |
| 405 | :raises cryptography.x509.UnsupportedExtension: If the certificate |
| 406 | contains an extension that is not supported. |
| 407 | |
| 408 | .. doctest:: |
| 409 | |
| 410 | >>> cert.extensions.get_extension_for_oid(x509.OID_BASIC_CONSTRAINTS) |
| 411 | <Extension(oid=<ObjectIdentifier(oid=2.5.29.19, name=basicConstraints)>, critical=True, value=<BasicConstraints(ca=True, path_length=None)>)> |
| 412 | |
Paul Kehrer | 8cf2642 | 2015-03-21 09:50:24 -0500 | [diff] [blame] | 413 | .. class:: Extension |
| 414 | |
| 415 | .. versionadded:: 0.9 |
| 416 | |
Paul Kehrer | 8589466 | 2015-03-22 13:19:31 -0500 | [diff] [blame] | 417 | .. attribute:: oid |
| 418 | |
| 419 | :type: :class:`ObjectIdentifier` |
| 420 | |
Paul Kehrer | 5553d57 | 2015-03-23 21:08:01 -0500 | [diff] [blame] | 421 | The :ref:`extension OID <extension_oids>`. |
Paul Kehrer | 8cf2642 | 2015-03-21 09:50:24 -0500 | [diff] [blame] | 422 | |
| 423 | .. attribute:: critical |
| 424 | |
| 425 | :type: bool |
| 426 | |
Paul Kehrer | 58b7569 | 2015-03-22 23:24:58 -0500 | [diff] [blame] | 427 | Determines whether a given extension is critical or not. :rfc:`5280` |
| 428 | requires that "A certificate-using system MUST reject the certificate |
| 429 | if it encounters a critical extension it does not recognize or a |
| 430 | critical extension that contains information that it cannot process". |
Paul Kehrer | 8cf2642 | 2015-03-21 09:50:24 -0500 | [diff] [blame] | 431 | |
Paul Kehrer | 8589466 | 2015-03-22 13:19:31 -0500 | [diff] [blame] | 432 | .. attribute:: value |
| 433 | |
| 434 | Returns an instance of the extension type corresponding to the OID. |
| 435 | |
Paul Kehrer | 8cf2642 | 2015-03-21 09:50:24 -0500 | [diff] [blame] | 436 | .. class:: BasicConstraints |
| 437 | |
| 438 | .. versionadded:: 0.9 |
| 439 | |
Paul Kehrer | 8589466 | 2015-03-22 13:19:31 -0500 | [diff] [blame] | 440 | Basic constraints is an X.509 extension type that defines whether a given |
Paul Kehrer | 8cf2642 | 2015-03-21 09:50:24 -0500 | [diff] [blame] | 441 | certificate is allowed to sign additional certificates and what path |
Paul Kehrer | 8589466 | 2015-03-22 13:19:31 -0500 | [diff] [blame] | 442 | length restrictions may exist. It corresponds to |
| 443 | :data:`OID_BASIC_CONSTRAINTS`. |
Paul Kehrer | 8cf2642 | 2015-03-21 09:50:24 -0500 | [diff] [blame] | 444 | |
| 445 | .. attribute:: ca |
| 446 | |
| 447 | :type: bool |
| 448 | |
| 449 | Whether the certificate can sign certificates. |
| 450 | |
| 451 | .. attribute:: path_length |
| 452 | |
Paul Kehrer | fd1444c | 2015-03-21 19:47:05 -0500 | [diff] [blame] | 453 | :type: int or None |
Paul Kehrer | 8cf2642 | 2015-03-21 09:50:24 -0500 | [diff] [blame] | 454 | |
| 455 | The maximum path length for certificates subordinate to this |
| 456 | certificate. This attribute only has meaning if ``ca`` is true. |
| 457 | If ``ca`` is true then a path length of None means there's no |
| 458 | restriction on the number of subordinate CAs in the certificate chain. |
| 459 | If it is zero or greater then that number defines the maximum length. |
| 460 | For example, a ``path_length`` of 1 means the certificate can sign a |
| 461 | subordinate CA, but the subordinate CA is not allowed to create |
Paul Kehrer | fd1444c | 2015-03-21 19:47:05 -0500 | [diff] [blame] | 462 | subordinates with ``ca`` set to true. |
Paul Kehrer | 8cf2642 | 2015-03-21 09:50:24 -0500 | [diff] [blame] | 463 | |
| 464 | |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 465 | Object Identifiers |
| 466 | ~~~~~~~~~~~~~~~~~~ |
| 467 | |
Paul Kehrer | 4bb4649 | 2015-02-07 16:59:14 -0600 | [diff] [blame] | 468 | X.509 elements are frequently identified by :class:`ObjectIdentifier` |
| 469 | instances. The following common OIDs are available as constants. |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 470 | |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 471 | Name OIDs |
| 472 | ~~~~~~~~~ |
| 473 | |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 474 | .. data:: OID_COMMON_NAME |
| 475 | |
Paul Kehrer | fb5ac9e | 2015-02-07 16:29:37 -0600 | [diff] [blame] | 476 | Corresponds to the dotted string ``"2.5.4.3"``. Historically the domain |
| 477 | name would be encoded here for server certificates. :rfc:`2818` deprecates |
| 478 | this practice and names of that type should now be located in a |
Paul Kehrer | 4bb4649 | 2015-02-07 16:59:14 -0600 | [diff] [blame] | 479 | SubjectAlternativeName extension. This OID is typically seen in X.509 names. |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 480 | |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 481 | .. data:: OID_COUNTRY_NAME |
| 482 | |
Paul Kehrer | 4bb4649 | 2015-02-07 16:59:14 -0600 | [diff] [blame] | 483 | Corresponds to the dotted string ``"2.5.4.6"``. This OID is typically seen |
| 484 | in X.509 names. |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 485 | |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 486 | .. data:: OID_LOCALITY_NAME |
| 487 | |
Paul Kehrer | 4bb4649 | 2015-02-07 16:59:14 -0600 | [diff] [blame] | 488 | Corresponds to the dotted string ``"2.5.4.7"``. This OID is typically seen |
| 489 | in X.509 names. |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 490 | |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 491 | .. data:: OID_STATE_OR_PROVINCE_NAME |
| 492 | |
Paul Kehrer | 4bb4649 | 2015-02-07 16:59:14 -0600 | [diff] [blame] | 493 | Corresponds to the dotted string ``"2.5.4.8"``. This OID is typically seen |
| 494 | in X.509 names. |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 495 | |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 496 | .. data:: OID_ORGANIZATION_NAME |
| 497 | |
Paul Kehrer | 4bb4649 | 2015-02-07 16:59:14 -0600 | [diff] [blame] | 498 | Corresponds to the dotted string ``"2.5.4.10"``. This OID is typically seen |
| 499 | in X.509 names. |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 500 | |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 501 | .. data:: OID_ORGANIZATIONAL_UNIT_NAME |
| 502 | |
Paul Kehrer | 4bb4649 | 2015-02-07 16:59:14 -0600 | [diff] [blame] | 503 | Corresponds to the dotted string ``"2.5.4.11"``. This OID is typically seen |
| 504 | in X.509 names. |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 505 | |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 506 | .. data:: OID_SERIAL_NUMBER |
| 507 | |
Paul Kehrer | fb5ac9e | 2015-02-07 16:29:37 -0600 | [diff] [blame] | 508 | Corresponds to the dotted string ``"2.5.4.5"``. This is distinct from the |
| 509 | serial number of the certificate itself (which can be obtained with |
Paul Kehrer | 4bb4649 | 2015-02-07 16:59:14 -0600 | [diff] [blame] | 510 | :func:`Certificate.serial`). This OID is typically seen in X.509 names. |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 511 | |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 512 | .. data:: OID_SURNAME |
| 513 | |
Paul Kehrer | 4bb4649 | 2015-02-07 16:59:14 -0600 | [diff] [blame] | 514 | Corresponds to the dotted string ``"2.5.4.4"``. This OID is typically seen |
| 515 | in X.509 names. |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 516 | |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 517 | .. data:: OID_GIVEN_NAME |
| 518 | |
Paul Kehrer | 4bb4649 | 2015-02-07 16:59:14 -0600 | [diff] [blame] | 519 | Corresponds to the dotted string ``"2.5.4.42"``. This OID is typically seen |
| 520 | in X.509 names. |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 521 | |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 522 | .. data:: OID_TITLE |
| 523 | |
Paul Kehrer | 4bb4649 | 2015-02-07 16:59:14 -0600 | [diff] [blame] | 524 | Corresponds to the dotted string ``"2.5.4.12"``. This OID is typically seen |
| 525 | in X.509 names. |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 526 | |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 527 | .. data:: OID_GENERATION_QUALIFIER |
| 528 | |
Paul Kehrer | 4bb4649 | 2015-02-07 16:59:14 -0600 | [diff] [blame] | 529 | Corresponds to the dotted string ``"2.5.4.44"``. This OID is typically seen |
| 530 | in X.509 names. |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 531 | |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 532 | .. data:: OID_DN_QUALIFIER |
| 533 | |
Paul Kehrer | fb5ac9e | 2015-02-07 16:29:37 -0600 | [diff] [blame] | 534 | Corresponds to the dotted string ``"2.5.4.46"``. This specifies |
| 535 | disambiguating information to add to the relative distinguished name of an |
Paul Kehrer | 4bb4649 | 2015-02-07 16:59:14 -0600 | [diff] [blame] | 536 | entry. See :rfc:`2256`. This OID is typically seen in X.509 names. |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 537 | |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 538 | .. data:: OID_PSEUDONYM |
| 539 | |
Paul Kehrer | 4bb4649 | 2015-02-07 16:59:14 -0600 | [diff] [blame] | 540 | Corresponds to the dotted string ``"2.5.4.65"``. This OID is typically seen |
| 541 | in X.509 names. |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 542 | |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 543 | .. data:: OID_DOMAIN_COMPONENT |
| 544 | |
Paul Kehrer | fb5ac9e | 2015-02-07 16:29:37 -0600 | [diff] [blame] | 545 | Corresponds to the dotted string ``"0.9.2342.19200300.100.1.25"``. A string |
Paul Kehrer | 4bb4649 | 2015-02-07 16:59:14 -0600 | [diff] [blame] | 546 | holding one component of a domain name. See :rfc:`4519`. This OID is |
| 547 | typically seen in X.509 names. |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 548 | |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 549 | .. data:: OID_EMAIL_ADDRESS |
| 550 | |
Paul Kehrer | 4bb4649 | 2015-02-07 16:59:14 -0600 | [diff] [blame] | 551 | Corresponds to the dotted string ``"1.2.840.113549.1.9.1"``. This OID is |
| 552 | typically seen in X.509 names. |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 553 | |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 554 | Signature Algorithm OIDs |
| 555 | ~~~~~~~~~~~~~~~~~~~~~~~~ |
| 556 | |
Paul Kehrer | 1a7ba87 | 2015-02-19 18:09:05 -0600 | [diff] [blame] | 557 | .. data:: OID_RSA_WITH_MD5 |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 558 | |
| 559 | Corresponds to the dotted string ``"1.2.840.113549.1.1.4"``. This is |
| 560 | an MD5 digest signed by an RSA key. |
| 561 | |
Paul Kehrer | 1a7ba87 | 2015-02-19 18:09:05 -0600 | [diff] [blame] | 562 | .. data:: OID_RSA_WITH_SHA1 |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 563 | |
| 564 | Corresponds to the dotted string ``"1.2.840.113549.1.1.5"``. This is |
| 565 | a SHA1 digest signed by an RSA key. |
| 566 | |
Paul Kehrer | 1a7ba87 | 2015-02-19 18:09:05 -0600 | [diff] [blame] | 567 | .. data:: OID_RSA_WITH_SHA224 |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 568 | |
| 569 | Corresponds to the dotted string ``"1.2.840.113549.1.1.14"``. This is |
| 570 | a SHA224 digest signed by an RSA key. |
| 571 | |
Paul Kehrer | 1a7ba87 | 2015-02-19 18:09:05 -0600 | [diff] [blame] | 572 | .. data:: OID_RSA_WITH_SHA256 |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 573 | |
| 574 | Corresponds to the dotted string ``"1.2.840.113549.1.1.11"``. This is |
| 575 | a SHA256 digest signed by an RSA key. |
| 576 | |
Paul Kehrer | 1a7ba87 | 2015-02-19 18:09:05 -0600 | [diff] [blame] | 577 | .. data:: OID_RSA_WITH_SHA384 |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 578 | |
| 579 | Corresponds to the dotted string ``"1.2.840.113549.1.1.12"``. This is |
| 580 | a SHA384 digest signed by an RSA key. |
| 581 | |
Paul Kehrer | 1a7ba87 | 2015-02-19 18:09:05 -0600 | [diff] [blame] | 582 | .. data:: OID_RSA_WITH_SHA512 |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 583 | |
| 584 | Corresponds to the dotted string ``"1.2.840.113549.1.1.13"``. This is |
| 585 | a SHA512 digest signed by an RSA key. |
| 586 | |
| 587 | .. data:: OID_ECDSA_WITH_SHA224 |
| 588 | |
| 589 | Corresponds to the dotted string ``"1.2.840.10045.4.3.1"``. This is |
| 590 | a SHA224 digest signed by an ECDSA key. |
| 591 | |
| 592 | .. data:: OID_ECDSA_WITH_SHA256 |
| 593 | |
| 594 | Corresponds to the dotted string ``"1.2.840.10045.4.3.2"``. This is |
| 595 | a SHA256 digest signed by an ECDSA key. |
| 596 | |
| 597 | .. data:: OID_ECDSA_WITH_SHA384 |
| 598 | |
| 599 | Corresponds to the dotted string ``"1.2.840.10045.4.3.3"``. This is |
| 600 | a SHA384 digest signed by an ECDSA key. |
| 601 | |
| 602 | .. data:: OID_ECDSA_WITH_SHA512 |
| 603 | |
| 604 | Corresponds to the dotted string ``"1.2.840.10045.4.3.4"``. This is |
| 605 | a SHA512 digest signed by an ECDSA key. |
| 606 | |
| 607 | .. data:: OID_DSA_WITH_SHA1 |
| 608 | |
| 609 | Corresponds to the dotted string ``"1.2.840.10040.4.3"``. This is |
| 610 | a SHA1 digest signed by a DSA key. |
| 611 | |
| 612 | .. data:: OID_DSA_WITH_SHA224 |
| 613 | |
| 614 | Corresponds to the dotted string ``"2.16.840.1.101.3.4.3.1"``. This is |
| 615 | a SHA224 digest signed by a DSA key. |
| 616 | |
| 617 | .. data:: OID_DSA_WITH_SHA256 |
| 618 | |
Paul Kehrer | fbb7ac8 | 2015-03-16 19:26:29 -0500 | [diff] [blame] | 619 | Corresponds to the dotted string ``"2.16.840.1.101.3.4.3.2"``. This is |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 620 | a SHA256 digest signed by a DSA key. |
| 621 | |
Paul Kehrer | 5553d57 | 2015-03-23 21:08:01 -0500 | [diff] [blame] | 622 | .. _extension_oids: |
| 623 | |
Paul Kehrer | 2bb9464 | 2015-03-21 09:54:17 -0500 | [diff] [blame] | 624 | Extension OIDs |
| 625 | ~~~~~~~~~~~~~~ |
| 626 | |
| 627 | .. data:: OID_BASIC_CONSTRAINTS |
| 628 | |
| 629 | Corresponds to the dotted string ``"2.5.29.19"``. The identifier for the |
Paul Kehrer | 611d3d3 | 2015-03-22 13:31:18 -0500 | [diff] [blame] | 630 | :class:`BasicConstraints` extension type. |
Paul Kehrer | 2bb9464 | 2015-03-21 09:54:17 -0500 | [diff] [blame] | 631 | |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 632 | |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 633 | Exceptions |
| 634 | ~~~~~~~~~~ |
| 635 | |
Paul Kehrer | e76cd27 | 2014-12-14 19:00:51 -0600 | [diff] [blame] | 636 | .. class:: InvalidVersion |
Paul Kehrer | a68fd33 | 2014-11-27 07:08:40 -1000 | [diff] [blame] | 637 | |
| 638 | This is raised when an X.509 certificate has an invalid version number. |
Paul Kehrer | 016e08a | 2014-11-26 09:41:18 -1000 | [diff] [blame] | 639 | |
Paul Kehrer | d5cccf7 | 2014-12-15 17:20:33 -0600 | [diff] [blame] | 640 | .. attribute:: parsed_version |
| 641 | |
Paul Kehrer | bbffc40 | 2014-12-17 13:33:55 -0600 | [diff] [blame] | 642 | :type: int |
| 643 | |
| 644 | Returns the raw version that was parsed from the certificate. |
Paul Kehrer | d5cccf7 | 2014-12-15 17:20:33 -0600 | [diff] [blame] | 645 | |
Paul Kehrer | fbb7ac8 | 2015-03-16 19:26:29 -0500 | [diff] [blame] | 646 | .. class:: DuplicateExtension |
| 647 | |
| 648 | This is raised when more than one X.509 extension of the same type is |
| 649 | found within a certificate. |
| 650 | |
| 651 | .. attribute:: oid |
| 652 | |
| 653 | :type: :class:`ObjectIdentifier` |
| 654 | |
| 655 | Returns the OID. |
| 656 | |
| 657 | .. class:: UnsupportedExtension |
| 658 | |
| 659 | This is raised when a certificate contains an unsupported extension type. |
| 660 | |
| 661 | .. attribute:: oid |
| 662 | |
| 663 | :type: :class:`ObjectIdentifier` |
| 664 | |
| 665 | Returns the OID. |
| 666 | |
Paul Kehrer | fa56a23 | 2015-03-17 13:14:03 -0500 | [diff] [blame] | 667 | .. class:: ExtensionNotFound |
| 668 | |
| 669 | This is raised when calling :meth:`Extensions.get_extension_for_oid` with |
| 670 | an extension OID that is not present in the certificate. |
| 671 | |
| 672 | .. attribute:: oid |
| 673 | |
| 674 | :type: :class:`ObjectIdentifier` |
| 675 | |
| 676 | Returns the OID. |
| 677 | |
Paul Kehrer | 016e08a | 2014-11-26 09:41:18 -1000 | [diff] [blame] | 678 | |
| 679 | .. _`public key infrastructure`: https://en.wikipedia.org/wiki/Public_key_infrastructure |
Paul Kehrer | a68fd33 | 2014-11-27 07:08:40 -1000 | [diff] [blame] | 680 | .. _`TLS`: https://en.wikipedia.org/wiki/Transport_Layer_Security |