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