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 | |
Paul Kehrer | 93ae805 | 2015-05-02 23:18:09 -0500 | [diff] [blame] | 53 | cryptography_cert_pem = b""" |
| 54 | -----BEGIN CERTIFICATE----- |
| 55 | MIIFvTCCBKWgAwIBAgICPyAwDQYJKoZIhvcNAQELBQAwRzELMAkGA1UEBhMCVVMx |
| 56 | FjAUBgNVBAoTDUdlb1RydXN0IEluYy4xIDAeBgNVBAMTF1JhcGlkU1NMIFNIQTI1 |
| 57 | NiBDQSAtIEczMB4XDTE0MTAxNTEyMDkzMloXDTE4MTExNjAxMTUwM1owgZcxEzAR |
| 58 | BgNVBAsTCkdUNDg3NDI5NjUxMTAvBgNVBAsTKFNlZSB3d3cucmFwaWRzc2wuY29t |
| 59 | L3Jlc291cmNlcy9jcHMgKGMpMTQxLzAtBgNVBAsTJkRvbWFpbiBDb250cm9sIFZh |
| 60 | bGlkYXRlZCAtIFJhcGlkU1NMKFIpMRwwGgYDVQQDExN3d3cuY3J5cHRvZ3JhcGh5 |
| 61 | LmlvMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAom/FebKJIot7Sp3s |
| 62 | itG1sicpe3thCssjI+g1JDAS7I3GLVNmbms1DOdIIqwf01gZkzzXBN2+9sOnyRaR |
| 63 | PPfCe1jTr3dk2y6rPE559vPa1nZQkhlzlhMhlPyjaT+S7g4Tio4qV2sCBZU01DZJ |
| 64 | CaksfohN+5BNVWoJzTbOcrHOEJ+M8B484KlBCiSxqf9cyNQKru4W3bHaCVNVJ8eu |
| 65 | 6i6KyhzLa0L7yK3LXwwXVs583C0/vwFhccGWsFODqD/9xHUzsBIshE8HKjdjDi7Y |
| 66 | 3BFQzVUQFjBB50NSZfAA/jcdt1blxJouc7z9T8Oklh+V5DDBowgAsrT4b6Z2Fq6/ |
| 67 | r7D1GqivLK/ypUQmxq2WXWAUBb/Q6xHgxASxI4Br+CByIUQJsm8L2jzc7k+mF4hW |
| 68 | ltAIUkbo8fGiVnat0505YJgxWEDKOLc4Gda6d/7GVd5AvKrz242bUqeaWo6e4MTx |
| 69 | diku2Ma3rhdcr044Qvfh9hGyjqNjvhWY/I+VRWgihU7JrYvgwFdJqsQ5eiKT4OHi |
| 70 | gsejvWwkZzDtiQ+aQTrzM1FsY2swJBJsLSX4ofohlVRlIJCn/ME+XErj553431Lu |
| 71 | YQ5SzMd3nXzN78Vj6qzTfMUUY72UoT1/AcFiUMobgIqrrmwuNxfrkbVE2b6Bga74 |
| 72 | FsJX63prvrJ41kuHK/16RQBM7fcCAwEAAaOCAWAwggFcMB8GA1UdIwQYMBaAFMOc |
| 73 | 8/zTRgg0u85Gf6B8W/PiCMtZMFcGCCsGAQUFBwEBBEswSTAfBggrBgEFBQcwAYYT |
| 74 | aHR0cDovL2d2LnN5bWNkLmNvbTAmBggrBgEFBQcwAoYaaHR0cDovL2d2LnN5bWNi |
| 75 | LmNvbS9ndi5jcnQwDgYDVR0PAQH/BAQDAgWgMB0GA1UdJQQWMBQGCCsGAQUFBwMB |
| 76 | BggrBgEFBQcDAjAvBgNVHREEKDAmghN3d3cuY3J5cHRvZ3JhcGh5Lmlvgg9jcnlw |
| 77 | dG9ncmFwaHkuaW8wKwYDVR0fBCQwIjAgoB6gHIYaaHR0cDovL2d2LnN5bWNiLmNv |
| 78 | bS9ndi5jcmwwDAYDVR0TAQH/BAIwADBFBgNVHSAEPjA8MDoGCmCGSAGG+EUBBzYw |
| 79 | LDAqBggrBgEFBQcCARYeaHR0cHM6Ly93d3cucmFwaWRzc2wuY29tL2xlZ2FsMA0G |
| 80 | CSqGSIb3DQEBCwUAA4IBAQAzIYO2jx7h17FBT74tJ2zbV9OKqGb7QF8y3wUtP4xc |
| 81 | dH80vprI/Cfji8s86kr77aAvAqjDjaVjHn7UzebhSUivvRPmfzRgyWBacomnXTSt |
| 82 | Xlt2dp2nDQuwGyK2vB7dMfKnQAkxwq1sYUXznB8i0IhhCAoXp01QGPKq51YoIlnF |
| 83 | 7DRMk6iEaL1SJbkIrLsCQyZFDf0xtfW9DqXugMMLoxeCsBhZJQzNyS2ryirrv9LH |
| 84 | aK3+6IZjrcyy9bkpz/gzJucyhU+75c4My/mnRCrtItRbCQuiI5pd5poDowm+HH9i |
| 85 | GVI9+0lAFwxOUnOnwsoI40iOoxjLMGB+CgFLKCGUcWxP |
| 86 | -----END CERTIFICATE----- |
| 87 | """.strip() |
| 88 | |
Paul Kehrer | d3dafbd | 2015-03-15 16:24:18 -0500 | [diff] [blame] | 89 | X.509 is an ITU-T standard for a `public key infrastructure`_. X.509v3 is |
| 90 | defined in :rfc:`5280` (which obsoletes :rfc:`2459` and :rfc:`3280`). X.509 |
| 91 | certificates are commonly used in protocols like `TLS`_. |
Paul Kehrer | b2de948 | 2014-12-11 14:54:48 -0600 | [diff] [blame] | 92 | |
| 93 | Loading Certificates |
| 94 | ~~~~~~~~~~~~~~~~~~~~ |
Paul Kehrer | 016e08a | 2014-11-26 09:41:18 -1000 | [diff] [blame] | 95 | |
| 96 | .. function:: load_pem_x509_certificate(data, backend) |
| 97 | |
| 98 | .. versionadded:: 0.7 |
| 99 | |
Paul Kehrer | e76cd27 | 2014-12-14 19:00:51 -0600 | [diff] [blame] | 100 | Deserialize a certificate from PEM encoded data. PEM certificates are |
| 101 | base64 decoded and have delimiters that look like |
| 102 | ``-----BEGIN CERTIFICATE-----``. |
Paul Kehrer | 016e08a | 2014-11-26 09:41:18 -1000 | [diff] [blame] | 103 | |
| 104 | :param bytes data: The PEM encoded certificate data. |
| 105 | |
| 106 | :param backend: A backend supporting the |
| 107 | :class:`~cryptography.hazmat.backends.interfaces.X509Backend` |
| 108 | interface. |
| 109 | |
Paul Kehrer | e76cd27 | 2014-12-14 19:00:51 -0600 | [diff] [blame] | 110 | :returns: An instance of :class:`~cryptography.x509.Certificate`. |
Paul Kehrer | 016e08a | 2014-11-26 09:41:18 -1000 | [diff] [blame] | 111 | |
| 112 | .. function:: load_der_x509_certificate(data, backend) |
| 113 | |
| 114 | .. versionadded:: 0.7 |
| 115 | |
Paul Kehrer | e76cd27 | 2014-12-14 19:00:51 -0600 | [diff] [blame] | 116 | Deserialize a certificate from DER encoded data. DER is a binary format |
Paul Kehrer | 92aac38 | 2014-12-15 16:25:28 -0600 | [diff] [blame] | 117 | and is commonly found in files with the ``.cer`` extension (although file |
| 118 | extensions are not a guarantee of encoding type). |
Paul Kehrer | 016e08a | 2014-11-26 09:41:18 -1000 | [diff] [blame] | 119 | |
| 120 | :param bytes data: The DER encoded certificate data. |
| 121 | |
| 122 | :param backend: A backend supporting the |
| 123 | :class:`~cryptography.hazmat.backends.interfaces.X509Backend` |
| 124 | interface. |
| 125 | |
Paul Kehrer | e76cd27 | 2014-12-14 19:00:51 -0600 | [diff] [blame] | 126 | :returns: An instance of :class:`~cryptography.x509.Certificate`. |
Paul Kehrer | 016e08a | 2014-11-26 09:41:18 -1000 | [diff] [blame] | 127 | |
Paul Kehrer | 016e08a | 2014-11-26 09:41:18 -1000 | [diff] [blame] | 128 | .. doctest:: |
| 129 | |
Paul Kehrer | cc8a26e | 2014-12-16 12:40:16 -0600 | [diff] [blame] | 130 | >>> from cryptography import x509 |
Paul Kehrer | 016e08a | 2014-11-26 09:41:18 -1000 | [diff] [blame] | 131 | >>> from cryptography.hazmat.backends import default_backend |
Paul Kehrer | cc8a26e | 2014-12-16 12:40:16 -0600 | [diff] [blame] | 132 | >>> cert = x509.load_pem_x509_certificate(pem_data, default_backend()) |
Paul Kehrer | 016e08a | 2014-11-26 09:41:18 -1000 | [diff] [blame] | 133 | >>> cert.serial |
| 134 | 2 |
| 135 | |
Paul Kehrer | a1a1f23 | 2015-03-15 15:34:35 -0500 | [diff] [blame] | 136 | Loading Certificate Signing Requests |
| 137 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
Paul Kehrer | dc480ad | 2015-02-23 12:14:54 -0600 | [diff] [blame] | 138 | |
Paul Kehrer | 31e3988 | 2015-03-11 11:37:04 -0500 | [diff] [blame] | 139 | .. function:: load_pem_x509_csr(data, backend) |
Paul Kehrer | dc480ad | 2015-02-23 12:14:54 -0600 | [diff] [blame] | 140 | |
| 141 | .. versionadded:: 0.9 |
| 142 | |
Paul Kehrer | a1a1f23 | 2015-03-15 15:34:35 -0500 | [diff] [blame] | 143 | Deserialize a certificate signing request (CSR) from PEM encoded data. PEM |
Paul Kehrer | 5aadb9c | 2015-03-11 20:48:42 -0500 | [diff] [blame] | 144 | requests are base64 decoded and have delimiters that look like |
Paul Kehrer | d3dafbd | 2015-03-15 16:24:18 -0500 | [diff] [blame] | 145 | ``-----BEGIN CERTIFICATE REQUEST-----``. This format is also known as |
| 146 | PKCS#10. |
Paul Kehrer | dc480ad | 2015-02-23 12:14:54 -0600 | [diff] [blame] | 147 | |
| 148 | :param bytes data: The PEM encoded request data. |
| 149 | |
| 150 | :param backend: A backend supporting the |
| 151 | :class:`~cryptography.hazmat.backends.interfaces.X509Backend` |
| 152 | interface. |
| 153 | |
Paul Kehrer | a1a1f23 | 2015-03-15 15:34:35 -0500 | [diff] [blame] | 154 | :returns: An instance of |
| 155 | :class:`~cryptography.x509.CertificateSigningRequest`. |
Paul Kehrer | dc480ad | 2015-02-23 12:14:54 -0600 | [diff] [blame] | 156 | |
Paul Kehrer | 1effb6e | 2015-03-30 15:05:59 -0500 | [diff] [blame] | 157 | .. function:: load_der_x509_csr(data, backend) |
| 158 | |
| 159 | .. versionadded:: 0.9 |
| 160 | |
| 161 | Deserialize a certificate signing request (CSR) from DER encoded data. DER |
| 162 | is a binary format and is not commonly used with CSRs. |
| 163 | |
| 164 | :param bytes data: The DER encoded request data. |
| 165 | |
| 166 | :param backend: A backend supporting the |
| 167 | :class:`~cryptography.hazmat.backends.interfaces.X509Backend` |
| 168 | interface. |
| 169 | |
| 170 | :returns: An instance of |
| 171 | :class:`~cryptography.x509.CertificateSigningRequest`. |
| 172 | |
Paul Kehrer | dc480ad | 2015-02-23 12:14:54 -0600 | [diff] [blame] | 173 | .. doctest:: |
| 174 | |
| 175 | >>> from cryptography import x509 |
| 176 | >>> from cryptography.hazmat.backends import default_backend |
| 177 | >>> from cryptography.hazmat.primitives import hashes |
Paul Kehrer | a1a1f23 | 2015-03-15 15:34:35 -0500 | [diff] [blame] | 178 | >>> csr = x509.load_pem_x509_csr(pem_req_data, default_backend()) |
| 179 | >>> isinstance(csr.signature_hash_algorithm, hashes.SHA1) |
Paul Kehrer | dc480ad | 2015-02-23 12:14:54 -0600 | [diff] [blame] | 180 | True |
| 181 | |
Paul Kehrer | e76cd27 | 2014-12-14 19:00:51 -0600 | [diff] [blame] | 182 | X.509 Certificate Object |
| 183 | ~~~~~~~~~~~~~~~~~~~~~~~~ |
Paul Kehrer | b2de948 | 2014-12-11 14:54:48 -0600 | [diff] [blame] | 184 | |
Paul Kehrer | e76cd27 | 2014-12-14 19:00:51 -0600 | [diff] [blame] | 185 | .. class:: Certificate |
Paul Kehrer | b2de948 | 2014-12-11 14:54:48 -0600 | [diff] [blame] | 186 | |
| 187 | .. versionadded:: 0.7 |
| 188 | |
| 189 | .. attribute:: version |
| 190 | |
Paul Kehrer | e76cd27 | 2014-12-14 19:00:51 -0600 | [diff] [blame] | 191 | :type: :class:`~cryptography.x509.Version` |
Paul Kehrer | b2de948 | 2014-12-11 14:54:48 -0600 | [diff] [blame] | 192 | |
Paul Kehrer | e76cd27 | 2014-12-14 19:00:51 -0600 | [diff] [blame] | 193 | The certificate version as an enumeration. Version 3 certificates are |
| 194 | the latest version and also the only type you should see in practice. |
Paul Kehrer | b2de948 | 2014-12-11 14:54:48 -0600 | [diff] [blame] | 195 | |
Alex Gaynor | 89c4dc8 | 2014-12-16 16:49:33 -0800 | [diff] [blame] | 196 | :raises cryptography.x509.InvalidVersion: If the version in the |
Alex Gaynor | 6d7ab4c | 2014-12-16 16:50:33 -0800 | [diff] [blame] | 197 | certificate is not a known |
| 198 | :class:`X.509 version <cryptography.x509.Version>`. |
Paul Kehrer | 92aac38 | 2014-12-15 16:25:28 -0600 | [diff] [blame] | 199 | |
Paul Kehrer | cc8a26e | 2014-12-16 12:40:16 -0600 | [diff] [blame] | 200 | .. doctest:: |
| 201 | |
| 202 | >>> cert.version |
| 203 | <Version.v3: 2> |
| 204 | |
Paul Kehrer | b2de948 | 2014-12-11 14:54:48 -0600 | [diff] [blame] | 205 | .. method:: fingerprint(algorithm) |
| 206 | |
| 207 | :param algorithm: The |
Paul Kehrer | 601278a | 2015-02-12 12:51:00 -0600 | [diff] [blame] | 208 | :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` |
Paul Kehrer | b2de948 | 2014-12-11 14:54:48 -0600 | [diff] [blame] | 209 | that will be used to generate the fingerprint. |
| 210 | |
Erik Trauschke | 2dcce90 | 2015-05-14 16:12:24 -0700 | [diff] [blame] | 211 | :return bytes: The fingerprint using the supplied hash algorithm, as |
Paul Kehrer | b2de948 | 2014-12-11 14:54:48 -0600 | [diff] [blame] | 212 | bytes. |
| 213 | |
Paul Kehrer | cc8a26e | 2014-12-16 12:40:16 -0600 | [diff] [blame] | 214 | .. doctest:: |
| 215 | |
| 216 | >>> from cryptography.hazmat.primitives import hashes |
| 217 | >>> cert.fingerprint(hashes.SHA256()) |
Paul Kehrer | 78a8150 | 2014-12-16 14:47:52 -0600 | [diff] [blame] | 218 | '\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] | 219 | |
Paul Kehrer | b2de948 | 2014-12-11 14:54:48 -0600 | [diff] [blame] | 220 | .. attribute:: serial |
| 221 | |
| 222 | :type: int |
| 223 | |
| 224 | The serial as a Python integer. |
| 225 | |
Paul Kehrer | cc8a26e | 2014-12-16 12:40:16 -0600 | [diff] [blame] | 226 | .. doctest:: |
| 227 | |
| 228 | >>> cert.serial |
| 229 | 2 |
| 230 | |
Paul Kehrer | b2de948 | 2014-12-11 14:54:48 -0600 | [diff] [blame] | 231 | .. method:: public_key() |
| 232 | |
| 233 | :type: |
Alex Stapleton | f79c231 | 2014-12-30 12:50:14 +0000 | [diff] [blame] | 234 | :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey` or |
Paul Kehrer | 45efdbc | 2015-02-12 10:58:22 -0600 | [diff] [blame] | 235 | :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPublicKey` or |
| 236 | :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey` |
Paul Kehrer | b2de948 | 2014-12-11 14:54:48 -0600 | [diff] [blame] | 237 | |
| 238 | The public key associated with the certificate. |
| 239 | |
Paul Kehrer | cc8a26e | 2014-12-16 12:40:16 -0600 | [diff] [blame] | 240 | .. doctest:: |
| 241 | |
Alex Stapleton | f79c231 | 2014-12-30 12:50:14 +0000 | [diff] [blame] | 242 | >>> from cryptography.hazmat.primitives.asymmetric import rsa |
Paul Kehrer | cc8a26e | 2014-12-16 12:40:16 -0600 | [diff] [blame] | 243 | >>> public_key = cert.public_key() |
Alex Stapleton | f79c231 | 2014-12-30 12:50:14 +0000 | [diff] [blame] | 244 | >>> isinstance(public_key, rsa.RSAPublicKey) |
Paul Kehrer | cc8a26e | 2014-12-16 12:40:16 -0600 | [diff] [blame] | 245 | True |
| 246 | |
Paul Kehrer | b2de948 | 2014-12-11 14:54:48 -0600 | [diff] [blame] | 247 | .. attribute:: not_valid_before |
| 248 | |
| 249 | :type: :class:`datetime.datetime` |
| 250 | |
Paul Kehrer | 78a8150 | 2014-12-16 14:47:52 -0600 | [diff] [blame] | 251 | A naïve datetime representing the beginning of the validity period for |
| 252 | the certificate in UTC. This value is inclusive. |
Paul Kehrer | b2de948 | 2014-12-11 14:54:48 -0600 | [diff] [blame] | 253 | |
Paul Kehrer | cc8a26e | 2014-12-16 12:40:16 -0600 | [diff] [blame] | 254 | .. doctest:: |
| 255 | |
| 256 | >>> cert.not_valid_before |
| 257 | datetime.datetime(2010, 1, 1, 8, 30) |
| 258 | |
Paul Kehrer | b2de948 | 2014-12-11 14:54:48 -0600 | [diff] [blame] | 259 | .. attribute:: not_valid_after |
| 260 | |
| 261 | :type: :class:`datetime.datetime` |
| 262 | |
Paul Kehrer | 78a8150 | 2014-12-16 14:47:52 -0600 | [diff] [blame] | 263 | A naïve datetime representing the end of the validity period for the |
| 264 | certificate in UTC. This value is inclusive. |
Paul Kehrer | b2de948 | 2014-12-11 14:54:48 -0600 | [diff] [blame] | 265 | |
Paul Kehrer | cc8a26e | 2014-12-16 12:40:16 -0600 | [diff] [blame] | 266 | .. doctest:: |
| 267 | |
| 268 | >>> cert.not_valid_after |
| 269 | datetime.datetime(2030, 12, 31, 8, 30) |
| 270 | |
Paul Kehrer | 719d536 | 2015-01-01 20:03:52 -0600 | [diff] [blame] | 271 | .. attribute:: issuer |
| 272 | |
| 273 | .. versionadded:: 0.8 |
| 274 | |
| 275 | :type: :class:`Name` |
| 276 | |
| 277 | The :class:`Name` of the issuer. |
| 278 | |
| 279 | .. attribute:: subject |
| 280 | |
| 281 | .. versionadded:: 0.8 |
| 282 | |
| 283 | :type: :class:`Name` |
| 284 | |
| 285 | The :class:`Name` of the subject. |
| 286 | |
Paul Kehrer | 8802a5b | 2015-02-13 12:06:57 -0600 | [diff] [blame] | 287 | .. attribute:: signature_hash_algorithm |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 288 | |
Paul Kehrer | 8802a5b | 2015-02-13 12:06:57 -0600 | [diff] [blame] | 289 | :type: :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 290 | |
Paul Kehrer | e612ec7 | 2015-02-16 14:33:35 -0600 | [diff] [blame] | 291 | Returns the |
Paul Kehrer | 71d40c6 | 2015-02-19 08:21:04 -0600 | [diff] [blame] | 292 | :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` which |
Paul Kehrer | 1a7ba87 | 2015-02-19 18:09:05 -0600 | [diff] [blame] | 293 | was used in signing this certificate. |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 294 | |
| 295 | .. doctest:: |
| 296 | |
Paul Kehrer | 8802a5b | 2015-02-13 12:06:57 -0600 | [diff] [blame] | 297 | >>> from cryptography.hazmat.primitives import hashes |
| 298 | >>> isinstance(cert.signature_hash_algorithm, hashes.SHA256) |
| 299 | True |
Paul Kehrer | 719d536 | 2015-01-01 20:03:52 -0600 | [diff] [blame] | 300 | |
Paul Kehrer | fbb7ac8 | 2015-03-16 19:26:29 -0500 | [diff] [blame] | 301 | .. attribute:: extensions |
| 302 | |
| 303 | :type: :class:`Extensions` |
| 304 | |
| 305 | The extensions encoded in the certificate. |
| 306 | |
| 307 | :raises cryptography.x509.DuplicateExtension: If more than one |
| 308 | extension of the same type is found within the certificate. |
| 309 | |
Paul Kehrer | d8fc0be | 2015-04-21 08:31:10 -0500 | [diff] [blame] | 310 | :raises cryptography.x509.UnsupportedExtension: If the certificate |
| 311 | contains an extension that is not supported. |
| 312 | |
Paul Kehrer | bed0735 | 2015-04-21 08:31:10 -0500 | [diff] [blame] | 313 | :raises cryptography.x509.UnsupportedGeneralNameType: If an extension |
| 314 | contains a general name that is not supported. |
| 315 | |
Paul Kehrer | b896881 | 2015-05-15 09:01:34 -0700 | [diff] [blame] | 316 | :raises UnicodeError: If an extension contains IDNA encoding that is |
| 317 | invalid or not compliant with IDNA 2008. |
| 318 | |
Paul Kehrer | fa56a23 | 2015-03-17 13:14:03 -0500 | [diff] [blame] | 319 | .. doctest:: |
| 320 | |
| 321 | >>> for ext in cert.extensions: |
| 322 | ... print(ext) |
Paul Kehrer | d774de9 | 2015-05-03 10:52:25 -0500 | [diff] [blame] | 323 | <Extension(oid=<ObjectIdentifier(oid=2.5.29.35, name=authorityKeyIdentifier)>, critical=False, value=<AuthorityKeyIdentifier(key_identifier='\xe4}_\xd1\\\x95\x86\x08,\x05\xae\xbeu\xb6e\xa7\xd9]\xa8f', authority_cert_issuer=None, authority_cert_serial_number=None)>)> |
Paul Kehrer | cbfb101 | 2015-04-10 20:57:20 -0400 | [diff] [blame] | 324 | <Extension(oid=<ObjectIdentifier(oid=2.5.29.14, name=subjectKeyIdentifier)>, critical=False, value=<SubjectKeyIdentifier(digest='X\x01\x84$\x1b\xbc+R\x94J=\xa5\x10r\x14Q\xf5\xaf:\xc9')>)> |
Paul Kehrer | b511ba8 | 2015-04-15 11:22:48 -0400 | [diff] [blame] | 325 | <Extension(oid=<ObjectIdentifier(oid=2.5.29.15, name=keyUsage)>, critical=True, value=<KeyUsage(digital_signature=False, content_commitment=False, key_encipherment=False, data_encipherment=False, key_agreement=False, key_cert_sign=True, crl_sign=True, encipher_only=None, decipher_only=None)>)> |
Paul Kehrer | 2008d9c | 2015-05-12 22:19:56 -0500 | [diff] [blame] | 326 | <Extension(oid=<ObjectIdentifier(oid=2.5.29.32, name=certificatePolicies)>, critical=False, value=<CertificatePolicies([<PolicyInformation(policy_identifier=<ObjectIdentifier(oid=2.16.840.1.101.3.2.1.48.1, name=Unknown OID)>, policy_qualifiers=None)>])>)> |
Paul Kehrer | fa56a23 | 2015-03-17 13:14:03 -0500 | [diff] [blame] | 327 | <Extension(oid=<ObjectIdentifier(oid=2.5.29.19, name=basicConstraints)>, critical=True, value=<BasicConstraints(ca=True, path_length=None)>)> |
| 328 | |
Andre Caron | a8aded6 | 2015-05-19 20:11:57 -0400 | [diff] [blame] | 329 | .. method:: public_bytes(encoding) |
| 330 | |
| 331 | :param encoding: The |
| 332 | :class:`~cryptography.hazmat.primitives.serialization.Encoding` |
| 333 | that will be used to serialize the certificate. |
| 334 | |
| 335 | :return bytes: The data that can be written to a file or sent |
| 336 | over the network to be verified by clients. |
| 337 | |
Erik Trauschke | 2dcce90 | 2015-05-14 16:12:24 -0700 | [diff] [blame] | 338 | X.509 CRL (Certificate Revocation List) Object |
| 339 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 340 | |
| 341 | .. class:: CertificateRevocationList |
| 342 | |
| 343 | .. versionadded:: 1.0 |
| 344 | |
| 345 | .. method:: fingerprint(algorithm) |
| 346 | |
| 347 | :param algorithm: The |
| 348 | :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` |
| 349 | that will be used to generate the fingerprint. |
| 350 | |
| 351 | :return bytes: The fingerprint using the supplied hash algorithm, as |
| 352 | bytes. |
| 353 | |
| 354 | .. attribute:: signature_hash_algorithm |
| 355 | |
| 356 | :type: :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` |
| 357 | |
| 358 | Returns the |
| 359 | :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` which |
| 360 | was used in signing this CRL. |
| 361 | |
| 362 | .. attribute:: issuer |
| 363 | |
| 364 | :type: :class:`Name` |
| 365 | |
| 366 | The :class:`Name` of the issuer. |
| 367 | |
| 368 | .. attribute:: next_update |
| 369 | |
| 370 | :type: :class:`datetime.datetime` |
| 371 | |
| 372 | A naïve datetime representing when the next update to this CRL is |
| 373 | expected. |
| 374 | |
| 375 | .. attribute:: last_update |
| 376 | |
| 377 | :type: :class:`datetime.datetime` |
| 378 | |
| 379 | A naïve datetime representing when the this CRL was last updated. |
| 380 | |
Erik Trauschke | abb7b6e | 2015-05-27 15:07:35 -0700 | [diff] [blame] | 381 | .. attribute:: revoked_certificates |
Erik Trauschke | 2dcce90 | 2015-05-14 16:12:24 -0700 | [diff] [blame] | 382 | |
| 383 | :type: list of :class:`RevokedCertificate` |
| 384 | |
| 385 | The revoked certificates listed in this CRL. |
| 386 | |
| 387 | .. attribute:: extensions |
| 388 | |
| 389 | :type: :class:`Extensions` |
| 390 | |
| 391 | The extensions encoded in the CRL. |
| 392 | |
Paul Kehrer | 5aadb9c | 2015-03-11 20:48:42 -0500 | [diff] [blame] | 393 | X.509 CSR (Certificate Signing Request) Object |
| 394 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
Paul Kehrer | dc480ad | 2015-02-23 12:14:54 -0600 | [diff] [blame] | 395 | |
Paul Kehrer | a1a1f23 | 2015-03-15 15:34:35 -0500 | [diff] [blame] | 396 | .. class:: CertificateSigningRequest |
Paul Kehrer | dc480ad | 2015-02-23 12:14:54 -0600 | [diff] [blame] | 397 | |
| 398 | .. versionadded:: 0.9 |
| 399 | |
| 400 | .. method:: public_key() |
| 401 | |
| 402 | :type: |
| 403 | :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey` or |
| 404 | :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPublicKey` or |
| 405 | :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey` |
| 406 | |
| 407 | The public key associated with the request. |
| 408 | |
| 409 | .. doctest:: |
| 410 | |
| 411 | >>> from cryptography.hazmat.primitives.asymmetric import rsa |
Paul Kehrer | a1a1f23 | 2015-03-15 15:34:35 -0500 | [diff] [blame] | 412 | >>> public_key = csr.public_key() |
Paul Kehrer | dc480ad | 2015-02-23 12:14:54 -0600 | [diff] [blame] | 413 | >>> isinstance(public_key, rsa.RSAPublicKey) |
| 414 | True |
| 415 | |
| 416 | .. attribute:: subject |
| 417 | |
| 418 | :type: :class:`Name` |
| 419 | |
| 420 | The :class:`Name` of the subject. |
| 421 | |
| 422 | .. attribute:: signature_hash_algorithm |
| 423 | |
| 424 | :type: :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` |
| 425 | |
| 426 | Returns the |
| 427 | :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` which |
| 428 | was used in signing this request. |
| 429 | |
| 430 | .. doctest:: |
| 431 | |
| 432 | >>> from cryptography.hazmat.primitives import hashes |
Paul Kehrer | a1a1f23 | 2015-03-15 15:34:35 -0500 | [diff] [blame] | 433 | >>> isinstance(csr.signature_hash_algorithm, hashes.SHA1) |
Paul Kehrer | dc480ad | 2015-02-23 12:14:54 -0600 | [diff] [blame] | 434 | True |
| 435 | |
Andre Caron | 476c5df | 2015-05-18 10:23:28 -0400 | [diff] [blame] | 436 | .. method:: public_bytes(encoding) |
| 437 | |
| 438 | :param encoding: The |
| 439 | :class:`~cryptography.hazmat.primitives.serialization.Encoding` |
| 440 | that will be used to serialize the certificate request. |
| 441 | |
| 442 | :return bytes: The data that can be written to a file or sent |
| 443 | over the network to be signed by the certificate |
| 444 | authority. |
| 445 | |
Erik Trauschke | 2dcce90 | 2015-05-14 16:12:24 -0700 | [diff] [blame] | 446 | X.509 Revoked Certificate Object |
Erik Trauschke | c5a8d17 | 2015-05-28 10:24:25 -0700 | [diff] [blame] | 447 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
Erik Trauschke | 2dcce90 | 2015-05-14 16:12:24 -0700 | [diff] [blame] | 448 | |
| 449 | .. class:: RevokedCertificate |
| 450 | |
| 451 | .. versionadded:: 1.0 |
| 452 | |
| 453 | .. attribute:: serial_number |
| 454 | |
| 455 | :type: :class:`int` |
| 456 | |
| 457 | An integer representing the serial number of the revoked certificate. |
| 458 | |
| 459 | .. attribute:: revocation_date |
| 460 | |
| 461 | :type: :class:`datetime.datetime` |
| 462 | |
| 463 | A naïve datetime representing the date this certificates was revoked. |
| 464 | |
| 465 | .. attribute:: extensions |
| 466 | |
| 467 | :type: :class:`Extensions` |
| 468 | |
| 469 | The extensions encoded in the revoked certificate. |
Andre Caron | 476c5df | 2015-05-18 10:23:28 -0400 | [diff] [blame] | 470 | |
Paul Kehrer | 719d536 | 2015-01-01 20:03:52 -0600 | [diff] [blame] | 471 | .. class:: Name |
| 472 | |
| 473 | .. versionadded:: 0.8 |
| 474 | |
Paul Kehrer | 53d8d49 | 2015-02-13 18:47:30 -0600 | [diff] [blame] | 475 | 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] | 476 | 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] | 477 | obtain the specific type you want. Names are sometimes represented as a |
Paul Kehrer | 53d8d49 | 2015-02-13 18:47:30 -0600 | [diff] [blame] | 478 | slash or comma delimited string (e.g. ``/CN=mydomain.com/O=My Org/C=US`` or |
| 479 | ``CN=mydomain.com, O=My Org, C=US``). |
Paul Kehrer | 719d536 | 2015-01-01 20:03:52 -0600 | [diff] [blame] | 480 | |
Paul Kehrer | 53d8d49 | 2015-02-13 18:47:30 -0600 | [diff] [blame] | 481 | .. doctest:: |
Paul Kehrer | 719d536 | 2015-01-01 20:03:52 -0600 | [diff] [blame] | 482 | |
Paul Kehrer | 8b21a4a | 2015-02-14 07:56:36 -0600 | [diff] [blame] | 483 | >>> len(cert.subject) |
Paul Kehrer | 53d8d49 | 2015-02-13 18:47:30 -0600 | [diff] [blame] | 484 | 3 |
Paul Kehrer | 8b21a4a | 2015-02-14 07:56:36 -0600 | [diff] [blame] | 485 | >>> for attribute in cert.subject: |
| 486 | ... print(attribute) |
| 487 | <NameAttribute(oid=<ObjectIdentifier(oid=2.5.4.6, name=countryName)>, value=u'US')> |
| 488 | <NameAttribute(oid=<ObjectIdentifier(oid=2.5.4.10, name=organizationName)>, value=u'Test Certificates 2011')> |
| 489 | <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] | 490 | |
Paul Kehrer | e901d64 | 2015-02-11 18:50:58 -0600 | [diff] [blame] | 491 | .. method:: get_attributes_for_oid(oid) |
Paul Kehrer | 719d536 | 2015-01-01 20:03:52 -0600 | [diff] [blame] | 492 | |
Paul Kehrer | e901d64 | 2015-02-11 18:50:58 -0600 | [diff] [blame] | 493 | :param oid: An :class:`ObjectIdentifier` instance. |
Paul Kehrer | 719d536 | 2015-01-01 20:03:52 -0600 | [diff] [blame] | 494 | |
Paul Kehrer | e901d64 | 2015-02-11 18:50:58 -0600 | [diff] [blame] | 495 | :returns: A list of :class:`NameAttribute` instances that match the |
| 496 | OID provided. If nothing matches an empty list will be returned. |
Paul Kehrer | 719d536 | 2015-01-01 20:03:52 -0600 | [diff] [blame] | 497 | |
| 498 | .. doctest:: |
| 499 | |
Paul Kehrer | e901d64 | 2015-02-11 18:50:58 -0600 | [diff] [blame] | 500 | >>> cert.subject.get_attributes_for_oid(x509.OID_COMMON_NAME) |
| 501 | [<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] | 502 | |
Paul Kehrer | e76cd27 | 2014-12-14 19:00:51 -0600 | [diff] [blame] | 503 | .. class:: Version |
Paul Kehrer | 016e08a | 2014-11-26 09:41:18 -1000 | [diff] [blame] | 504 | |
| 505 | .. versionadded:: 0.7 |
| 506 | |
| 507 | An enumeration for X.509 versions. |
| 508 | |
| 509 | .. attribute:: v1 |
| 510 | |
| 511 | For version 1 X.509 certificates. |
| 512 | |
| 513 | .. attribute:: v3 |
| 514 | |
| 515 | For version 3 X.509 certificates. |
| 516 | |
Paul Kehrer | 806bfb2 | 2015-02-02 17:05:24 -0600 | [diff] [blame] | 517 | .. class:: NameAttribute |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 518 | |
| 519 | .. versionadded:: 0.8 |
| 520 | |
Paul Kehrer | 834d22f | 2015-02-06 11:01:07 -0600 | [diff] [blame] | 521 | An X.509 name consists of a list of NameAttribute instances. |
Paul Kehrer | 5b0a8d6 | 2015-01-30 20:05:55 -0600 | [diff] [blame] | 522 | |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 523 | .. attribute:: oid |
| 524 | |
| 525 | :type: :class:`ObjectIdentifier` |
| 526 | |
| 527 | The attribute OID. |
| 528 | |
| 529 | .. attribute:: value |
| 530 | |
Paul Kehrer | d5852cb | 2015-01-30 08:25:23 -0600 | [diff] [blame] | 531 | :type: :term:`text` |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 532 | |
| 533 | The value of the attribute. |
| 534 | |
| 535 | .. class:: ObjectIdentifier |
| 536 | |
| 537 | .. versionadded:: 0.8 |
| 538 | |
Paul Kehrer | 5b0a8d6 | 2015-01-30 20:05:55 -0600 | [diff] [blame] | 539 | Object identifiers (frequently seen abbreviated as OID) identify the type |
Paul Kehrer | 806bfb2 | 2015-02-02 17:05:24 -0600 | [diff] [blame] | 540 | of a value (see: :class:`NameAttribute`). |
Paul Kehrer | 5b0a8d6 | 2015-01-30 20:05:55 -0600 | [diff] [blame] | 541 | |
Paul Kehrer | d44f9a6 | 2015-02-04 14:47:34 -0600 | [diff] [blame] | 542 | .. attribute:: dotted_string |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 543 | |
| 544 | :type: :class:`str` |
| 545 | |
Paul Kehrer | fedf4f4 | 2015-02-06 11:22:07 -0600 | [diff] [blame] | 546 | 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] | 547 | |
Paul Kehrer | 31bdf79 | 2015-03-25 14:11:00 -0500 | [diff] [blame] | 548 | .. _general_name_classes: |
| 549 | |
| 550 | General Name Classes |
| 551 | ~~~~~~~~~~~~~~~~~~~~ |
| 552 | |
| 553 | .. class:: GeneralName |
| 554 | |
| 555 | .. versionadded:: 0.9 |
| 556 | |
| 557 | This is the generic interface that all the following classes are registered |
| 558 | against. |
| 559 | |
| 560 | .. class:: RFC822Name |
| 561 | |
| 562 | .. versionadded:: 0.9 |
| 563 | |
| 564 | This corresponds to an email address. For example, ``user@example.com``. |
| 565 | |
| 566 | .. attribute:: value |
| 567 | |
| 568 | :type: :term:`text` |
| 569 | |
| 570 | .. class:: DNSName |
| 571 | |
| 572 | .. versionadded:: 0.9 |
| 573 | |
| 574 | This corresponds to a domain name. For example, ``cryptography.io``. |
| 575 | |
| 576 | .. attribute:: value |
| 577 | |
| 578 | :type: :term:`text` |
| 579 | |
| 580 | .. class:: DirectoryName |
| 581 | |
| 582 | .. versionadded:: 0.9 |
| 583 | |
| 584 | This corresponds to a directory name. |
| 585 | |
| 586 | .. attribute:: value |
| 587 | |
| 588 | :type: :class:`Name` |
| 589 | |
| 590 | .. class:: UniformResourceIdentifier |
| 591 | |
| 592 | .. versionadded:: 0.9 |
| 593 | |
| 594 | This corresponds to a uniform resource identifier. For example, |
Paul Kehrer | b8ef82e | 2015-04-22 16:04:24 -0500 | [diff] [blame] | 595 | ``https://cryptography.io``. The URI is parsed and IDNA decoded (see |
| 596 | :rfc:`5895`). |
| 597 | |
| 598 | .. note:: |
| 599 | |
| 600 | URIs that do not contain ``://`` in them will not be decoded. |
Paul Kehrer | 31bdf79 | 2015-03-25 14:11:00 -0500 | [diff] [blame] | 601 | |
| 602 | .. attribute:: value |
| 603 | |
| 604 | :type: :term:`text` |
| 605 | |
| 606 | .. class:: IPAddress |
| 607 | |
| 608 | .. versionadded:: 0.9 |
| 609 | |
| 610 | This corresponds to an IP address. |
| 611 | |
| 612 | .. attribute:: value |
| 613 | |
Paul Kehrer | eb17793 | 2015-05-17 18:33:33 -0700 | [diff] [blame] | 614 | :type: :class:`~ipaddress.IPv4Address`, |
| 615 | :class:`~ipaddress.IPv6Address`, :class:`~ipaddress.IPv4Network`, |
| 616 | or :class:`~ipaddress.IPv6Network`. |
Paul Kehrer | 31bdf79 | 2015-03-25 14:11:00 -0500 | [diff] [blame] | 617 | |
| 618 | .. class:: RegisteredID |
| 619 | |
| 620 | .. versionadded:: 0.9 |
| 621 | |
| 622 | This corresponds to a registered ID. |
| 623 | |
| 624 | .. attribute:: value |
| 625 | |
| 626 | :type: :class:`ObjectIdentifier` |
| 627 | |
Paul Kehrer | 8cf2642 | 2015-03-21 09:50:24 -0500 | [diff] [blame] | 628 | X.509 Extensions |
| 629 | ~~~~~~~~~~~~~~~~ |
| 630 | |
Paul Kehrer | fbb7ac8 | 2015-03-16 19:26:29 -0500 | [diff] [blame] | 631 | .. class:: Extensions |
| 632 | |
| 633 | .. versionadded:: 0.9 |
| 634 | |
| 635 | An X.509 Extensions instance is an ordered list of extensions. The object |
| 636 | is iterable to get every extension. |
| 637 | |
Paul Kehrer | fa56a23 | 2015-03-17 13:14:03 -0500 | [diff] [blame] | 638 | .. method:: get_extension_for_oid(oid) |
| 639 | |
| 640 | :param oid: An :class:`ObjectIdentifier` instance. |
| 641 | |
| 642 | :returns: An instance of the extension class. |
| 643 | |
| 644 | :raises cryptography.x509.ExtensionNotFound: If the certificate does |
| 645 | not have the extension requested. |
| 646 | |
Paul Kehrer | fa56a23 | 2015-03-17 13:14:03 -0500 | [diff] [blame] | 647 | .. doctest:: |
| 648 | |
| 649 | >>> cert.extensions.get_extension_for_oid(x509.OID_BASIC_CONSTRAINTS) |
| 650 | <Extension(oid=<ObjectIdentifier(oid=2.5.29.19, name=basicConstraints)>, critical=True, value=<BasicConstraints(ca=True, path_length=None)>)> |
| 651 | |
Paul Kehrer | 8cf2642 | 2015-03-21 09:50:24 -0500 | [diff] [blame] | 652 | .. class:: Extension |
| 653 | |
| 654 | .. versionadded:: 0.9 |
| 655 | |
Paul Kehrer | 8589466 | 2015-03-22 13:19:31 -0500 | [diff] [blame] | 656 | .. attribute:: oid |
| 657 | |
| 658 | :type: :class:`ObjectIdentifier` |
| 659 | |
Paul Kehrer | 5553d57 | 2015-03-23 21:08:01 -0500 | [diff] [blame] | 660 | The :ref:`extension OID <extension_oids>`. |
Paul Kehrer | 8cf2642 | 2015-03-21 09:50:24 -0500 | [diff] [blame] | 661 | |
| 662 | .. attribute:: critical |
| 663 | |
| 664 | :type: bool |
| 665 | |
Paul Kehrer | 58b7569 | 2015-03-22 23:24:58 -0500 | [diff] [blame] | 666 | Determines whether a given extension is critical or not. :rfc:`5280` |
| 667 | requires that "A certificate-using system MUST reject the certificate |
| 668 | if it encounters a critical extension it does not recognize or a |
| 669 | critical extension that contains information that it cannot process". |
Paul Kehrer | 8cf2642 | 2015-03-21 09:50:24 -0500 | [diff] [blame] | 670 | |
Paul Kehrer | 8589466 | 2015-03-22 13:19:31 -0500 | [diff] [blame] | 671 | .. attribute:: value |
| 672 | |
| 673 | Returns an instance of the extension type corresponding to the OID. |
| 674 | |
Paul Kehrer | cecbbba | 2015-03-30 14:58:38 -0500 | [diff] [blame] | 675 | .. class:: KeyUsage |
| 676 | |
| 677 | .. versionadded:: 0.9 |
| 678 | |
| 679 | The key usage extension defines the purpose of the key contained in the |
| 680 | certificate. The usage restriction might be employed when a key that could |
| 681 | be used for more than one operation is to be restricted. It corresponds to |
| 682 | :data:`OID_KEY_USAGE`. |
| 683 | |
| 684 | .. attribute:: digital_signature |
| 685 | |
| 686 | :type: bool |
| 687 | |
Paul Kehrer | 738407b | 2015-04-01 22:39:02 -0500 | [diff] [blame] | 688 | This purpose is set to true when the subject public key is used for verifying |
Paul Kehrer | cecbbba | 2015-03-30 14:58:38 -0500 | [diff] [blame] | 689 | digital signatures, other than signatures on certificates |
| 690 | (``key_cert_sign``) and CRLs (``crl_sign``). |
| 691 | |
| 692 | .. attribute:: content_commitment |
| 693 | |
| 694 | :type: bool |
| 695 | |
Paul Kehrer | 738407b | 2015-04-01 22:39:02 -0500 | [diff] [blame] | 696 | This purpose is set to true when the subject public key is used for verifying |
Paul Kehrer | cecbbba | 2015-03-30 14:58:38 -0500 | [diff] [blame] | 697 | digital signatures, other than signatures on certificates |
| 698 | (``key_cert_sign``) and CRLs (``crl_sign``). It is used to provide a |
| 699 | non-repudiation service that protects against the signing entity |
| 700 | falsely denying some action. In the case of later conflict, a |
| 701 | reliable third party may determine the authenticity of the signed |
| 702 | data. This was called ``non_repudiation`` in older revisions of the |
| 703 | X.509 specification. |
| 704 | |
| 705 | .. attribute:: key_encipherment |
| 706 | |
| 707 | :type: bool |
| 708 | |
Paul Kehrer | 738407b | 2015-04-01 22:39:02 -0500 | [diff] [blame] | 709 | This purpose is set to true when the subject public key is used for |
| 710 | enciphering private or secret keys. |
Paul Kehrer | cecbbba | 2015-03-30 14:58:38 -0500 | [diff] [blame] | 711 | |
| 712 | .. attribute:: data_encipherment |
| 713 | |
| 714 | :type: bool |
| 715 | |
Paul Kehrer | 738407b | 2015-04-01 22:39:02 -0500 | [diff] [blame] | 716 | This purpose is set to true when the subject public key is used for |
| 717 | directly enciphering raw user data without the use of an intermediate |
| 718 | symmetric cipher. |
Paul Kehrer | cecbbba | 2015-03-30 14:58:38 -0500 | [diff] [blame] | 719 | |
| 720 | .. attribute:: key_agreement |
| 721 | |
| 722 | :type: bool |
| 723 | |
Paul Kehrer | 738407b | 2015-04-01 22:39:02 -0500 | [diff] [blame] | 724 | This purpose is set to true when the subject public key is used for key |
| 725 | agreement. For example, when a Diffie-Hellman key is to be used for |
| 726 | key management, then this purpose is set to true. |
Paul Kehrer | cecbbba | 2015-03-30 14:58:38 -0500 | [diff] [blame] | 727 | |
| 728 | .. attribute:: key_cert_sign |
| 729 | |
| 730 | :type: bool |
| 731 | |
Paul Kehrer | 738407b | 2015-04-01 22:39:02 -0500 | [diff] [blame] | 732 | This purpose is set to true when the subject public key is used for |
| 733 | verifying signatures on public key certificates. If this purpose is set |
| 734 | to true then ``ca`` must be true in the :class:`BasicConstraints` |
| 735 | extension. |
Paul Kehrer | cecbbba | 2015-03-30 14:58:38 -0500 | [diff] [blame] | 736 | |
| 737 | .. attribute:: crl_sign |
| 738 | |
| 739 | :type: bool |
| 740 | |
Paul Kehrer | 738407b | 2015-04-01 22:39:02 -0500 | [diff] [blame] | 741 | This purpose is set to true when the subject public key is used for |
| 742 | verifying signatures on certificate revocation lists. |
Paul Kehrer | cecbbba | 2015-03-30 14:58:38 -0500 | [diff] [blame] | 743 | |
| 744 | .. attribute:: encipher_only |
| 745 | |
| 746 | :type: bool |
| 747 | |
Paul Kehrer | 738407b | 2015-04-01 22:39:02 -0500 | [diff] [blame] | 748 | When this purposes is set to true and the ``key_agreement`` purpose is |
| 749 | also set, the subject public key may be used only for enciphering data |
| 750 | while performing key agreement. |
Paul Kehrer | cecbbba | 2015-03-30 14:58:38 -0500 | [diff] [blame] | 751 | |
| 752 | :raises ValueError: This is raised if accessed when ``key_agreement`` |
| 753 | is false. |
| 754 | |
| 755 | .. attribute:: decipher_only |
| 756 | |
| 757 | :type: bool |
| 758 | |
Paul Kehrer | 738407b | 2015-04-01 22:39:02 -0500 | [diff] [blame] | 759 | When this purposes is set to true and the ``key_agreement`` purpose is |
| 760 | also set, the subject public key may be used only for deciphering data |
| 761 | while performing key agreement. |
Paul Kehrer | cecbbba | 2015-03-30 14:58:38 -0500 | [diff] [blame] | 762 | |
| 763 | :raises ValueError: This is raised if accessed when ``key_agreement`` |
| 764 | is false. |
| 765 | |
| 766 | |
Paul Kehrer | 8cf2642 | 2015-03-21 09:50:24 -0500 | [diff] [blame] | 767 | .. class:: BasicConstraints |
| 768 | |
| 769 | .. versionadded:: 0.9 |
| 770 | |
Paul Kehrer | 8589466 | 2015-03-22 13:19:31 -0500 | [diff] [blame] | 771 | 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] | 772 | certificate is allowed to sign additional certificates and what path |
Paul Kehrer | 8589466 | 2015-03-22 13:19:31 -0500 | [diff] [blame] | 773 | length restrictions may exist. It corresponds to |
| 774 | :data:`OID_BASIC_CONSTRAINTS`. |
Paul Kehrer | 8cf2642 | 2015-03-21 09:50:24 -0500 | [diff] [blame] | 775 | |
| 776 | .. attribute:: ca |
| 777 | |
| 778 | :type: bool |
| 779 | |
| 780 | Whether the certificate can sign certificates. |
| 781 | |
| 782 | .. attribute:: path_length |
| 783 | |
Paul Kehrer | fd1444c | 2015-03-21 19:47:05 -0500 | [diff] [blame] | 784 | :type: int or None |
Paul Kehrer | 8cf2642 | 2015-03-21 09:50:24 -0500 | [diff] [blame] | 785 | |
| 786 | The maximum path length for certificates subordinate to this |
| 787 | certificate. This attribute only has meaning if ``ca`` is true. |
| 788 | If ``ca`` is true then a path length of None means there's no |
| 789 | restriction on the number of subordinate CAs in the certificate chain. |
Alex Gaynor | 99c5f15 | 2015-05-03 10:01:04 -0400 | [diff] [blame] | 790 | If it is zero or greater then it defines the maximum length for a |
| 791 | subordinate CA's certificate chain. For example, a ``path_length`` of 1 |
| 792 | means the certificate can sign a subordinate CA, but the subordinate CA |
| 793 | is not allowed to create subordinates with ``ca`` set to true. |
Paul Kehrer | 8cf2642 | 2015-03-21 09:50:24 -0500 | [diff] [blame] | 794 | |
Paul Kehrer | ffa2a15 | 2015-03-31 08:18:25 -0500 | [diff] [blame] | 795 | .. class:: ExtendedKeyUsage |
| 796 | |
| 797 | .. versionadded:: 0.9 |
| 798 | |
| 799 | This extension indicates one or more purposes for which the certified |
| 800 | public key may be used, in addition to or in place of the basic |
| 801 | purposes indicated in the key usage extension. The object is |
| 802 | iterable to obtain the list of :ref:`extended key usage OIDs <eku_oids>`. |
| 803 | |
Paul Kehrer | 4a1038e | 2015-05-18 10:28:31 -0700 | [diff] [blame] | 804 | .. class:: OCSPNoCheck |
| 805 | |
Paul Kehrer | 506a215 | 2015-05-26 08:01:18 -0500 | [diff] [blame] | 806 | .. versionadded:: 1.0 |
Paul Kehrer | 4a1038e | 2015-05-18 10:28:31 -0700 | [diff] [blame] | 807 | |
| 808 | This presence of this extension indicates that an OCSP client can trust a |
| 809 | responder for the lifetime of the responder's certificate. CAs issuing |
| 810 | such a certificate should realize that a compromise of the responder's key |
| 811 | is as serious as the compromise of a CA key used to sign CRLs, at least for |
| 812 | the validity period of this certificate. CA's may choose to issue this type |
| 813 | of certificate with a very short lifetime and renew it frequently. This |
| 814 | extension is only relevant when the certificate is an authorized OCSP |
| 815 | responder. |
| 816 | |
Paul Kehrer | e0017be | 2015-05-17 20:39:40 -0600 | [diff] [blame^] | 817 | .. class:: NameConstraints |
| 818 | |
| 819 | .. versionadded:: 1.0 |
| 820 | |
| 821 | The name constraints extension, which only has meaning in a CA certificate, |
| 822 | defines a name space within which all subject names in certificates issued |
| 823 | beneath the CA certificate must (or must not) be in. For specific details |
| 824 | on the way this extension should be processed see :rfc:`5280`. |
| 825 | |
| 826 | .. attribute:: permitted_subtrees |
| 827 | |
| 828 | :type: list of :class:`GeneralName` objects or None |
| 829 | |
| 830 | The set of permitted name patterns. If a name matches this and an |
| 831 | element in ``excluded_subtrees`` it is invalid. At least one of |
| 832 | ``permitted_subtrees`` and ``excluded_subtrees`` will be non-None. |
| 833 | |
| 834 | .. attribute:: excluded_subtrees |
| 835 | |
| 836 | :type: list of :class:`GeneralName` objects or None |
| 837 | |
| 838 | Any name matching a restriction in the ``excluded_subtrees`` field is |
| 839 | invalid regardless of information appearing in the |
| 840 | ``permitted_subtrees``. At least one of ``permitted_subtrees`` and |
| 841 | ``excluded_subtrees`` will be non-None. |
| 842 | |
Paul Kehrer | 2eb4ed9 | 2015-04-11 15:33:45 -0400 | [diff] [blame] | 843 | .. class:: AuthorityKeyIdentifier |
| 844 | |
| 845 | .. versionadded:: 0.9 |
| 846 | |
| 847 | The authority key identifier extension provides a means of identifying the |
| 848 | public key corresponding to the private key used to sign a certificate. |
Paul Kehrer | 8c8cd72 | 2015-04-19 09:15:04 -0500 | [diff] [blame] | 849 | This extension is typically used to assist in determining the appropriate |
| 850 | certificate chain. For more information about generation and use of this |
| 851 | extension see `RFC 5280 section 4.2.1.1`_. |
Paul Kehrer | 2eb4ed9 | 2015-04-11 15:33:45 -0400 | [diff] [blame] | 852 | |
| 853 | .. attribute:: key_identifier |
| 854 | |
| 855 | :type: bytes |
| 856 | |
Paul Kehrer | 9104b1d | 2015-04-18 09:23:44 -0500 | [diff] [blame] | 857 | A value derived from the public key used to verify the certificate's |
Paul Kehrer | 8c8cd72 | 2015-04-19 09:15:04 -0500 | [diff] [blame] | 858 | signature. |
Paul Kehrer | 9104b1d | 2015-04-18 09:23:44 -0500 | [diff] [blame] | 859 | |
Paul Kehrer | 2eb4ed9 | 2015-04-11 15:33:45 -0400 | [diff] [blame] | 860 | .. attribute:: authority_cert_issuer |
| 861 | |
| 862 | :type: :class:`Name` or None |
| 863 | |
Paul Kehrer | 9104b1d | 2015-04-18 09:23:44 -0500 | [diff] [blame] | 864 | The :class:`Name` of the issuer's issuer. |
| 865 | |
Paul Kehrer | 2eb4ed9 | 2015-04-11 15:33:45 -0400 | [diff] [blame] | 866 | .. attribute:: authority_cert_serial_number |
| 867 | |
| 868 | :type: int or None |
| 869 | |
Paul Kehrer | 9104b1d | 2015-04-18 09:23:44 -0500 | [diff] [blame] | 870 | The serial number of the issuer's issuer. |
| 871 | |
Paul Kehrer | 1eb82a6 | 2015-03-31 20:00:33 -0500 | [diff] [blame] | 872 | .. class:: SubjectKeyIdentifier |
| 873 | |
| 874 | .. versionadded:: 0.9 |
| 875 | |
| 876 | The subject key identifier extension provides a means of identifying |
| 877 | certificates that contain a particular public key. |
| 878 | |
| 879 | .. attribute:: digest |
| 880 | |
| 881 | :type: bytes |
| 882 | |
| 883 | The binary value of the identifier. |
| 884 | |
Paul Kehrer | 31bdf79 | 2015-03-25 14:11:00 -0500 | [diff] [blame] | 885 | .. class:: SubjectAlternativeName |
| 886 | |
| 887 | .. versionadded:: 0.9 |
| 888 | |
| 889 | Subject alternative name is an X.509 extension that provides a list of |
| 890 | :ref:`general name <general_name_classes>` instances that provide a set |
| 891 | of identities for which the certificate is valid. The object is iterable to |
| 892 | get every element. |
| 893 | |
| 894 | .. method:: get_values_for_type(type) |
| 895 | |
| 896 | :param type: A :class:`GeneralName` provider. This is one of the |
| 897 | :ref:`general name classes <general_name_classes>`. |
| 898 | |
| 899 | :returns: A list of values extracted from the matched general names. |
| 900 | |
Paul Kehrer | 93ae805 | 2015-05-02 23:18:09 -0500 | [diff] [blame] | 901 | .. doctest:: |
| 902 | |
| 903 | >>> from cryptography import x509 |
| 904 | >>> from cryptography.hazmat.backends import default_backend |
| 905 | >>> from cryptography.hazmat.primitives import hashes |
| 906 | >>> cert = x509.load_pem_x509_certificate(cryptography_cert_pem, default_backend()) |
Paul Kehrer | d0cd507 | 2015-05-02 23:27:00 -0500 | [diff] [blame] | 907 | >>> # Get the subjectAltName extension from the certificate |
Paul Kehrer | 93ae805 | 2015-05-02 23:18:09 -0500 | [diff] [blame] | 908 | >>> ext = cert.extensions.get_extension_for_oid(x509.OID_SUBJECT_ALTERNATIVE_NAME) |
Paul Kehrer | d0cd507 | 2015-05-02 23:27:00 -0500 | [diff] [blame] | 909 | >>> # Get the dNSName entries from the SAN extension |
| 910 | >>> ext.value.get_values_for_type(x509.DNSName) |
Paul Kehrer | 93ae805 | 2015-05-02 23:18:09 -0500 | [diff] [blame] | 911 | [u'www.cryptography.io', u'cryptography.io'] |
| 912 | |
Paul Kehrer | 8cf2642 | 2015-03-21 09:50:24 -0500 | [diff] [blame] | 913 | |
Paul Kehrer | 99125c9 | 2015-06-07 18:37:10 -0500 | [diff] [blame] | 914 | .. class:: IssuerAlternativeName |
| 915 | |
| 916 | .. versionadded:: 1.0 |
| 917 | |
| 918 | Issuer alternative name is an X.509 extension that provides a list of |
| 919 | :ref:`general name <general_name_classes>` instances that provide a set |
| 920 | of identities for the certificate issuer. The object is iterable to |
| 921 | get every element. |
| 922 | |
| 923 | .. method:: get_values_for_type(type) |
| 924 | |
| 925 | :param type: A :class:`GeneralName` provider. This is one of the |
| 926 | :ref:`general name classes <general_name_classes>`. |
| 927 | |
| 928 | :returns: A list of values extracted from the matched general names. |
| 929 | |
| 930 | |
Paul Kehrer | 3e6d558 | 2015-05-02 21:57:56 -0500 | [diff] [blame] | 931 | .. class:: AuthorityInformationAccess |
| 932 | |
| 933 | .. versionadded:: 0.9 |
| 934 | |
| 935 | The authority information access extension indicates how to access |
| 936 | information and services for the issuer of the certificate in which |
| 937 | the extension appears. Information and services may include online |
| 938 | validation services (such as OCSP) and issuer data. It is an iterable, |
| 939 | containing one or more :class:`AccessDescription` instances. |
| 940 | |
| 941 | |
| 942 | .. class:: AccessDescription |
| 943 | |
Paul Kehrer | 5a48552 | 2015-05-06 00:29:12 -0500 | [diff] [blame] | 944 | .. versionadded:: 0.9 |
| 945 | |
Paul Kehrer | 3e6d558 | 2015-05-02 21:57:56 -0500 | [diff] [blame] | 946 | .. attribute:: access_method |
| 947 | |
| 948 | :type: :class:`ObjectIdentifier` |
| 949 | |
Paul Kehrer | f506bca | 2015-05-02 22:31:47 -0500 | [diff] [blame] | 950 | The access method defines what the ``access_location`` means. It must |
| 951 | be either :data:`OID_OCSP` or :data:`OID_CA_ISSUERS`. If it is |
| 952 | :data:`OID_OCSP` the access location will be where to obtain OCSP |
| 953 | information for the certificate. If it is :data:`OID_CA_ISSUERS` the |
| 954 | access location will provide additional information about the issuing |
| 955 | certificate. |
Paul Kehrer | 3e6d558 | 2015-05-02 21:57:56 -0500 | [diff] [blame] | 956 | |
| 957 | .. attribute:: access_location |
| 958 | |
| 959 | :type: :class:`GeneralName` |
| 960 | |
Paul Kehrer | f506bca | 2015-05-02 22:31:47 -0500 | [diff] [blame] | 961 | Where to access the information defined by the access method. |
| 962 | |
Paul Kehrer | 5a48552 | 2015-05-06 00:29:12 -0500 | [diff] [blame] | 963 | .. class:: CRLDistributionPoints |
| 964 | |
| 965 | .. versionadded:: 0.9 |
| 966 | |
| 967 | The CRL distribution points extension identifies how CRL information is |
| 968 | obtained. It is an iterable, containing one or more |
| 969 | :class:`DistributionPoint` instances. |
| 970 | |
| 971 | .. class:: DistributionPoint |
| 972 | |
| 973 | .. versionadded:: 0.9 |
| 974 | |
Paul Kehrer | 4e8dacd | 2015-05-09 10:38:23 -0500 | [diff] [blame] | 975 | .. attribute:: full_name |
Paul Kehrer | 5a48552 | 2015-05-06 00:29:12 -0500 | [diff] [blame] | 976 | |
Paul Kehrer | 4e8dacd | 2015-05-09 10:38:23 -0500 | [diff] [blame] | 977 | :type: list of :class:`GeneralName` instances or None |
Paul Kehrer | 5a48552 | 2015-05-06 00:29:12 -0500 | [diff] [blame] | 978 | |
Paul Kehrer | f2c072b | 2015-05-09 17:04:28 -0500 | [diff] [blame] | 979 | This field describes methods to retrieve the CRL. At most one of |
| 980 | ``full_name`` or ``relative_name`` will be non-None. |
Paul Kehrer | 4e8dacd | 2015-05-09 10:38:23 -0500 | [diff] [blame] | 981 | |
| 982 | .. attribute:: relative_name |
| 983 | |
| 984 | :type: :class:`Name` or None |
| 985 | |
| 986 | This field describes methods to retrieve the CRL relative to the CRL |
Paul Kehrer | f2c072b | 2015-05-09 17:04:28 -0500 | [diff] [blame] | 987 | issuer. At most one of ``full_name`` or ``relative_name`` will be |
| 988 | non-None. |
Paul Kehrer | 5a48552 | 2015-05-06 00:29:12 -0500 | [diff] [blame] | 989 | |
| 990 | .. attribute:: crl_issuer |
| 991 | |
| 992 | :type: list of :class:`GeneralName` instances or None |
| 993 | |
| 994 | Information about the issuer of the CRL. |
| 995 | |
| 996 | .. attribute:: reasons |
| 997 | |
Paul Kehrer | 3fd0260 | 2015-05-09 19:46:13 -0500 | [diff] [blame] | 998 | :type: frozenset of :class:`ReasonFlags` or None |
Paul Kehrer | 5a48552 | 2015-05-06 00:29:12 -0500 | [diff] [blame] | 999 | |
| 1000 | The reasons a given distribution point may be used for when performing |
| 1001 | revocation checks. |
| 1002 | |
| 1003 | .. class:: ReasonFlags |
| 1004 | |
| 1005 | .. versionadded:: 0.9 |
| 1006 | |
Paul Kehrer | 4e8dacd | 2015-05-09 10:38:23 -0500 | [diff] [blame] | 1007 | An enumeration for CRL reasons. |
| 1008 | |
| 1009 | .. attribute:: unspecified |
| 1010 | |
| 1011 | It is unspecified why the certificate was revoked. This reason cannot |
| 1012 | be used as a reason flag in a :class:`DistributionPoint`. |
Paul Kehrer | 5a48552 | 2015-05-06 00:29:12 -0500 | [diff] [blame] | 1013 | |
| 1014 | .. attribute:: key_compromise |
| 1015 | |
Paul Kehrer | 4e8dacd | 2015-05-09 10:38:23 -0500 | [diff] [blame] | 1016 | This reason indicates that the private key was compromised. |
Paul Kehrer | 5a48552 | 2015-05-06 00:29:12 -0500 | [diff] [blame] | 1017 | |
| 1018 | .. attribute:: ca_compromise |
| 1019 | |
Paul Kehrer | 4e8dacd | 2015-05-09 10:38:23 -0500 | [diff] [blame] | 1020 | This reason indicates that the CA issuing the certificate was |
| 1021 | compromised. |
Paul Kehrer | 5a48552 | 2015-05-06 00:29:12 -0500 | [diff] [blame] | 1022 | |
| 1023 | .. attribute:: affiliation_changed |
| 1024 | |
Paul Kehrer | 4e8dacd | 2015-05-09 10:38:23 -0500 | [diff] [blame] | 1025 | This reason indicates that the subject's name or other information has |
| 1026 | changed. |
Paul Kehrer | 5a48552 | 2015-05-06 00:29:12 -0500 | [diff] [blame] | 1027 | |
| 1028 | .. attribute:: superseded |
| 1029 | |
Paul Kehrer | 4e8dacd | 2015-05-09 10:38:23 -0500 | [diff] [blame] | 1030 | This reason indicates that a certificate has been superseded. |
Paul Kehrer | 5a48552 | 2015-05-06 00:29:12 -0500 | [diff] [blame] | 1031 | |
| 1032 | .. attribute:: cessation_of_operation |
| 1033 | |
Paul Kehrer | 4e8dacd | 2015-05-09 10:38:23 -0500 | [diff] [blame] | 1034 | This reason indicates that the certificate is no longer required. |
Paul Kehrer | 5a48552 | 2015-05-06 00:29:12 -0500 | [diff] [blame] | 1035 | |
| 1036 | .. attribute:: certificate_hold |
| 1037 | |
Paul Kehrer | 4e8dacd | 2015-05-09 10:38:23 -0500 | [diff] [blame] | 1038 | This reason indicates that the certificate is on hold. |
Paul Kehrer | 5a48552 | 2015-05-06 00:29:12 -0500 | [diff] [blame] | 1039 | |
| 1040 | .. attribute:: privilege_withdrawn |
| 1041 | |
Paul Kehrer | 4e8dacd | 2015-05-09 10:38:23 -0500 | [diff] [blame] | 1042 | This reason indicates that the privilege granted by this certificate |
| 1043 | have been withdrawn. |
Paul Kehrer | 5a48552 | 2015-05-06 00:29:12 -0500 | [diff] [blame] | 1044 | |
| 1045 | .. attribute:: aa_compromise |
| 1046 | |
Paul Kehrer | 4e8dacd | 2015-05-09 10:38:23 -0500 | [diff] [blame] | 1047 | When an attribute authority has been compromised. |
| 1048 | |
| 1049 | .. attribute:: remove_from_crl |
| 1050 | |
| 1051 | This reason indicates that the certificate was on hold and should be |
| 1052 | removed from the CRL. This reason cannot be used as a reason flag |
| 1053 | in a :class:`DistributionPoint`. |
Paul Kehrer | 5a48552 | 2015-05-06 00:29:12 -0500 | [diff] [blame] | 1054 | |
Paul Kehrer | 16fae76 | 2015-05-01 23:14:20 -0500 | [diff] [blame] | 1055 | .. class:: InhibitAnyPolicy |
| 1056 | |
| 1057 | .. versionadded:: 1.0 |
| 1058 | |
| 1059 | The inhibit ``anyPolicy`` extension indicates that the special OID |
| 1060 | :data:`OID_ANY_POLICY`, is not considered an explicit match for other |
| 1061 | :class:`CertificatePolicies` except when it appears in an intermediate |
| 1062 | self-issued CA certificate. The value indicates the number of additional |
| 1063 | non-self-issued certificates that may appear in the path before |
| 1064 | :data:`OID_ANY_POLICY` is no longer permitted. For example, a value |
| 1065 | of one indicates that :data:`OID_ANY_POLICY` may be processed in |
| 1066 | certificates issued by the subject of this certificate, but not in |
| 1067 | additional certificates in the path. |
| 1068 | |
| 1069 | .. attribute:: skip_certs |
| 1070 | |
| 1071 | :type: int |
| 1072 | |
Paul Kehrer | 0d21092 | 2015-04-28 17:31:07 -0500 | [diff] [blame] | 1073 | .. class:: CertificatePolicies |
| 1074 | |
| 1075 | .. versionadded:: 0.9 |
| 1076 | |
Paul Kehrer | 2e87974 | 2015-05-02 23:09:56 -0500 | [diff] [blame] | 1077 | The certificate policies extension is an iterable, containing one or more |
| 1078 | :class:`PolicyInformation` instances. |
Paul Kehrer | 0d21092 | 2015-04-28 17:31:07 -0500 | [diff] [blame] | 1079 | |
| 1080 | Certificate Policies Classes |
| 1081 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 1082 | |
| 1083 | These classes may be present within a :class:`CertificatePolicies` instance. |
| 1084 | |
| 1085 | .. class:: PolicyInformation |
| 1086 | |
| 1087 | .. versionadded:: 0.9 |
| 1088 | |
| 1089 | Contains a policy identifier and an optional list of qualifiers. |
| 1090 | |
| 1091 | .. attribute:: policy_identifier |
| 1092 | |
| 1093 | :type: :class:`ObjectIdentifier` |
| 1094 | |
| 1095 | .. attribute:: policy_qualifiers |
| 1096 | |
| 1097 | :type: list |
| 1098 | |
Paul Kehrer | ba35b3b | 2015-05-10 13:07:59 -0500 | [diff] [blame] | 1099 | A list consisting of :term:`text` and/or :class:`UserNotice` objects. |
Paul Kehrer | 3f8ddeb | 2015-05-11 00:25:36 -0500 | [diff] [blame] | 1100 | If the value is text it is a pointer to the practice statement |
| 1101 | published by the certificate authority. If it is a user notice it is |
| 1102 | meant for display to the relying party when the certificate is |
| 1103 | used. |
Paul Kehrer | 2e87974 | 2015-05-02 23:09:56 -0500 | [diff] [blame] | 1104 | |
Paul Kehrer | 0d21092 | 2015-04-28 17:31:07 -0500 | [diff] [blame] | 1105 | .. class:: UserNotice |
| 1106 | |
| 1107 | .. versionadded:: 0.9 |
| 1108 | |
Paul Kehrer | 2e87974 | 2015-05-02 23:09:56 -0500 | [diff] [blame] | 1109 | User notices are intended for display to a relying party when a certificate |
| 1110 | is used. In practice, few if any UIs expose this data and it is a rarely |
| 1111 | encoded component. |
| 1112 | |
Paul Kehrer | 0d21092 | 2015-04-28 17:31:07 -0500 | [diff] [blame] | 1113 | .. attribute:: notice_reference |
| 1114 | |
| 1115 | :type: :class:`NoticeReference` or None |
| 1116 | |
Paul Kehrer | 2e87974 | 2015-05-02 23:09:56 -0500 | [diff] [blame] | 1117 | The notice reference field names an organization and identifies, |
| 1118 | by number, a particular statement prepared by that organization. |
| 1119 | |
Paul Kehrer | 0d21092 | 2015-04-28 17:31:07 -0500 | [diff] [blame] | 1120 | .. attribute:: explicit_text |
| 1121 | |
Paul Kehrer | 2e87974 | 2015-05-02 23:09:56 -0500 | [diff] [blame] | 1122 | This field includes an arbitrary textual statement directly in the |
| 1123 | certificate. |
| 1124 | |
Paul Kehrer | 0d21092 | 2015-04-28 17:31:07 -0500 | [diff] [blame] | 1125 | :type: :term:`text` |
| 1126 | |
| 1127 | .. class:: NoticeReference |
| 1128 | |
Paul Kehrer | 2e87974 | 2015-05-02 23:09:56 -0500 | [diff] [blame] | 1129 | Notice reference can name an organization and provide information about |
| 1130 | notices related to the certificate. For example, it might identify the |
| 1131 | organization name and notice number 1. Application software could |
| 1132 | have a notice file containing the current set of notices for the named |
| 1133 | organization; the application would then extract the notice text from the |
| 1134 | file and display it. In practice this is rarely seen. |
| 1135 | |
Paul Kehrer | 0d21092 | 2015-04-28 17:31:07 -0500 | [diff] [blame] | 1136 | .. versionadded:: 0.9 |
| 1137 | |
| 1138 | .. attribute:: organization |
| 1139 | |
Paul Kehrer | 66c6170 | 2015-05-12 16:39:18 -0500 | [diff] [blame] | 1140 | :type: :term:`text` |
Paul Kehrer | 0d21092 | 2015-04-28 17:31:07 -0500 | [diff] [blame] | 1141 | |
Paul Kehrer | 3f8ddeb | 2015-05-11 00:25:36 -0500 | [diff] [blame] | 1142 | .. attribute:: notice_numbers |
Paul Kehrer | 0d21092 | 2015-04-28 17:31:07 -0500 | [diff] [blame] | 1143 | |
Paul Kehrer | 66c6170 | 2015-05-12 16:39:18 -0500 | [diff] [blame] | 1144 | :type: list |
Paul Kehrer | 0d21092 | 2015-04-28 17:31:07 -0500 | [diff] [blame] | 1145 | |
Paul Kehrer | 66c6170 | 2015-05-12 16:39:18 -0500 | [diff] [blame] | 1146 | A list of integers. |
Paul Kehrer | 0d21092 | 2015-04-28 17:31:07 -0500 | [diff] [blame] | 1147 | |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 1148 | Object Identifiers |
| 1149 | ~~~~~~~~~~~~~~~~~~ |
| 1150 | |
Paul Kehrer | 4bb4649 | 2015-02-07 16:59:14 -0600 | [diff] [blame] | 1151 | X.509 elements are frequently identified by :class:`ObjectIdentifier` |
| 1152 | instances. The following common OIDs are available as constants. |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 1153 | |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 1154 | Name OIDs |
| 1155 | ~~~~~~~~~ |
| 1156 | |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 1157 | .. data:: OID_COMMON_NAME |
| 1158 | |
Paul Kehrer | fb5ac9e | 2015-02-07 16:29:37 -0600 | [diff] [blame] | 1159 | Corresponds to the dotted string ``"2.5.4.3"``. Historically the domain |
| 1160 | name would be encoded here for server certificates. :rfc:`2818` deprecates |
| 1161 | 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] | 1162 | SubjectAlternativeName extension. This OID is typically seen in X.509 names. |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 1163 | |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 1164 | .. data:: OID_COUNTRY_NAME |
| 1165 | |
Paul Kehrer | 4bb4649 | 2015-02-07 16:59:14 -0600 | [diff] [blame] | 1166 | Corresponds to the dotted string ``"2.5.4.6"``. This OID is typically seen |
| 1167 | in X.509 names. |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 1168 | |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 1169 | .. data:: OID_LOCALITY_NAME |
| 1170 | |
Paul Kehrer | 4bb4649 | 2015-02-07 16:59:14 -0600 | [diff] [blame] | 1171 | Corresponds to the dotted string ``"2.5.4.7"``. This OID is typically seen |
| 1172 | in X.509 names. |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 1173 | |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 1174 | .. data:: OID_STATE_OR_PROVINCE_NAME |
| 1175 | |
Paul Kehrer | 4bb4649 | 2015-02-07 16:59:14 -0600 | [diff] [blame] | 1176 | Corresponds to the dotted string ``"2.5.4.8"``. This OID is typically seen |
| 1177 | in X.509 names. |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 1178 | |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 1179 | .. data:: OID_ORGANIZATION_NAME |
| 1180 | |
Paul Kehrer | 4bb4649 | 2015-02-07 16:59:14 -0600 | [diff] [blame] | 1181 | Corresponds to the dotted string ``"2.5.4.10"``. This OID is typically seen |
| 1182 | in X.509 names. |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 1183 | |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 1184 | .. data:: OID_ORGANIZATIONAL_UNIT_NAME |
| 1185 | |
Paul Kehrer | 4bb4649 | 2015-02-07 16:59:14 -0600 | [diff] [blame] | 1186 | Corresponds to the dotted string ``"2.5.4.11"``. This OID is typically seen |
| 1187 | in X.509 names. |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 1188 | |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 1189 | .. data:: OID_SERIAL_NUMBER |
| 1190 | |
Paul Kehrer | fb5ac9e | 2015-02-07 16:29:37 -0600 | [diff] [blame] | 1191 | Corresponds to the dotted string ``"2.5.4.5"``. This is distinct from the |
| 1192 | serial number of the certificate itself (which can be obtained with |
Paul Kehrer | 4bb4649 | 2015-02-07 16:59:14 -0600 | [diff] [blame] | 1193 | :func:`Certificate.serial`). This OID is typically seen in X.509 names. |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 1194 | |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 1195 | .. data:: OID_SURNAME |
| 1196 | |
Paul Kehrer | 4bb4649 | 2015-02-07 16:59:14 -0600 | [diff] [blame] | 1197 | Corresponds to the dotted string ``"2.5.4.4"``. This OID is typically seen |
| 1198 | in X.509 names. |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 1199 | |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 1200 | .. data:: OID_GIVEN_NAME |
| 1201 | |
Paul Kehrer | 4bb4649 | 2015-02-07 16:59:14 -0600 | [diff] [blame] | 1202 | Corresponds to the dotted string ``"2.5.4.42"``. This OID is typically seen |
| 1203 | in X.509 names. |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 1204 | |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 1205 | .. data:: OID_TITLE |
| 1206 | |
Paul Kehrer | 4bb4649 | 2015-02-07 16:59:14 -0600 | [diff] [blame] | 1207 | Corresponds to the dotted string ``"2.5.4.12"``. This OID is typically seen |
| 1208 | in X.509 names. |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 1209 | |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 1210 | .. data:: OID_GENERATION_QUALIFIER |
| 1211 | |
Paul Kehrer | 4bb4649 | 2015-02-07 16:59:14 -0600 | [diff] [blame] | 1212 | Corresponds to the dotted string ``"2.5.4.44"``. This OID is typically seen |
| 1213 | in X.509 names. |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 1214 | |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 1215 | .. data:: OID_DN_QUALIFIER |
| 1216 | |
Paul Kehrer | fb5ac9e | 2015-02-07 16:29:37 -0600 | [diff] [blame] | 1217 | Corresponds to the dotted string ``"2.5.4.46"``. This specifies |
| 1218 | disambiguating information to add to the relative distinguished name of an |
Paul Kehrer | 4bb4649 | 2015-02-07 16:59:14 -0600 | [diff] [blame] | 1219 | 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] | 1220 | |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 1221 | .. data:: OID_PSEUDONYM |
| 1222 | |
Paul Kehrer | 4bb4649 | 2015-02-07 16:59:14 -0600 | [diff] [blame] | 1223 | Corresponds to the dotted string ``"2.5.4.65"``. This OID is typically seen |
| 1224 | in X.509 names. |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 1225 | |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 1226 | .. data:: OID_DOMAIN_COMPONENT |
| 1227 | |
Paul Kehrer | fb5ac9e | 2015-02-07 16:29:37 -0600 | [diff] [blame] | 1228 | 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] | 1229 | holding one component of a domain name. See :rfc:`4519`. This OID is |
| 1230 | typically seen in X.509 names. |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 1231 | |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 1232 | .. data:: OID_EMAIL_ADDRESS |
| 1233 | |
Paul Kehrer | 4bb4649 | 2015-02-07 16:59:14 -0600 | [diff] [blame] | 1234 | Corresponds to the dotted string ``"1.2.840.113549.1.9.1"``. This OID is |
| 1235 | typically seen in X.509 names. |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 1236 | |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 1237 | Signature Algorithm OIDs |
| 1238 | ~~~~~~~~~~~~~~~~~~~~~~~~ |
| 1239 | |
Paul Kehrer | 1a7ba87 | 2015-02-19 18:09:05 -0600 | [diff] [blame] | 1240 | .. data:: OID_RSA_WITH_MD5 |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 1241 | |
| 1242 | Corresponds to the dotted string ``"1.2.840.113549.1.1.4"``. This is |
| 1243 | an MD5 digest signed by an RSA key. |
| 1244 | |
Paul Kehrer | 1a7ba87 | 2015-02-19 18:09:05 -0600 | [diff] [blame] | 1245 | .. data:: OID_RSA_WITH_SHA1 |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 1246 | |
| 1247 | Corresponds to the dotted string ``"1.2.840.113549.1.1.5"``. This is |
| 1248 | a SHA1 digest signed by an RSA key. |
| 1249 | |
Paul Kehrer | 1a7ba87 | 2015-02-19 18:09:05 -0600 | [diff] [blame] | 1250 | .. data:: OID_RSA_WITH_SHA224 |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 1251 | |
| 1252 | Corresponds to the dotted string ``"1.2.840.113549.1.1.14"``. This is |
| 1253 | a SHA224 digest signed by an RSA key. |
| 1254 | |
Paul Kehrer | 1a7ba87 | 2015-02-19 18:09:05 -0600 | [diff] [blame] | 1255 | .. data:: OID_RSA_WITH_SHA256 |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 1256 | |
| 1257 | Corresponds to the dotted string ``"1.2.840.113549.1.1.11"``. This is |
| 1258 | a SHA256 digest signed by an RSA key. |
| 1259 | |
Paul Kehrer | 1a7ba87 | 2015-02-19 18:09:05 -0600 | [diff] [blame] | 1260 | .. data:: OID_RSA_WITH_SHA384 |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 1261 | |
| 1262 | Corresponds to the dotted string ``"1.2.840.113549.1.1.12"``. This is |
| 1263 | a SHA384 digest signed by an RSA key. |
| 1264 | |
Paul Kehrer | 1a7ba87 | 2015-02-19 18:09:05 -0600 | [diff] [blame] | 1265 | .. data:: OID_RSA_WITH_SHA512 |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 1266 | |
| 1267 | Corresponds to the dotted string ``"1.2.840.113549.1.1.13"``. This is |
| 1268 | a SHA512 digest signed by an RSA key. |
| 1269 | |
| 1270 | .. data:: OID_ECDSA_WITH_SHA224 |
| 1271 | |
| 1272 | Corresponds to the dotted string ``"1.2.840.10045.4.3.1"``. This is |
| 1273 | a SHA224 digest signed by an ECDSA key. |
| 1274 | |
| 1275 | .. data:: OID_ECDSA_WITH_SHA256 |
| 1276 | |
| 1277 | Corresponds to the dotted string ``"1.2.840.10045.4.3.2"``. This is |
| 1278 | a SHA256 digest signed by an ECDSA key. |
| 1279 | |
| 1280 | .. data:: OID_ECDSA_WITH_SHA384 |
| 1281 | |
| 1282 | Corresponds to the dotted string ``"1.2.840.10045.4.3.3"``. This is |
| 1283 | a SHA384 digest signed by an ECDSA key. |
| 1284 | |
| 1285 | .. data:: OID_ECDSA_WITH_SHA512 |
| 1286 | |
| 1287 | Corresponds to the dotted string ``"1.2.840.10045.4.3.4"``. This is |
| 1288 | a SHA512 digest signed by an ECDSA key. |
| 1289 | |
| 1290 | .. data:: OID_DSA_WITH_SHA1 |
| 1291 | |
| 1292 | Corresponds to the dotted string ``"1.2.840.10040.4.3"``. This is |
| 1293 | a SHA1 digest signed by a DSA key. |
| 1294 | |
| 1295 | .. data:: OID_DSA_WITH_SHA224 |
| 1296 | |
| 1297 | Corresponds to the dotted string ``"2.16.840.1.101.3.4.3.1"``. This is |
| 1298 | a SHA224 digest signed by a DSA key. |
| 1299 | |
| 1300 | .. data:: OID_DSA_WITH_SHA256 |
| 1301 | |
Paul Kehrer | fbb7ac8 | 2015-03-16 19:26:29 -0500 | [diff] [blame] | 1302 | 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] | 1303 | a SHA256 digest signed by a DSA key. |
| 1304 | |
Paul Kehrer | ffa2a15 | 2015-03-31 08:18:25 -0500 | [diff] [blame] | 1305 | .. _eku_oids: |
| 1306 | |
Paul Kehrer | e1513fa | 2015-03-30 23:08:17 -0500 | [diff] [blame] | 1307 | Extended Key Usage OIDs |
| 1308 | ~~~~~~~~~~~~~~~~~~~~~~~ |
| 1309 | |
| 1310 | .. data:: OID_SERVER_AUTH |
| 1311 | |
| 1312 | Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.1"``. This is used to |
| 1313 | denote that a certificate may be used for TLS web server authentication. |
| 1314 | |
| 1315 | .. data:: OID_CLIENT_AUTH |
| 1316 | |
| 1317 | Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.2"``. This is used to |
| 1318 | denote that a certificate may be used for TLS web client authentication. |
| 1319 | |
| 1320 | .. data:: OID_CODE_SIGNING |
| 1321 | |
| 1322 | Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.3"``. This is used to |
| 1323 | denote that a certificate may be used for code signing. |
| 1324 | |
| 1325 | .. data:: OID_EMAIL_PROTECTION |
| 1326 | |
| 1327 | Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.4"``. This is used to |
| 1328 | denote that a certificate may be used for email protection. |
| 1329 | |
| 1330 | .. data:: OID_TIME_STAMPING |
| 1331 | |
| 1332 | Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.8"``. This is used to |
| 1333 | denote that a certificate may be used for time stamping. |
| 1334 | |
| 1335 | .. data:: OID_OCSP_SIGNING |
| 1336 | |
| 1337 | Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.9"``. This is used to |
| 1338 | denote that a certificate may be used for signing OCSP responses. |
| 1339 | |
Paul Kehrer | 3e6d558 | 2015-05-02 21:57:56 -0500 | [diff] [blame] | 1340 | Authority Information Access OIDs |
| 1341 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 1342 | |
| 1343 | .. data:: OID_OCSP |
| 1344 | |
| 1345 | Corresponds to the dotted string ``"1.3.6.1.5.5.7.48.1"``. Used as the |
| 1346 | identifier for OCSP data in :class:`AccessDescription` objects. |
| 1347 | |
| 1348 | .. data:: OID_CA_ISSUERS |
| 1349 | |
| 1350 | Corresponds to the dotted string ``"1.3.6.1.5.5.7.48.2"``. Used as the |
| 1351 | identifier for CA issuer data in :class:`AccessDescription` objects. |
| 1352 | |
Paul Kehrer | 2e87974 | 2015-05-02 23:09:56 -0500 | [diff] [blame] | 1353 | Policy Qualifier OIDs |
| 1354 | ~~~~~~~~~~~~~~~~~~~~~ |
| 1355 | |
| 1356 | .. data:: OID_CPS_QUALIFIER |
| 1357 | |
Paul Kehrer | ba35b3b | 2015-05-10 13:07:59 -0500 | [diff] [blame] | 1358 | Corresponds to the dotted string ``"1.3.6.1.5.5.7.2.1"``. |
Paul Kehrer | 2e87974 | 2015-05-02 23:09:56 -0500 | [diff] [blame] | 1359 | |
| 1360 | .. data:: OID_CPS_USER_NOTICE |
| 1361 | |
Paul Kehrer | ba35b3b | 2015-05-10 13:07:59 -0500 | [diff] [blame] | 1362 | Corresponds to the dotted string ``"1.3.6.1.5.5.7.2.2"``. |
Paul Kehrer | 2e87974 | 2015-05-02 23:09:56 -0500 | [diff] [blame] | 1363 | |
Paul Kehrer | 16fae76 | 2015-05-01 23:14:20 -0500 | [diff] [blame] | 1364 | .. data:: OID_ANY_POLICY |
| 1365 | |
| 1366 | Corresponds to the dotted string ``"2.5.29.32.0"``. |
| 1367 | |
Paul Kehrer | 5553d57 | 2015-03-23 21:08:01 -0500 | [diff] [blame] | 1368 | .. _extension_oids: |
| 1369 | |
Paul Kehrer | 2bb9464 | 2015-03-21 09:54:17 -0500 | [diff] [blame] | 1370 | Extension OIDs |
| 1371 | ~~~~~~~~~~~~~~ |
| 1372 | |
| 1373 | .. data:: OID_BASIC_CONSTRAINTS |
| 1374 | |
| 1375 | 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] | 1376 | :class:`BasicConstraints` extension type. |
Paul Kehrer | 2bb9464 | 2015-03-21 09:54:17 -0500 | [diff] [blame] | 1377 | |
Paul Kehrer | cecbbba | 2015-03-30 14:58:38 -0500 | [diff] [blame] | 1378 | .. data:: OID_KEY_USAGE |
| 1379 | |
| 1380 | Corresponds to the dotted string ``"2.5.29.15"``. The identifier for the |
| 1381 | :class:`KeyUsage` extension type. |
| 1382 | |
Paul Kehrer | d4f632e | 2015-05-12 08:25:42 -0500 | [diff] [blame] | 1383 | .. data:: OID_SUBJECT_ALTERNATIVE_NAME |
| 1384 | |
| 1385 | Corresponds to the dotted string ``"2.5.29.17"``. The identifier for the |
| 1386 | :class:`SubjectAlternativeName` extension type. |
| 1387 | |
Paul Kehrer | 99125c9 | 2015-06-07 18:37:10 -0500 | [diff] [blame] | 1388 | .. data:: OID_ISSUER_ALTERNATIVE_NAME |
| 1389 | |
| 1390 | Corresponds to the dotted string ``"2.5.29.18"``. The identifier for the |
| 1391 | :class:`IssuerAlternativeName` extension type. |
| 1392 | |
Paul Kehrer | d4f632e | 2015-05-12 08:25:42 -0500 | [diff] [blame] | 1393 | .. data:: OID_SUBJECT_KEY_IDENTIFIER |
| 1394 | |
| 1395 | Corresponds to the dotted string ``"2.5.29.14"``. The identifier for the |
| 1396 | :class:`SubjectKeyIdentifier` extension type. |
| 1397 | |
Paul Kehrer | e0017be | 2015-05-17 20:39:40 -0600 | [diff] [blame^] | 1398 | .. data:: OID_NAME_CONSTRAINTS |
| 1399 | |
| 1400 | Corresponds to the dotted string ``"2.5.29.30"``. The identifier for the |
| 1401 | :class:`NameConstraints` extension type. |
| 1402 | |
Paul Kehrer | d4f632e | 2015-05-12 08:25:42 -0500 | [diff] [blame] | 1403 | .. data:: OID_CRL_DISTRIBUTION_POINTS |
| 1404 | |
| 1405 | Corresponds to the dotted string ``"2.5.29.31"``. The identifier for the |
| 1406 | :class:`CRLDistributionPoints` extension type. |
| 1407 | |
| 1408 | .. data:: OID_CERTIFICATE_POLICIES |
| 1409 | |
| 1410 | Corresponds to the dotted string ``"2.5.29.32"``. The identifier for the |
| 1411 | :class:`CertificatePolicies` extension type. |
| 1412 | |
| 1413 | .. data:: OID_AUTHORITY_KEY_IDENTIFIER |
| 1414 | |
| 1415 | Corresponds to the dotted string ``"2.5.29.35"``. The identifier for the |
| 1416 | :class:`AuthorityKeyIdentifier` extension type. |
| 1417 | |
| 1418 | .. data:: OID_EXTENDED_KEY_USAGE |
| 1419 | |
| 1420 | Corresponds to the dotted string ``"2.5.29.37"``. The identifier for the |
| 1421 | :class:`ExtendedKeyUsage` extension type. |
| 1422 | |
| 1423 | .. data:: OID_AUTHORITY_INFORMATION_ACCESS |
| 1424 | |
| 1425 | Corresponds to the dotted string ``"1.3.6.1.5.5.7.1.1"``. The identifier |
| 1426 | for the :class:`AuthorityInformationAccess` extension type. |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 1427 | |
Paul Kehrer | 4a1038e | 2015-05-18 10:28:31 -0700 | [diff] [blame] | 1428 | .. data:: OID_OCSP_NO_CHECK |
| 1429 | |
| 1430 | Corresponds to the dotted string ``"1.3.6.1.5.5.7.48.1.5"``. The identifier |
| 1431 | for the :class:`OCSPNoCheck` extension type. |
| 1432 | |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 1433 | Exceptions |
| 1434 | ~~~~~~~~~~ |
| 1435 | |
Paul Kehrer | e76cd27 | 2014-12-14 19:00:51 -0600 | [diff] [blame] | 1436 | .. class:: InvalidVersion |
Paul Kehrer | a68fd33 | 2014-11-27 07:08:40 -1000 | [diff] [blame] | 1437 | |
| 1438 | 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] | 1439 | |
Paul Kehrer | d5cccf7 | 2014-12-15 17:20:33 -0600 | [diff] [blame] | 1440 | .. attribute:: parsed_version |
| 1441 | |
Paul Kehrer | bbffc40 | 2014-12-17 13:33:55 -0600 | [diff] [blame] | 1442 | :type: int |
| 1443 | |
| 1444 | Returns the raw version that was parsed from the certificate. |
Paul Kehrer | d5cccf7 | 2014-12-15 17:20:33 -0600 | [diff] [blame] | 1445 | |
Paul Kehrer | fbb7ac8 | 2015-03-16 19:26:29 -0500 | [diff] [blame] | 1446 | .. class:: DuplicateExtension |
| 1447 | |
| 1448 | This is raised when more than one X.509 extension of the same type is |
| 1449 | found within a certificate. |
| 1450 | |
| 1451 | .. attribute:: oid |
| 1452 | |
| 1453 | :type: :class:`ObjectIdentifier` |
| 1454 | |
| 1455 | Returns the OID. |
| 1456 | |
| 1457 | .. class:: UnsupportedExtension |
| 1458 | |
| 1459 | This is raised when a certificate contains an unsupported extension type. |
| 1460 | |
| 1461 | .. attribute:: oid |
| 1462 | |
| 1463 | :type: :class:`ObjectIdentifier` |
| 1464 | |
| 1465 | Returns the OID. |
| 1466 | |
Paul Kehrer | fa56a23 | 2015-03-17 13:14:03 -0500 | [diff] [blame] | 1467 | .. class:: ExtensionNotFound |
| 1468 | |
| 1469 | This is raised when calling :meth:`Extensions.get_extension_for_oid` with |
| 1470 | an extension OID that is not present in the certificate. |
| 1471 | |
| 1472 | .. attribute:: oid |
| 1473 | |
| 1474 | :type: :class:`ObjectIdentifier` |
| 1475 | |
| 1476 | Returns the OID. |
| 1477 | |
Paul Kehrer | 9089c91 | 2015-04-20 22:15:20 -0500 | [diff] [blame] | 1478 | .. class:: UnsupportedGeneralNameType |
| 1479 | |
| 1480 | This is raised when a certificate contains an unsupported general name |
| 1481 | type in an extension. |
| 1482 | |
Paul Kehrer | bed0735 | 2015-04-21 08:31:10 -0500 | [diff] [blame] | 1483 | .. attribute:: type |
| 1484 | |
Paul Kehrer | 0a621bf | 2015-04-22 09:22:56 -0500 | [diff] [blame] | 1485 | :type: int |
| 1486 | |
| 1487 | The integer value of the unsupported type. The complete list of |
| 1488 | types can be found in `RFC 5280 section 4.2.1.6`_. |
Paul Kehrer | bed0735 | 2015-04-21 08:31:10 -0500 | [diff] [blame] | 1489 | |
Paul Kehrer | 016e08a | 2014-11-26 09:41:18 -1000 | [diff] [blame] | 1490 | |
| 1491 | .. _`public key infrastructure`: https://en.wikipedia.org/wiki/Public_key_infrastructure |
Paul Kehrer | a68fd33 | 2014-11-27 07:08:40 -1000 | [diff] [blame] | 1492 | .. _`TLS`: https://en.wikipedia.org/wiki/Transport_Layer_Security |
Paul Kehrer | c7c9a43 | 2015-04-19 09:20:13 -0500 | [diff] [blame] | 1493 | .. _`RFC 5280 section 4.2.1.1`: https://tools.ietf.org/html/rfc5280#section-4.2.1.1 |
Paul Kehrer | 0a621bf | 2015-04-22 09:22:56 -0500 | [diff] [blame] | 1494 | .. _`RFC 5280 section 4.2.1.6`: https://tools.ietf.org/html/rfc5280#section-4.2.1.6 |