Alex Gaynor | 4af5b37 | 2015-07-12 10:30:59 -0500 | [diff] [blame] | 1 | X.509 Reference |
| 2 | =============== |
Paul Kehrer | 016e08a | 2014-11-26 09:41:18 -1000 | [diff] [blame] | 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 | b2de948 | 2014-12-11 14:54:48 -0600 | [diff] [blame] | 89 | Loading Certificates |
| 90 | ~~~~~~~~~~~~~~~~~~~~ |
Paul Kehrer | 016e08a | 2014-11-26 09:41:18 -1000 | [diff] [blame] | 91 | |
| 92 | .. function:: load_pem_x509_certificate(data, backend) |
| 93 | |
| 94 | .. versionadded:: 0.7 |
| 95 | |
Paul Kehrer | e76cd27 | 2014-12-14 19:00:51 -0600 | [diff] [blame] | 96 | Deserialize a certificate from PEM encoded data. PEM certificates are |
| 97 | base64 decoded and have delimiters that look like |
| 98 | ``-----BEGIN CERTIFICATE-----``. |
Paul Kehrer | 016e08a | 2014-11-26 09:41:18 -1000 | [diff] [blame] | 99 | |
| 100 | :param bytes data: The PEM encoded certificate data. |
| 101 | |
| 102 | :param backend: A backend supporting the |
| 103 | :class:`~cryptography.hazmat.backends.interfaces.X509Backend` |
| 104 | interface. |
| 105 | |
Paul Kehrer | e76cd27 | 2014-12-14 19:00:51 -0600 | [diff] [blame] | 106 | :returns: An instance of :class:`~cryptography.x509.Certificate`. |
Paul Kehrer | 016e08a | 2014-11-26 09:41:18 -1000 | [diff] [blame] | 107 | |
| 108 | .. function:: load_der_x509_certificate(data, backend) |
| 109 | |
| 110 | .. versionadded:: 0.7 |
| 111 | |
Paul Kehrer | e76cd27 | 2014-12-14 19:00:51 -0600 | [diff] [blame] | 112 | Deserialize a certificate from DER encoded data. DER is a binary format |
Paul Kehrer | 92aac38 | 2014-12-15 16:25:28 -0600 | [diff] [blame] | 113 | and is commonly found in files with the ``.cer`` extension (although file |
| 114 | extensions are not a guarantee of encoding type). |
Paul Kehrer | 016e08a | 2014-11-26 09:41:18 -1000 | [diff] [blame] | 115 | |
| 116 | :param bytes data: The DER encoded certificate data. |
| 117 | |
| 118 | :param backend: A backend supporting the |
| 119 | :class:`~cryptography.hazmat.backends.interfaces.X509Backend` |
| 120 | interface. |
| 121 | |
Paul Kehrer | e76cd27 | 2014-12-14 19:00:51 -0600 | [diff] [blame] | 122 | :returns: An instance of :class:`~cryptography.x509.Certificate`. |
Paul Kehrer | 016e08a | 2014-11-26 09:41:18 -1000 | [diff] [blame] | 123 | |
Paul Kehrer | 016e08a | 2014-11-26 09:41:18 -1000 | [diff] [blame] | 124 | .. doctest:: |
| 125 | |
Paul Kehrer | cc8a26e | 2014-12-16 12:40:16 -0600 | [diff] [blame] | 126 | >>> from cryptography import x509 |
Paul Kehrer | 016e08a | 2014-11-26 09:41:18 -1000 | [diff] [blame] | 127 | >>> from cryptography.hazmat.backends import default_backend |
Paul Kehrer | cc8a26e | 2014-12-16 12:40:16 -0600 | [diff] [blame] | 128 | >>> cert = x509.load_pem_x509_certificate(pem_data, default_backend()) |
Paul Kehrer | 016e08a | 2014-11-26 09:41:18 -1000 | [diff] [blame] | 129 | >>> cert.serial |
| 130 | 2 |
| 131 | |
Paul Kehrer | a1a1f23 | 2015-03-15 15:34:35 -0500 | [diff] [blame] | 132 | Loading Certificate Signing Requests |
| 133 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
Paul Kehrer | dc480ad | 2015-02-23 12:14:54 -0600 | [diff] [blame] | 134 | |
Paul Kehrer | 31e3988 | 2015-03-11 11:37:04 -0500 | [diff] [blame] | 135 | .. function:: load_pem_x509_csr(data, backend) |
Paul Kehrer | dc480ad | 2015-02-23 12:14:54 -0600 | [diff] [blame] | 136 | |
| 137 | .. versionadded:: 0.9 |
| 138 | |
Paul Kehrer | a1a1f23 | 2015-03-15 15:34:35 -0500 | [diff] [blame] | 139 | Deserialize a certificate signing request (CSR) from PEM encoded data. PEM |
Paul Kehrer | 5aadb9c | 2015-03-11 20:48:42 -0500 | [diff] [blame] | 140 | requests are base64 decoded and have delimiters that look like |
Paul Kehrer | d3dafbd | 2015-03-15 16:24:18 -0500 | [diff] [blame] | 141 | ``-----BEGIN CERTIFICATE REQUEST-----``. This format is also known as |
| 142 | PKCS#10. |
Paul Kehrer | dc480ad | 2015-02-23 12:14:54 -0600 | [diff] [blame] | 143 | |
| 144 | :param bytes data: The PEM encoded request data. |
| 145 | |
| 146 | :param backend: A backend supporting the |
| 147 | :class:`~cryptography.hazmat.backends.interfaces.X509Backend` |
| 148 | interface. |
| 149 | |
Paul Kehrer | a1a1f23 | 2015-03-15 15:34:35 -0500 | [diff] [blame] | 150 | :returns: An instance of |
| 151 | :class:`~cryptography.x509.CertificateSigningRequest`. |
Paul Kehrer | dc480ad | 2015-02-23 12:14:54 -0600 | [diff] [blame] | 152 | |
Paul Kehrer | 1effb6e | 2015-03-30 15:05:59 -0500 | [diff] [blame] | 153 | .. function:: load_der_x509_csr(data, backend) |
| 154 | |
| 155 | .. versionadded:: 0.9 |
| 156 | |
| 157 | Deserialize a certificate signing request (CSR) from DER encoded data. DER |
| 158 | is a binary format and is not commonly used with CSRs. |
| 159 | |
| 160 | :param bytes data: The DER encoded request data. |
| 161 | |
| 162 | :param backend: A backend supporting the |
| 163 | :class:`~cryptography.hazmat.backends.interfaces.X509Backend` |
| 164 | interface. |
| 165 | |
| 166 | :returns: An instance of |
| 167 | :class:`~cryptography.x509.CertificateSigningRequest`. |
| 168 | |
Paul Kehrer | dc480ad | 2015-02-23 12:14:54 -0600 | [diff] [blame] | 169 | .. doctest:: |
| 170 | |
| 171 | >>> from cryptography import x509 |
| 172 | >>> from cryptography.hazmat.backends import default_backend |
| 173 | >>> from cryptography.hazmat.primitives import hashes |
Paul Kehrer | a1a1f23 | 2015-03-15 15:34:35 -0500 | [diff] [blame] | 174 | >>> csr = x509.load_pem_x509_csr(pem_req_data, default_backend()) |
| 175 | >>> isinstance(csr.signature_hash_algorithm, hashes.SHA1) |
Paul Kehrer | dc480ad | 2015-02-23 12:14:54 -0600 | [diff] [blame] | 176 | True |
| 177 | |
Paul Kehrer | e76cd27 | 2014-12-14 19:00:51 -0600 | [diff] [blame] | 178 | X.509 Certificate Object |
| 179 | ~~~~~~~~~~~~~~~~~~~~~~~~ |
Paul Kehrer | b2de948 | 2014-12-11 14:54:48 -0600 | [diff] [blame] | 180 | |
Paul Kehrer | e76cd27 | 2014-12-14 19:00:51 -0600 | [diff] [blame] | 181 | .. class:: Certificate |
Paul Kehrer | b2de948 | 2014-12-11 14:54:48 -0600 | [diff] [blame] | 182 | |
| 183 | .. versionadded:: 0.7 |
| 184 | |
| 185 | .. attribute:: version |
| 186 | |
Paul Kehrer | e76cd27 | 2014-12-14 19:00:51 -0600 | [diff] [blame] | 187 | :type: :class:`~cryptography.x509.Version` |
Paul Kehrer | b2de948 | 2014-12-11 14:54:48 -0600 | [diff] [blame] | 188 | |
Paul Kehrer | e76cd27 | 2014-12-14 19:00:51 -0600 | [diff] [blame] | 189 | The certificate version as an enumeration. Version 3 certificates are |
| 190 | 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] | 191 | |
Alex Gaynor | 89c4dc8 | 2014-12-16 16:49:33 -0800 | [diff] [blame] | 192 | :raises cryptography.x509.InvalidVersion: If the version in the |
Alex Gaynor | 6d7ab4c | 2014-12-16 16:50:33 -0800 | [diff] [blame] | 193 | certificate is not a known |
| 194 | :class:`X.509 version <cryptography.x509.Version>`. |
Paul Kehrer | 92aac38 | 2014-12-15 16:25:28 -0600 | [diff] [blame] | 195 | |
Paul Kehrer | cc8a26e | 2014-12-16 12:40:16 -0600 | [diff] [blame] | 196 | .. doctest:: |
| 197 | |
| 198 | >>> cert.version |
| 199 | <Version.v3: 2> |
| 200 | |
Paul Kehrer | b2de948 | 2014-12-11 14:54:48 -0600 | [diff] [blame] | 201 | .. method:: fingerprint(algorithm) |
| 202 | |
| 203 | :param algorithm: The |
Paul Kehrer | 601278a | 2015-02-12 12:51:00 -0600 | [diff] [blame] | 204 | :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` |
Paul Kehrer | b2de948 | 2014-12-11 14:54:48 -0600 | [diff] [blame] | 205 | that will be used to generate the fingerprint. |
| 206 | |
Erik Trauschke | 2dcce90 | 2015-05-14 16:12:24 -0700 | [diff] [blame] | 207 | :return bytes: The fingerprint using the supplied hash algorithm, as |
Paul Kehrer | b2de948 | 2014-12-11 14:54:48 -0600 | [diff] [blame] | 208 | bytes. |
| 209 | |
Paul Kehrer | cc8a26e | 2014-12-16 12:40:16 -0600 | [diff] [blame] | 210 | .. doctest:: |
| 211 | |
| 212 | >>> from cryptography.hazmat.primitives import hashes |
| 213 | >>> cert.fingerprint(hashes.SHA256()) |
Paul Kehrer | 78a8150 | 2014-12-16 14:47:52 -0600 | [diff] [blame] | 214 | '\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] | 215 | |
Paul Kehrer | b2de948 | 2014-12-11 14:54:48 -0600 | [diff] [blame] | 216 | .. attribute:: serial |
| 217 | |
| 218 | :type: int |
| 219 | |
| 220 | The serial as a Python integer. |
| 221 | |
Paul Kehrer | cc8a26e | 2014-12-16 12:40:16 -0600 | [diff] [blame] | 222 | .. doctest:: |
| 223 | |
| 224 | >>> cert.serial |
| 225 | 2 |
| 226 | |
Paul Kehrer | b2de948 | 2014-12-11 14:54:48 -0600 | [diff] [blame] | 227 | .. method:: public_key() |
| 228 | |
| 229 | :type: |
Alex Stapleton | f79c231 | 2014-12-30 12:50:14 +0000 | [diff] [blame] | 230 | :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey` or |
Paul Kehrer | 45efdbc | 2015-02-12 10:58:22 -0600 | [diff] [blame] | 231 | :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPublicKey` or |
| 232 | :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey` |
Paul Kehrer | b2de948 | 2014-12-11 14:54:48 -0600 | [diff] [blame] | 233 | |
| 234 | The public key associated with the certificate. |
| 235 | |
Paul Kehrer | cc8a26e | 2014-12-16 12:40:16 -0600 | [diff] [blame] | 236 | .. doctest:: |
| 237 | |
Alex Stapleton | f79c231 | 2014-12-30 12:50:14 +0000 | [diff] [blame] | 238 | >>> from cryptography.hazmat.primitives.asymmetric import rsa |
Paul Kehrer | cc8a26e | 2014-12-16 12:40:16 -0600 | [diff] [blame] | 239 | >>> public_key = cert.public_key() |
Alex Stapleton | f79c231 | 2014-12-30 12:50:14 +0000 | [diff] [blame] | 240 | >>> isinstance(public_key, rsa.RSAPublicKey) |
Paul Kehrer | cc8a26e | 2014-12-16 12:40:16 -0600 | [diff] [blame] | 241 | True |
| 242 | |
Paul Kehrer | b2de948 | 2014-12-11 14:54:48 -0600 | [diff] [blame] | 243 | .. attribute:: not_valid_before |
| 244 | |
| 245 | :type: :class:`datetime.datetime` |
| 246 | |
Paul Kehrer | 78a8150 | 2014-12-16 14:47:52 -0600 | [diff] [blame] | 247 | A naïve datetime representing the beginning of the validity period for |
| 248 | the certificate in UTC. This value is inclusive. |
Paul Kehrer | b2de948 | 2014-12-11 14:54:48 -0600 | [diff] [blame] | 249 | |
Paul Kehrer | cc8a26e | 2014-12-16 12:40:16 -0600 | [diff] [blame] | 250 | .. doctest:: |
| 251 | |
| 252 | >>> cert.not_valid_before |
| 253 | datetime.datetime(2010, 1, 1, 8, 30) |
| 254 | |
Paul Kehrer | b2de948 | 2014-12-11 14:54:48 -0600 | [diff] [blame] | 255 | .. attribute:: not_valid_after |
| 256 | |
| 257 | :type: :class:`datetime.datetime` |
| 258 | |
Paul Kehrer | 78a8150 | 2014-12-16 14:47:52 -0600 | [diff] [blame] | 259 | A naïve datetime representing the end of the validity period for the |
| 260 | certificate in UTC. This value is inclusive. |
Paul Kehrer | b2de948 | 2014-12-11 14:54:48 -0600 | [diff] [blame] | 261 | |
Paul Kehrer | cc8a26e | 2014-12-16 12:40:16 -0600 | [diff] [blame] | 262 | .. doctest:: |
| 263 | |
| 264 | >>> cert.not_valid_after |
| 265 | datetime.datetime(2030, 12, 31, 8, 30) |
| 266 | |
Paul Kehrer | 719d536 | 2015-01-01 20:03:52 -0600 | [diff] [blame] | 267 | .. attribute:: issuer |
| 268 | |
| 269 | .. versionadded:: 0.8 |
| 270 | |
| 271 | :type: :class:`Name` |
| 272 | |
| 273 | The :class:`Name` of the issuer. |
| 274 | |
| 275 | .. attribute:: subject |
| 276 | |
| 277 | .. versionadded:: 0.8 |
| 278 | |
| 279 | :type: :class:`Name` |
| 280 | |
| 281 | The :class:`Name` of the subject. |
| 282 | |
Paul Kehrer | 8802a5b | 2015-02-13 12:06:57 -0600 | [diff] [blame] | 283 | .. attribute:: signature_hash_algorithm |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 284 | |
Paul Kehrer | 8802a5b | 2015-02-13 12:06:57 -0600 | [diff] [blame] | 285 | :type: :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 286 | |
Paul Kehrer | e612ec7 | 2015-02-16 14:33:35 -0600 | [diff] [blame] | 287 | Returns the |
Paul Kehrer | 71d40c6 | 2015-02-19 08:21:04 -0600 | [diff] [blame] | 288 | :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` which |
Paul Kehrer | 1a7ba87 | 2015-02-19 18:09:05 -0600 | [diff] [blame] | 289 | was used in signing this certificate. |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 290 | |
| 291 | .. doctest:: |
| 292 | |
Paul Kehrer | 8802a5b | 2015-02-13 12:06:57 -0600 | [diff] [blame] | 293 | >>> from cryptography.hazmat.primitives import hashes |
| 294 | >>> isinstance(cert.signature_hash_algorithm, hashes.SHA256) |
| 295 | True |
Paul Kehrer | 719d536 | 2015-01-01 20:03:52 -0600 | [diff] [blame] | 296 | |
Paul Kehrer | fbb7ac8 | 2015-03-16 19:26:29 -0500 | [diff] [blame] | 297 | .. attribute:: extensions |
| 298 | |
| 299 | :type: :class:`Extensions` |
| 300 | |
| 301 | The extensions encoded in the certificate. |
| 302 | |
| 303 | :raises cryptography.x509.DuplicateExtension: If more than one |
| 304 | extension of the same type is found within the certificate. |
| 305 | |
Paul Kehrer | d8fc0be | 2015-04-21 08:31:10 -0500 | [diff] [blame] | 306 | :raises cryptography.x509.UnsupportedExtension: If the certificate |
| 307 | contains an extension that is not supported. |
| 308 | |
Paul Kehrer | bed0735 | 2015-04-21 08:31:10 -0500 | [diff] [blame] | 309 | :raises cryptography.x509.UnsupportedGeneralNameType: If an extension |
| 310 | contains a general name that is not supported. |
| 311 | |
Paul Kehrer | b896881 | 2015-05-15 09:01:34 -0700 | [diff] [blame] | 312 | :raises UnicodeError: If an extension contains IDNA encoding that is |
| 313 | invalid or not compliant with IDNA 2008. |
| 314 | |
Paul Kehrer | fa56a23 | 2015-03-17 13:14:03 -0500 | [diff] [blame] | 315 | .. doctest:: |
| 316 | |
| 317 | >>> for ext in cert.extensions: |
| 318 | ... print(ext) |
Paul Kehrer | d774de9 | 2015-05-03 10:52:25 -0500 | [diff] [blame] | 319 | <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] | 320 | <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] | 321 | <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] | 322 | <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] | 323 | <Extension(oid=<ObjectIdentifier(oid=2.5.29.19, name=basicConstraints)>, critical=True, value=<BasicConstraints(ca=True, path_length=None)>)> |
| 324 | |
Andre Caron | a8aded6 | 2015-05-19 20:11:57 -0400 | [diff] [blame] | 325 | .. method:: public_bytes(encoding) |
| 326 | |
Alex Gaynor | d0b376b | 2015-07-05 13:58:12 -0400 | [diff] [blame] | 327 | .. versionadded:: 1.0 |
| 328 | |
Andre Caron | a8aded6 | 2015-05-19 20:11:57 -0400 | [diff] [blame] | 329 | :param encoding: The |
| 330 | :class:`~cryptography.hazmat.primitives.serialization.Encoding` |
| 331 | that will be used to serialize the certificate. |
| 332 | |
| 333 | :return bytes: The data that can be written to a file or sent |
| 334 | over the network to be verified by clients. |
| 335 | |
Erik Trauschke | 2dcce90 | 2015-05-14 16:12:24 -0700 | [diff] [blame] | 336 | X.509 CRL (Certificate Revocation List) Object |
| 337 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 338 | |
| 339 | .. class:: CertificateRevocationList |
| 340 | |
| 341 | .. versionadded:: 1.0 |
| 342 | |
| 343 | .. method:: fingerprint(algorithm) |
| 344 | |
| 345 | :param algorithm: The |
| 346 | :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` |
| 347 | that will be used to generate the fingerprint. |
| 348 | |
| 349 | :return bytes: The fingerprint using the supplied hash algorithm, as |
| 350 | bytes. |
| 351 | |
| 352 | .. attribute:: signature_hash_algorithm |
| 353 | |
| 354 | :type: :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` |
| 355 | |
| 356 | Returns the |
| 357 | :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` which |
| 358 | was used in signing this CRL. |
| 359 | |
| 360 | .. attribute:: issuer |
| 361 | |
| 362 | :type: :class:`Name` |
| 363 | |
| 364 | The :class:`Name` of the issuer. |
| 365 | |
| 366 | .. attribute:: next_update |
| 367 | |
| 368 | :type: :class:`datetime.datetime` |
| 369 | |
| 370 | A naïve datetime representing when the next update to this CRL is |
| 371 | expected. |
| 372 | |
| 373 | .. attribute:: last_update |
| 374 | |
| 375 | :type: :class:`datetime.datetime` |
| 376 | |
| 377 | A naïve datetime representing when the this CRL was last updated. |
| 378 | |
Erik Trauschke | abb7b6e | 2015-05-27 15:07:35 -0700 | [diff] [blame] | 379 | .. attribute:: revoked_certificates |
Erik Trauschke | 2dcce90 | 2015-05-14 16:12:24 -0700 | [diff] [blame] | 380 | |
| 381 | :type: list of :class:`RevokedCertificate` |
| 382 | |
| 383 | The revoked certificates listed in this CRL. |
| 384 | |
| 385 | .. attribute:: extensions |
| 386 | |
| 387 | :type: :class:`Extensions` |
| 388 | |
| 389 | The extensions encoded in the CRL. |
| 390 | |
Andre Caron | 9bbfcea | 2015-05-18 20:55:29 -0400 | [diff] [blame] | 391 | X.509 Certificate Builder |
| 392 | ~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 393 | |
| 394 | .. class:: CertificateBuilder |
| 395 | |
Ian Cordasco | 1517a4b | 2015-08-02 22:11:19 -0500 | [diff] [blame] | 396 | .. versionadded:: 1.0 |
| 397 | |
| 398 | .. doctest:: |
| 399 | |
| 400 | >>> from cryptography import x509 |
| 401 | >>> from cryptography.hazmat.backends import default_backend |
| 402 | >>> from cryptography.hazmat.primitives import hashes |
| 403 | >>> from cryptography.hazmat.primitives.asymmetric import rsa |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 404 | >>> from cryptography.x509.oid import NameOID |
Ian Cordasco | 1517a4b | 2015-08-02 22:11:19 -0500 | [diff] [blame] | 405 | >>> import datetime |
| 406 | >>> import uuid |
| 407 | >>> one_day = datetime.timedelta(1, 0, 0) |
| 408 | >>> private_key = rsa.generate_private_key( |
| 409 | ... public_exponent=65537, |
| 410 | ... key_size=2048, |
| 411 | ... backend=default_backend() |
| 412 | ... ) |
| 413 | >>> public_key = rsa.generate_private_key( |
| 414 | ... public_exponent=65537, |
| 415 | ... key_size=2048, |
| 416 | ... backend=default_backend() |
| 417 | ... ).public_key() |
| 418 | >>> builder = x509.CertificateBuilder() |
| 419 | >>> builder = builder.subject_name(x509.Name([ |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 420 | ... x509.NameAttribute(NameOID.COMMON_NAME, u'cryptography.io'), |
Ian Cordasco | 1517a4b | 2015-08-02 22:11:19 -0500 | [diff] [blame] | 421 | ... ])) |
| 422 | >>> builder = builder.issuer_name(x509.Name([ |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 423 | ... x509.NameAttribute(NameOID.COMMON_NAME, u'cryptography.io'), |
Ian Cordasco | 1517a4b | 2015-08-02 22:11:19 -0500 | [diff] [blame] | 424 | ... ])) |
| 425 | >>> builder = builder.not_valid_before(datetime.datetime.today() - one_day) |
| 426 | >>> builder = builder.not_valid_after(datetime.datetime(2018, 8, 2)) |
| 427 | >>> builder = builder.serial_number(int(uuid.uuid4())) |
| 428 | >>> builder = builder.public_key(public_key) |
| 429 | >>> builder = builder.add_extension( |
| 430 | ... x509.BasicConstraints(ca=False, path_length=None), critical=True, |
| 431 | ... ) |
| 432 | >>> certificate = builder.sign( |
| 433 | ... private_key=private_key, algorithm=hashes.SHA256(), |
| 434 | ... backend=default_backend() |
| 435 | ... ) |
| 436 | >>> isinstance(certificate, x509.Certificate) |
| 437 | True |
| 438 | |
Ian Cordasco | 0092a0b | 2015-07-18 21:46:41 -0500 | [diff] [blame] | 439 | .. method:: issuer_name(name) |
Andre Caron | 9bbfcea | 2015-05-18 20:55:29 -0400 | [diff] [blame] | 440 | |
| 441 | Sets the issuer's distinguished name. |
| 442 | |
Ian Cordasco | c9682ad | 2015-08-01 12:11:13 -0500 | [diff] [blame] | 443 | :param name: The :class:`~cryptography.x509.Name` that describes the |
| 444 | issuer (CA). |
Andre Caron | 9bbfcea | 2015-05-18 20:55:29 -0400 | [diff] [blame] | 445 | |
Ian Cordasco | 0092a0b | 2015-07-18 21:46:41 -0500 | [diff] [blame] | 446 | .. method:: subject_name(name) |
Andre Caron | 9bbfcea | 2015-05-18 20:55:29 -0400 | [diff] [blame] | 447 | |
| 448 | Sets the subject's distinguished name. |
| 449 | |
Ian Cordasco | c9682ad | 2015-08-01 12:11:13 -0500 | [diff] [blame] | 450 | :param name: The :class:`~cryptography.x509.Name` that describes the |
Ian Cordasco | 85fc4d5 | 2015-08-01 20:29:31 -0500 | [diff] [blame] | 451 | subject. |
Andre Caron | 9bbfcea | 2015-05-18 20:55:29 -0400 | [diff] [blame] | 452 | |
Ian Cordasco | 0092a0b | 2015-07-18 21:46:41 -0500 | [diff] [blame] | 453 | .. method:: public_key(public_key) |
Andre Caron | 9bbfcea | 2015-05-18 20:55:29 -0400 | [diff] [blame] | 454 | |
| 455 | Sets the subject's public key. |
| 456 | |
Ian Cordasco | 8f57142 | 2015-08-02 11:31:08 -0500 | [diff] [blame] | 457 | :param public_key: The subject's public key. This can be one of |
| 458 | :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey`, |
| 459 | :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPublicKey` or |
| 460 | :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey` |
Andre Caron | 9bbfcea | 2015-05-18 20:55:29 -0400 | [diff] [blame] | 461 | |
Ian Cordasco | 0092a0b | 2015-07-18 21:46:41 -0500 | [diff] [blame] | 462 | .. method:: serial_number(serial_number) |
Andre Caron | 9bbfcea | 2015-05-18 20:55:29 -0400 | [diff] [blame] | 463 | |
| 464 | Sets the certificate's serial number (an integer). The CA's policy |
| 465 | determines how it attributes serial numbers to certificates. The only |
| 466 | requirement is that this number uniquely identify the certificate given |
| 467 | the issuer. |
| 468 | |
| 469 | :param serial_number: Integer number that will be used by the CA to |
| 470 | identify this certificate (most notably during certificate |
Ian Cordasco | 17c8900 | 2015-08-02 21:13:59 -0500 | [diff] [blame] | 471 | revocation checking). Users are encouraged to use a method of |
| 472 | generating 20 bytes of entropy, e.g., UUID4. For more information |
Ian Cordasco | b7530a4 | 2015-08-02 22:47:06 -0500 | [diff] [blame] | 473 | on secure random number generation, see :doc:`/random-numbers`. |
Andre Caron | 9bbfcea | 2015-05-18 20:55:29 -0400 | [diff] [blame] | 474 | |
Ian Cordasco | 0092a0b | 2015-07-18 21:46:41 -0500 | [diff] [blame] | 475 | .. method:: not_valid_before(time) |
Andre Caron | 9bbfcea | 2015-05-18 20:55:29 -0400 | [diff] [blame] | 476 | |
| 477 | Sets the certificate's activation time. This is the time from which |
| 478 | clients can start trusting the certificate. It may be different from |
| 479 | the time at which the certificate was created. |
| 480 | |
Ian Cordasco | 17c8900 | 2015-08-02 21:13:59 -0500 | [diff] [blame] | 481 | :param time: The :class:`datetime.datetime` object (in UTC) that marks the |
Andre Caron | 9bbfcea | 2015-05-18 20:55:29 -0400 | [diff] [blame] | 482 | activation time for the certificate. The certificate may not be |
| 483 | trusted clients if it is used before this time. |
| 484 | |
Ian Cordasco | 0092a0b | 2015-07-18 21:46:41 -0500 | [diff] [blame] | 485 | .. method:: not_valid_after(time) |
Andre Caron | 9bbfcea | 2015-05-18 20:55:29 -0400 | [diff] [blame] | 486 | |
| 487 | Sets the certificate's expiration time. This is the time from which |
| 488 | clients should no longer trust the certificate. The CA's policy will |
| 489 | determine how long the certificate should remain in use. |
| 490 | |
Ian Cordasco | 17c8900 | 2015-08-02 21:13:59 -0500 | [diff] [blame] | 491 | :param time: The :class:`datetime.datetime` object (in UTC) that marks the |
Andre Caron | 9bbfcea | 2015-05-18 20:55:29 -0400 | [diff] [blame] | 492 | expiration time for the certificate. The certificate may not be |
| 493 | trusted clients if it is used after this time. |
| 494 | |
Ian Cordasco | 17c8900 | 2015-08-02 21:13:59 -0500 | [diff] [blame] | 495 | .. method:: add_extension(extension, critical) |
Andre Caron | 9bbfcea | 2015-05-18 20:55:29 -0400 | [diff] [blame] | 496 | |
| 497 | Adds an X.509 extension to the certificate. |
| 498 | |
Ian Cordasco | 8f57142 | 2015-08-02 11:31:08 -0500 | [diff] [blame] | 499 | :param extension: The extension to add to the certificate. Can be one |
| 500 | of :class:`~cryptography.x509.BasicConstraints` or |
| 501 | :class:`~cryptography.x509.SubjectAlternativeName`. |
Andre Caron | 9bbfcea | 2015-05-18 20:55:29 -0400 | [diff] [blame] | 502 | |
Ian Cordasco | 17c8900 | 2015-08-02 21:13:59 -0500 | [diff] [blame] | 503 | :param critical: Set to ``True`` if the extension must be understood and |
| 504 | handled by whoever reads the certificate. |
| 505 | |
Paul Kehrer | 9add80e | 2015-08-03 17:53:14 +0100 | [diff] [blame] | 506 | .. method:: sign(private_key, algorithm, backend) |
Andre Caron | 9bbfcea | 2015-05-18 20:55:29 -0400 | [diff] [blame] | 507 | |
| 508 | Sign the certificate using the CA's private key. |
| 509 | |
Ian Cordasco | c5e1c25 | 2015-07-31 23:33:35 -0500 | [diff] [blame] | 510 | :param private_key: The |
| 511 | :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey`, |
| 512 | :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPrivateKey` or |
| 513 | :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateKey` |
| 514 | that will be used to sign the certificate. |
| 515 | |
Andre Caron | 9bbfcea | 2015-05-18 20:55:29 -0400 | [diff] [blame] | 516 | :param algorithm: The |
| 517 | :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` that |
| 518 | will be used to generate the signature. |
| 519 | |
Paul Kehrer | 9add80e | 2015-08-03 17:53:14 +0100 | [diff] [blame] | 520 | :param backend: Backend that will be used to build the certificate. |
| 521 | Must support the |
| 522 | :class:`~cryptography.hazmat.backends.interfaces.X509Backend` |
| 523 | interface. |
| 524 | |
Andre Caron | 9bbfcea | 2015-05-18 20:55:29 -0400 | [diff] [blame] | 525 | |
Paul Kehrer | 5aadb9c | 2015-03-11 20:48:42 -0500 | [diff] [blame] | 526 | X.509 CSR (Certificate Signing Request) Object |
| 527 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
Paul Kehrer | dc480ad | 2015-02-23 12:14:54 -0600 | [diff] [blame] | 528 | |
Paul Kehrer | a1a1f23 | 2015-03-15 15:34:35 -0500 | [diff] [blame] | 529 | .. class:: CertificateSigningRequest |
Paul Kehrer | dc480ad | 2015-02-23 12:14:54 -0600 | [diff] [blame] | 530 | |
| 531 | .. versionadded:: 0.9 |
| 532 | |
| 533 | .. method:: public_key() |
| 534 | |
| 535 | :type: |
| 536 | :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey` or |
| 537 | :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPublicKey` or |
| 538 | :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey` |
| 539 | |
| 540 | The public key associated with the request. |
| 541 | |
| 542 | .. doctest:: |
| 543 | |
| 544 | >>> from cryptography.hazmat.primitives.asymmetric import rsa |
Paul Kehrer | a1a1f23 | 2015-03-15 15:34:35 -0500 | [diff] [blame] | 545 | >>> public_key = csr.public_key() |
Paul Kehrer | dc480ad | 2015-02-23 12:14:54 -0600 | [diff] [blame] | 546 | >>> isinstance(public_key, rsa.RSAPublicKey) |
| 547 | True |
| 548 | |
| 549 | .. attribute:: subject |
| 550 | |
| 551 | :type: :class:`Name` |
| 552 | |
| 553 | The :class:`Name` of the subject. |
| 554 | |
| 555 | .. attribute:: signature_hash_algorithm |
| 556 | |
| 557 | :type: :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` |
| 558 | |
| 559 | Returns the |
| 560 | :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` which |
| 561 | was used in signing this request. |
| 562 | |
| 563 | .. doctest:: |
| 564 | |
| 565 | >>> from cryptography.hazmat.primitives import hashes |
Paul Kehrer | a1a1f23 | 2015-03-15 15:34:35 -0500 | [diff] [blame] | 566 | >>> isinstance(csr.signature_hash_algorithm, hashes.SHA1) |
Paul Kehrer | dc480ad | 2015-02-23 12:14:54 -0600 | [diff] [blame] | 567 | True |
| 568 | |
Paul Kehrer | c4e6194 | 2015-08-01 21:21:13 +0100 | [diff] [blame] | 569 | .. attribute:: extensions |
| 570 | |
| 571 | :type: :class:`Extensions` |
| 572 | |
| 573 | The extensions encoded in the certificate signing request. |
| 574 | |
| 575 | :raises cryptography.x509.DuplicateExtension: If more than one |
Paul Kehrer | 24283d2 | 2015-08-01 21:31:19 +0100 | [diff] [blame] | 576 | extension of the same type is found within the certificate signing request. |
Paul Kehrer | c4e6194 | 2015-08-01 21:21:13 +0100 | [diff] [blame] | 577 | |
Paul Kehrer | 24283d2 | 2015-08-01 21:31:19 +0100 | [diff] [blame] | 578 | :raises cryptography.x509.UnsupportedExtension: If the certificate signing request |
Paul Kehrer | c4e6194 | 2015-08-01 21:21:13 +0100 | [diff] [blame] | 579 | contains an extension that is not supported. |
| 580 | |
| 581 | :raises cryptography.x509.UnsupportedGeneralNameType: If an extension |
| 582 | contains a general name that is not supported. |
| 583 | |
| 584 | :raises UnicodeError: If an extension contains IDNA encoding that is |
| 585 | invalid or not compliant with IDNA 2008. |
| 586 | |
| 587 | |
Andre Caron | 476c5df | 2015-05-18 10:23:28 -0400 | [diff] [blame] | 588 | .. method:: public_bytes(encoding) |
| 589 | |
Alex Gaynor | d0b376b | 2015-07-05 13:58:12 -0400 | [diff] [blame] | 590 | .. versionadded:: 1.0 |
| 591 | |
Andre Caron | 476c5df | 2015-05-18 10:23:28 -0400 | [diff] [blame] | 592 | :param encoding: The |
| 593 | :class:`~cryptography.hazmat.primitives.serialization.Encoding` |
| 594 | that will be used to serialize the certificate request. |
| 595 | |
| 596 | :return bytes: The data that can be written to a file or sent |
| 597 | over the network to be signed by the certificate |
| 598 | authority. |
| 599 | |
Erik Trauschke | 2dcce90 | 2015-05-14 16:12:24 -0700 | [diff] [blame] | 600 | X.509 Revoked Certificate Object |
Erik Trauschke | c5a8d17 | 2015-05-28 10:24:25 -0700 | [diff] [blame] | 601 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
Erik Trauschke | 2dcce90 | 2015-05-14 16:12:24 -0700 | [diff] [blame] | 602 | |
| 603 | .. class:: RevokedCertificate |
| 604 | |
| 605 | .. versionadded:: 1.0 |
| 606 | |
| 607 | .. attribute:: serial_number |
| 608 | |
| 609 | :type: :class:`int` |
| 610 | |
| 611 | An integer representing the serial number of the revoked certificate. |
| 612 | |
| 613 | .. attribute:: revocation_date |
| 614 | |
| 615 | :type: :class:`datetime.datetime` |
| 616 | |
| 617 | A naïve datetime representing the date this certificates was revoked. |
| 618 | |
| 619 | .. attribute:: extensions |
| 620 | |
| 621 | :type: :class:`Extensions` |
| 622 | |
| 623 | The extensions encoded in the revoked certificate. |
Andre Caron | 476c5df | 2015-05-18 10:23:28 -0400 | [diff] [blame] | 624 | |
Andre Caron | 0ef595f | 2015-05-18 13:53:43 -0400 | [diff] [blame] | 625 | X.509 CSR (Certificate Signing Request) Builder Object |
| 626 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 627 | |
| 628 | .. class:: CertificateSigningRequestBuilder |
| 629 | |
Andre Caron | d259ee5 | 2015-06-02 23:47:11 -0400 | [diff] [blame] | 630 | .. versionadded:: 1.0 |
| 631 | |
| 632 | .. doctest:: |
| 633 | |
| 634 | >>> from cryptography import x509 |
| 635 | >>> from cryptography.hazmat.backends import default_backend |
| 636 | >>> from cryptography.hazmat.primitives import hashes |
| 637 | >>> from cryptography.hazmat.primitives.asymmetric import rsa |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 638 | >>> from cryptography.x509.oid import NameOID |
Andre Caron | d259ee5 | 2015-06-02 23:47:11 -0400 | [diff] [blame] | 639 | >>> private_key = rsa.generate_private_key( |
| 640 | ... public_exponent=65537, |
| 641 | ... key_size=2048, |
| 642 | ... backend=default_backend() |
| 643 | ... ) |
| 644 | >>> builder = x509.CertificateSigningRequestBuilder() |
Andre Caron | a9a5117 | 2015-06-06 20:18:44 -0400 | [diff] [blame] | 645 | >>> builder = builder.subject_name(x509.Name([ |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 646 | ... x509.NameAttribute(NameOID.COMMON_NAME, u'cryptography.io'), |
Andre Caron | d259ee5 | 2015-06-02 23:47:11 -0400 | [diff] [blame] | 647 | ... ])) |
Ian Cordasco | f06b6be | 2015-06-21 10:09:18 -0500 | [diff] [blame] | 648 | >>> builder = builder.add_extension( |
Ian Cordasco | 0112b02 | 2015-06-16 17:51:18 -0500 | [diff] [blame] | 649 | ... x509.BasicConstraints(ca=False, path_length=None), critical=True, |
Andre Caron | 472fd69 | 2015-06-06 20:04:44 -0400 | [diff] [blame] | 650 | ... ) |
Andre Caron | d259ee5 | 2015-06-02 23:47:11 -0400 | [diff] [blame] | 651 | >>> request = builder.sign( |
Alex Gaynor | de9e584 | 2015-06-26 20:11:23 -0400 | [diff] [blame] | 652 | ... private_key, hashes.SHA256(), default_backend() |
Andre Caron | d259ee5 | 2015-06-02 23:47:11 -0400 | [diff] [blame] | 653 | ... ) |
| 654 | >>> isinstance(request, x509.CertificateSigningRequest) |
| 655 | True |
| 656 | |
Andre Caron | a9a5117 | 2015-06-06 20:18:44 -0400 | [diff] [blame] | 657 | .. method:: subject_name(name) |
Andre Caron | 0ef595f | 2015-05-18 13:53:43 -0400 | [diff] [blame] | 658 | |
Andre Caron | 341ff85 | 2015-06-06 20:14:31 -0400 | [diff] [blame] | 659 | :param name: The :class:`~cryptography.x509.Name` of the certificate |
| 660 | subject. |
| 661 | :returns: A new |
| 662 | :class:`~cryptography.x509.CertificateSigningRequestBuilder`. |
Andre Caron | 0ef595f | 2015-05-18 13:53:43 -0400 | [diff] [blame] | 663 | |
Ian Cordasco | f06b6be | 2015-06-21 10:09:18 -0500 | [diff] [blame] | 664 | .. method:: add_extension(extension, critical) |
Andre Caron | 0ef595f | 2015-05-18 13:53:43 -0400 | [diff] [blame] | 665 | |
Andre Caron | 341ff85 | 2015-06-06 20:14:31 -0400 | [diff] [blame] | 666 | :param extension: The :class:`~cryptography.x509.Extension` to add to |
| 667 | the request. |
Andre Caron | 472fd69 | 2015-06-06 20:04:44 -0400 | [diff] [blame] | 668 | :param critical: Set to `True` if the extension must be understood and |
| 669 | handled by whoever reads the certificate. |
Andre Caron | 341ff85 | 2015-06-06 20:14:31 -0400 | [diff] [blame] | 670 | :returns: A new |
| 671 | :class:`~cryptography.x509.CertificateSigningRequestBuilder`. |
Andre Caron | 0ef595f | 2015-05-18 13:53:43 -0400 | [diff] [blame] | 672 | |
Alex Gaynor | b3b0fbe | 2015-06-26 19:57:18 -0400 | [diff] [blame] | 673 | .. method:: sign(private_key, algorithm, backend) |
Andre Caron | 0ef595f | 2015-05-18 13:53:43 -0400 | [diff] [blame] | 674 | |
| 675 | :param backend: Backend that will be used to sign the request. |
| 676 | Must support the |
| 677 | :class:`~cryptography.hazmat.backends.interfaces.X509Backend` |
| 678 | interface. |
| 679 | |
| 680 | :param private_key: The |
Andre Caron | 24f9bf4 | 2015-06-06 20:14:54 -0400 | [diff] [blame] | 681 | :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey`, |
| 682 | :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPrivateKey` or |
| 683 | :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateKey` |
Andre Caron | 0ef595f | 2015-05-18 13:53:43 -0400 | [diff] [blame] | 684 | that will be used to sign the request. When the request is |
| 685 | signed by a certificate authority, the private key's associated |
| 686 | public key will be stored in the resulting certificate. |
| 687 | |
| 688 | :param algorithm: The |
| 689 | :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` |
| 690 | that will be used to generate the request signature. |
| 691 | |
Andre Caron | 341ff85 | 2015-06-06 20:14:31 -0400 | [diff] [blame] | 692 | :returns: A new |
| 693 | :class:`~cryptography.x509.CertificateSigningRequest`. |
Andre Caron | 0ef595f | 2015-05-18 13:53:43 -0400 | [diff] [blame] | 694 | |
| 695 | |
Paul Kehrer | 719d536 | 2015-01-01 20:03:52 -0600 | [diff] [blame] | 696 | .. class:: Name |
| 697 | |
| 698 | .. versionadded:: 0.8 |
| 699 | |
Paul Kehrer | 53d8d49 | 2015-02-13 18:47:30 -0600 | [diff] [blame] | 700 | 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] | 701 | 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] | 702 | obtain the specific type you want. Names are sometimes represented as a |
Paul Kehrer | 53d8d49 | 2015-02-13 18:47:30 -0600 | [diff] [blame] | 703 | slash or comma delimited string (e.g. ``/CN=mydomain.com/O=My Org/C=US`` or |
| 704 | ``CN=mydomain.com, O=My Org, C=US``). |
Paul Kehrer | 719d536 | 2015-01-01 20:03:52 -0600 | [diff] [blame] | 705 | |
Paul Kehrer | 53d8d49 | 2015-02-13 18:47:30 -0600 | [diff] [blame] | 706 | .. doctest:: |
Paul Kehrer | 719d536 | 2015-01-01 20:03:52 -0600 | [diff] [blame] | 707 | |
Paul Kehrer | 8b21a4a | 2015-02-14 07:56:36 -0600 | [diff] [blame] | 708 | >>> len(cert.subject) |
Paul Kehrer | 53d8d49 | 2015-02-13 18:47:30 -0600 | [diff] [blame] | 709 | 3 |
Paul Kehrer | 8b21a4a | 2015-02-14 07:56:36 -0600 | [diff] [blame] | 710 | >>> for attribute in cert.subject: |
| 711 | ... print(attribute) |
| 712 | <NameAttribute(oid=<ObjectIdentifier(oid=2.5.4.6, name=countryName)>, value=u'US')> |
| 713 | <NameAttribute(oid=<ObjectIdentifier(oid=2.5.4.10, name=organizationName)>, value=u'Test Certificates 2011')> |
| 714 | <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] | 715 | |
Paul Kehrer | e901d64 | 2015-02-11 18:50:58 -0600 | [diff] [blame] | 716 | .. method:: get_attributes_for_oid(oid) |
Paul Kehrer | 719d536 | 2015-01-01 20:03:52 -0600 | [diff] [blame] | 717 | |
Paul Kehrer | e901d64 | 2015-02-11 18:50:58 -0600 | [diff] [blame] | 718 | :param oid: An :class:`ObjectIdentifier` instance. |
Paul Kehrer | 719d536 | 2015-01-01 20:03:52 -0600 | [diff] [blame] | 719 | |
Paul Kehrer | e901d64 | 2015-02-11 18:50:58 -0600 | [diff] [blame] | 720 | :returns: A list of :class:`NameAttribute` instances that match the |
| 721 | OID provided. If nothing matches an empty list will be returned. |
Paul Kehrer | 719d536 | 2015-01-01 20:03:52 -0600 | [diff] [blame] | 722 | |
| 723 | .. doctest:: |
| 724 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 725 | >>> cert.subject.get_attributes_for_oid(NameOID.COMMON_NAME) |
Paul Kehrer | e901d64 | 2015-02-11 18:50:58 -0600 | [diff] [blame] | 726 | [<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] | 727 | |
Paul Kehrer | e76cd27 | 2014-12-14 19:00:51 -0600 | [diff] [blame] | 728 | .. class:: Version |
Paul Kehrer | 016e08a | 2014-11-26 09:41:18 -1000 | [diff] [blame] | 729 | |
| 730 | .. versionadded:: 0.7 |
| 731 | |
| 732 | An enumeration for X.509 versions. |
| 733 | |
| 734 | .. attribute:: v1 |
| 735 | |
| 736 | For version 1 X.509 certificates. |
| 737 | |
| 738 | .. attribute:: v3 |
| 739 | |
| 740 | For version 3 X.509 certificates. |
| 741 | |
Paul Kehrer | 806bfb2 | 2015-02-02 17:05:24 -0600 | [diff] [blame] | 742 | .. class:: NameAttribute |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 743 | |
| 744 | .. versionadded:: 0.8 |
| 745 | |
Paul Kehrer | 834d22f | 2015-02-06 11:01:07 -0600 | [diff] [blame] | 746 | An X.509 name consists of a list of NameAttribute instances. |
Paul Kehrer | 5b0a8d6 | 2015-01-30 20:05:55 -0600 | [diff] [blame] | 747 | |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 748 | .. attribute:: oid |
| 749 | |
| 750 | :type: :class:`ObjectIdentifier` |
| 751 | |
| 752 | The attribute OID. |
| 753 | |
| 754 | .. attribute:: value |
| 755 | |
Paul Kehrer | d5852cb | 2015-01-30 08:25:23 -0600 | [diff] [blame] | 756 | :type: :term:`text` |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 757 | |
| 758 | The value of the attribute. |
| 759 | |
| 760 | .. class:: ObjectIdentifier |
| 761 | |
| 762 | .. versionadded:: 0.8 |
| 763 | |
Paul Kehrer | 5b0a8d6 | 2015-01-30 20:05:55 -0600 | [diff] [blame] | 764 | Object identifiers (frequently seen abbreviated as OID) identify the type |
Paul Kehrer | 806bfb2 | 2015-02-02 17:05:24 -0600 | [diff] [blame] | 765 | of a value (see: :class:`NameAttribute`). |
Paul Kehrer | 5b0a8d6 | 2015-01-30 20:05:55 -0600 | [diff] [blame] | 766 | |
Paul Kehrer | d44f9a6 | 2015-02-04 14:47:34 -0600 | [diff] [blame] | 767 | .. attribute:: dotted_string |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 768 | |
| 769 | :type: :class:`str` |
| 770 | |
Paul Kehrer | fedf4f4 | 2015-02-06 11:22:07 -0600 | [diff] [blame] | 771 | 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] | 772 | |
Paul Kehrer | 31bdf79 | 2015-03-25 14:11:00 -0500 | [diff] [blame] | 773 | .. _general_name_classes: |
| 774 | |
| 775 | General Name Classes |
| 776 | ~~~~~~~~~~~~~~~~~~~~ |
| 777 | |
| 778 | .. class:: GeneralName |
| 779 | |
| 780 | .. versionadded:: 0.9 |
| 781 | |
| 782 | This is the generic interface that all the following classes are registered |
| 783 | against. |
| 784 | |
| 785 | .. class:: RFC822Name |
| 786 | |
| 787 | .. versionadded:: 0.9 |
| 788 | |
| 789 | This corresponds to an email address. For example, ``user@example.com``. |
| 790 | |
| 791 | .. attribute:: value |
| 792 | |
| 793 | :type: :term:`text` |
| 794 | |
| 795 | .. class:: DNSName |
| 796 | |
| 797 | .. versionadded:: 0.9 |
| 798 | |
| 799 | This corresponds to a domain name. For example, ``cryptography.io``. |
| 800 | |
| 801 | .. attribute:: value |
| 802 | |
| 803 | :type: :term:`text` |
| 804 | |
| 805 | .. class:: DirectoryName |
| 806 | |
| 807 | .. versionadded:: 0.9 |
| 808 | |
| 809 | This corresponds to a directory name. |
| 810 | |
| 811 | .. attribute:: value |
| 812 | |
| 813 | :type: :class:`Name` |
| 814 | |
| 815 | .. class:: UniformResourceIdentifier |
| 816 | |
| 817 | .. versionadded:: 0.9 |
| 818 | |
| 819 | This corresponds to a uniform resource identifier. For example, |
Paul Kehrer | b8ef82e | 2015-04-22 16:04:24 -0500 | [diff] [blame] | 820 | ``https://cryptography.io``. The URI is parsed and IDNA decoded (see |
| 821 | :rfc:`5895`). |
| 822 | |
| 823 | .. note:: |
| 824 | |
| 825 | URIs that do not contain ``://`` in them will not be decoded. |
Paul Kehrer | 31bdf79 | 2015-03-25 14:11:00 -0500 | [diff] [blame] | 826 | |
| 827 | .. attribute:: value |
| 828 | |
| 829 | :type: :term:`text` |
| 830 | |
| 831 | .. class:: IPAddress |
| 832 | |
| 833 | .. versionadded:: 0.9 |
| 834 | |
| 835 | This corresponds to an IP address. |
| 836 | |
| 837 | .. attribute:: value |
| 838 | |
Paul Kehrer | eb17793 | 2015-05-17 18:33:33 -0700 | [diff] [blame] | 839 | :type: :class:`~ipaddress.IPv4Address`, |
| 840 | :class:`~ipaddress.IPv6Address`, :class:`~ipaddress.IPv4Network`, |
| 841 | or :class:`~ipaddress.IPv6Network`. |
Paul Kehrer | 31bdf79 | 2015-03-25 14:11:00 -0500 | [diff] [blame] | 842 | |
| 843 | .. class:: RegisteredID |
| 844 | |
| 845 | .. versionadded:: 0.9 |
| 846 | |
| 847 | This corresponds to a registered ID. |
| 848 | |
| 849 | .. attribute:: value |
| 850 | |
| 851 | :type: :class:`ObjectIdentifier` |
| 852 | |
Joshua Tauberer | 2ee5e3c | 2015-07-04 20:09:46 +0000 | [diff] [blame] | 853 | .. class:: OtherName |
| 854 | |
| 855 | .. versionadded:: 1.0 |
| 856 | |
Joshua Tauberer | 18b6fc8 | 2015-07-05 21:44:51 +0000 | [diff] [blame] | 857 | This corresponds to an ``otherName.`` An ``otherName`` has a type identifier and a value represented in binary DER format. |
Joshua Tauberer | 2ee5e3c | 2015-07-04 20:09:46 +0000 | [diff] [blame] | 858 | |
| 859 | .. attribute:: type_id |
| 860 | |
| 861 | :type: :class:`ObjectIdentifier` |
| 862 | |
| 863 | .. attribute:: value |
| 864 | |
| 865 | :type: `bytes` |
| 866 | |
Paul Kehrer | 8cf2642 | 2015-03-21 09:50:24 -0500 | [diff] [blame] | 867 | X.509 Extensions |
| 868 | ~~~~~~~~~~~~~~~~ |
| 869 | |
Paul Kehrer | fbb7ac8 | 2015-03-16 19:26:29 -0500 | [diff] [blame] | 870 | .. class:: Extensions |
| 871 | |
| 872 | .. versionadded:: 0.9 |
| 873 | |
| 874 | An X.509 Extensions instance is an ordered list of extensions. The object |
| 875 | is iterable to get every extension. |
| 876 | |
Paul Kehrer | fa56a23 | 2015-03-17 13:14:03 -0500 | [diff] [blame] | 877 | .. method:: get_extension_for_oid(oid) |
| 878 | |
| 879 | :param oid: An :class:`ObjectIdentifier` instance. |
| 880 | |
| 881 | :returns: An instance of the extension class. |
| 882 | |
| 883 | :raises cryptography.x509.ExtensionNotFound: If the certificate does |
| 884 | not have the extension requested. |
| 885 | |
Paul Kehrer | fa56a23 | 2015-03-17 13:14:03 -0500 | [diff] [blame] | 886 | .. doctest:: |
| 887 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 888 | >>> from cryptography.x509.oid import ExtensionOID |
| 889 | >>> cert.extensions.get_extension_for_oid(ExtensionOID.BASIC_CONSTRAINTS) |
Paul Kehrer | fa56a23 | 2015-03-17 13:14:03 -0500 | [diff] [blame] | 890 | <Extension(oid=<ObjectIdentifier(oid=2.5.29.19, name=basicConstraints)>, critical=True, value=<BasicConstraints(ca=True, path_length=None)>)> |
| 891 | |
Phoebe Queen | 019b7f8 | 2015-08-12 03:52:03 +0100 | [diff] [blame] | 892 | .. method:: get_extension_for_class(extclass) |
| 893 | |
Phoebe Queen | 6a603eb | 2015-08-12 14:14:49 +0100 | [diff] [blame] | 894 | .. versionadded:: 1.1 |
| 895 | |
Phoebe Queen | 019b7f8 | 2015-08-12 03:52:03 +0100 | [diff] [blame] | 896 | :param extclass: An extension class. |
| 897 | |
| 898 | :returns: An instance of the extension class. |
| 899 | |
| 900 | :raises cryptography.x509.ExtensionNotFound: If the certificate does |
| 901 | not have the extension requested. |
| 902 | |
| 903 | .. doctest:: |
| 904 | |
| 905 | >>> from cryptography import x509 |
| 906 | >>> cert.extensions.get_extension_for_class(x509.BasicConstraints) |
| 907 | <Extension(oid=<ObjectIdentifier(oid=2.5.29.19, name=basicConstraints)>, critical=True, value=<BasicConstraints(ca=True, path_length=None)>)> |
| 908 | |
Paul Kehrer | 8cf2642 | 2015-03-21 09:50:24 -0500 | [diff] [blame] | 909 | .. class:: Extension |
| 910 | |
| 911 | .. versionadded:: 0.9 |
| 912 | |
Paul Kehrer | 8589466 | 2015-03-22 13:19:31 -0500 | [diff] [blame] | 913 | .. attribute:: oid |
| 914 | |
| 915 | :type: :class:`ObjectIdentifier` |
| 916 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 917 | One of the :class:`~cryptography.x509.oid.ExtensionOID` OIDs. |
Paul Kehrer | 8cf2642 | 2015-03-21 09:50:24 -0500 | [diff] [blame] | 918 | |
| 919 | .. attribute:: critical |
| 920 | |
| 921 | :type: bool |
| 922 | |
Paul Kehrer | 58b7569 | 2015-03-22 23:24:58 -0500 | [diff] [blame] | 923 | Determines whether a given extension is critical or not. :rfc:`5280` |
| 924 | requires that "A certificate-using system MUST reject the certificate |
| 925 | if it encounters a critical extension it does not recognize or a |
| 926 | critical extension that contains information that it cannot process". |
Paul Kehrer | 8cf2642 | 2015-03-21 09:50:24 -0500 | [diff] [blame] | 927 | |
Paul Kehrer | 8589466 | 2015-03-22 13:19:31 -0500 | [diff] [blame] | 928 | .. attribute:: value |
| 929 | |
| 930 | Returns an instance of the extension type corresponding to the OID. |
| 931 | |
Paul Kehrer | 14f0bd0 | 2015-08-06 11:55:18 +0100 | [diff] [blame] | 932 | .. class:: ExtensionType |
| 933 | |
| 934 | .. versionadded:: 1.0 |
| 935 | |
| 936 | This is the interface against which all the following extension types are |
| 937 | registered. |
| 938 | |
Paul Kehrer | cecbbba | 2015-03-30 14:58:38 -0500 | [diff] [blame] | 939 | .. class:: KeyUsage |
| 940 | |
| 941 | .. versionadded:: 0.9 |
| 942 | |
| 943 | The key usage extension defines the purpose of the key contained in the |
| 944 | certificate. The usage restriction might be employed when a key that could |
Paul Kehrer | b33de93 | 2015-08-06 23:41:05 +0100 | [diff] [blame] | 945 | be used for more than one operation is to be restricted. |
Paul Kehrer | cecbbba | 2015-03-30 14:58:38 -0500 | [diff] [blame] | 946 | |
Paul Kehrer | 822f3d3 | 2015-08-06 11:47:32 +0100 | [diff] [blame] | 947 | .. attribute:: oid |
| 948 | |
| 949 | .. versionadded:: 1.0 |
| 950 | |
| 951 | :type: :class:`ObjectIdentifier` |
| 952 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 953 | Returns :attr:`~cryptography.x509.oid.ExtensionOID.KEY_USAGE`. |
Paul Kehrer | 822f3d3 | 2015-08-06 11:47:32 +0100 | [diff] [blame] | 954 | |
Paul Kehrer | cecbbba | 2015-03-30 14:58:38 -0500 | [diff] [blame] | 955 | .. attribute:: digital_signature |
| 956 | |
| 957 | :type: bool |
| 958 | |
Paul Kehrer | 738407b | 2015-04-01 22:39:02 -0500 | [diff] [blame] | 959 | 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] | 960 | digital signatures, other than signatures on certificates |
| 961 | (``key_cert_sign``) and CRLs (``crl_sign``). |
| 962 | |
| 963 | .. attribute:: content_commitment |
| 964 | |
| 965 | :type: bool |
| 966 | |
Paul Kehrer | 738407b | 2015-04-01 22:39:02 -0500 | [diff] [blame] | 967 | 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] | 968 | digital signatures, other than signatures on certificates |
| 969 | (``key_cert_sign``) and CRLs (``crl_sign``). It is used to provide a |
| 970 | non-repudiation service that protects against the signing entity |
| 971 | falsely denying some action. In the case of later conflict, a |
| 972 | reliable third party may determine the authenticity of the signed |
| 973 | data. This was called ``non_repudiation`` in older revisions of the |
| 974 | X.509 specification. |
| 975 | |
| 976 | .. attribute:: key_encipherment |
| 977 | |
| 978 | :type: bool |
| 979 | |
Paul Kehrer | 738407b | 2015-04-01 22:39:02 -0500 | [diff] [blame] | 980 | This purpose is set to true when the subject public key is used for |
| 981 | enciphering private or secret keys. |
Paul Kehrer | cecbbba | 2015-03-30 14:58:38 -0500 | [diff] [blame] | 982 | |
| 983 | .. attribute:: data_encipherment |
| 984 | |
| 985 | :type: bool |
| 986 | |
Paul Kehrer | 738407b | 2015-04-01 22:39:02 -0500 | [diff] [blame] | 987 | This purpose is set to true when the subject public key is used for |
| 988 | directly enciphering raw user data without the use of an intermediate |
| 989 | symmetric cipher. |
Paul Kehrer | cecbbba | 2015-03-30 14:58:38 -0500 | [diff] [blame] | 990 | |
| 991 | .. attribute:: key_agreement |
| 992 | |
| 993 | :type: bool |
| 994 | |
Paul Kehrer | 738407b | 2015-04-01 22:39:02 -0500 | [diff] [blame] | 995 | This purpose is set to true when the subject public key is used for key |
| 996 | agreement. For example, when a Diffie-Hellman key is to be used for |
| 997 | key management, then this purpose is set to true. |
Paul Kehrer | cecbbba | 2015-03-30 14:58:38 -0500 | [diff] [blame] | 998 | |
| 999 | .. attribute:: key_cert_sign |
| 1000 | |
| 1001 | :type: bool |
| 1002 | |
Paul Kehrer | 738407b | 2015-04-01 22:39:02 -0500 | [diff] [blame] | 1003 | This purpose is set to true when the subject public key is used for |
| 1004 | verifying signatures on public key certificates. If this purpose is set |
| 1005 | to true then ``ca`` must be true in the :class:`BasicConstraints` |
| 1006 | extension. |
Paul Kehrer | cecbbba | 2015-03-30 14:58:38 -0500 | [diff] [blame] | 1007 | |
| 1008 | .. attribute:: crl_sign |
| 1009 | |
| 1010 | :type: bool |
| 1011 | |
Paul Kehrer | 738407b | 2015-04-01 22:39:02 -0500 | [diff] [blame] | 1012 | This purpose is set to true when the subject public key is used for |
| 1013 | verifying signatures on certificate revocation lists. |
Paul Kehrer | cecbbba | 2015-03-30 14:58:38 -0500 | [diff] [blame] | 1014 | |
| 1015 | .. attribute:: encipher_only |
| 1016 | |
| 1017 | :type: bool |
| 1018 | |
Paul Kehrer | 738407b | 2015-04-01 22:39:02 -0500 | [diff] [blame] | 1019 | When this purposes is set to true and the ``key_agreement`` purpose is |
| 1020 | also set, the subject public key may be used only for enciphering data |
| 1021 | while performing key agreement. |
Paul Kehrer | cecbbba | 2015-03-30 14:58:38 -0500 | [diff] [blame] | 1022 | |
| 1023 | :raises ValueError: This is raised if accessed when ``key_agreement`` |
| 1024 | is false. |
| 1025 | |
| 1026 | .. attribute:: decipher_only |
| 1027 | |
| 1028 | :type: bool |
| 1029 | |
Paul Kehrer | 738407b | 2015-04-01 22:39:02 -0500 | [diff] [blame] | 1030 | When this purposes is set to true and the ``key_agreement`` purpose is |
| 1031 | also set, the subject public key may be used only for deciphering data |
| 1032 | while performing key agreement. |
Paul Kehrer | cecbbba | 2015-03-30 14:58:38 -0500 | [diff] [blame] | 1033 | |
| 1034 | :raises ValueError: This is raised if accessed when ``key_agreement`` |
| 1035 | is false. |
| 1036 | |
| 1037 | |
Paul Kehrer | 8cf2642 | 2015-03-21 09:50:24 -0500 | [diff] [blame] | 1038 | .. class:: BasicConstraints |
| 1039 | |
| 1040 | .. versionadded:: 0.9 |
| 1041 | |
Paul Kehrer | 8589466 | 2015-03-22 13:19:31 -0500 | [diff] [blame] | 1042 | 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] | 1043 | certificate is allowed to sign additional certificates and what path |
Paul Kehrer | b33de93 | 2015-08-06 23:41:05 +0100 | [diff] [blame] | 1044 | length restrictions may exist. |
Paul Kehrer | 8cf2642 | 2015-03-21 09:50:24 -0500 | [diff] [blame] | 1045 | |
Paul Kehrer | 822f3d3 | 2015-08-06 11:47:32 +0100 | [diff] [blame] | 1046 | .. attribute:: oid |
| 1047 | |
| 1048 | .. versionadded:: 1.0 |
| 1049 | |
| 1050 | :type: :class:`ObjectIdentifier` |
| 1051 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1052 | Returns :attr:`~cryptography.x509.oid.ExtensionOID.BASIC_CONSTRAINTS`. |
Paul Kehrer | 822f3d3 | 2015-08-06 11:47:32 +0100 | [diff] [blame] | 1053 | |
Paul Kehrer | 8cf2642 | 2015-03-21 09:50:24 -0500 | [diff] [blame] | 1054 | .. attribute:: ca |
| 1055 | |
| 1056 | :type: bool |
| 1057 | |
| 1058 | Whether the certificate can sign certificates. |
| 1059 | |
| 1060 | .. attribute:: path_length |
| 1061 | |
Paul Kehrer | fd1444c | 2015-03-21 19:47:05 -0500 | [diff] [blame] | 1062 | :type: int or None |
Paul Kehrer | 8cf2642 | 2015-03-21 09:50:24 -0500 | [diff] [blame] | 1063 | |
| 1064 | The maximum path length for certificates subordinate to this |
| 1065 | certificate. This attribute only has meaning if ``ca`` is true. |
| 1066 | If ``ca`` is true then a path length of None means there's no |
| 1067 | restriction on the number of subordinate CAs in the certificate chain. |
Alex Gaynor | 99c5f15 | 2015-05-03 10:01:04 -0400 | [diff] [blame] | 1068 | If it is zero or greater then it defines the maximum length for a |
| 1069 | subordinate CA's certificate chain. For example, a ``path_length`` of 1 |
| 1070 | means the certificate can sign a subordinate CA, but the subordinate CA |
| 1071 | is not allowed to create subordinates with ``ca`` set to true. |
Paul Kehrer | 8cf2642 | 2015-03-21 09:50:24 -0500 | [diff] [blame] | 1072 | |
Paul Kehrer | ffa2a15 | 2015-03-31 08:18:25 -0500 | [diff] [blame] | 1073 | .. class:: ExtendedKeyUsage |
| 1074 | |
| 1075 | .. versionadded:: 0.9 |
| 1076 | |
| 1077 | This extension indicates one or more purposes for which the certified |
| 1078 | public key may be used, in addition to or in place of the basic |
| 1079 | purposes indicated in the key usage extension. The object is |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1080 | iterable to obtain the list of |
| 1081 | :class:`~cryptography.x509.oid.ExtendedKeyUsageOID` OIDs present. |
Paul Kehrer | ffa2a15 | 2015-03-31 08:18:25 -0500 | [diff] [blame] | 1082 | |
Paul Kehrer | 822f3d3 | 2015-08-06 11:47:32 +0100 | [diff] [blame] | 1083 | .. attribute:: oid |
| 1084 | |
| 1085 | .. versionadded:: 1.0 |
| 1086 | |
| 1087 | :type: :class:`ObjectIdentifier` |
| 1088 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1089 | Returns :attr:`~cryptography.x509.oid.ExtensionOID.EXTENDED_KEY_USAGE`. |
Paul Kehrer | 822f3d3 | 2015-08-06 11:47:32 +0100 | [diff] [blame] | 1090 | |
| 1091 | |
Paul Kehrer | 4a1038e | 2015-05-18 10:28:31 -0700 | [diff] [blame] | 1092 | .. class:: OCSPNoCheck |
| 1093 | |
Paul Kehrer | 506a215 | 2015-05-26 08:01:18 -0500 | [diff] [blame] | 1094 | .. versionadded:: 1.0 |
Paul Kehrer | 4a1038e | 2015-05-18 10:28:31 -0700 | [diff] [blame] | 1095 | |
| 1096 | This presence of this extension indicates that an OCSP client can trust a |
| 1097 | responder for the lifetime of the responder's certificate. CAs issuing |
| 1098 | such a certificate should realize that a compromise of the responder's key |
| 1099 | is as serious as the compromise of a CA key used to sign CRLs, at least for |
| 1100 | the validity period of this certificate. CA's may choose to issue this type |
| 1101 | of certificate with a very short lifetime and renew it frequently. This |
| 1102 | extension is only relevant when the certificate is an authorized OCSP |
| 1103 | responder. |
| 1104 | |
Paul Kehrer | 822f3d3 | 2015-08-06 11:47:32 +0100 | [diff] [blame] | 1105 | .. attribute:: oid |
| 1106 | |
| 1107 | .. versionadded:: 1.0 |
| 1108 | |
| 1109 | :type: :class:`ObjectIdentifier` |
| 1110 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1111 | Returns :attr:`~cryptography.x509.oid.ExtensionOID.OCSP_NO_CHECK`. |
Paul Kehrer | 822f3d3 | 2015-08-06 11:47:32 +0100 | [diff] [blame] | 1112 | |
Paul Kehrer | e0017be | 2015-05-17 20:39:40 -0600 | [diff] [blame] | 1113 | .. class:: NameConstraints |
| 1114 | |
| 1115 | .. versionadded:: 1.0 |
| 1116 | |
| 1117 | The name constraints extension, which only has meaning in a CA certificate, |
| 1118 | defines a name space within which all subject names in certificates issued |
| 1119 | beneath the CA certificate must (or must not) be in. For specific details |
| 1120 | on the way this extension should be processed see :rfc:`5280`. |
| 1121 | |
Paul Kehrer | 822f3d3 | 2015-08-06 11:47:32 +0100 | [diff] [blame] | 1122 | .. attribute:: oid |
| 1123 | |
| 1124 | .. versionadded:: 1.0 |
| 1125 | |
| 1126 | :type: :class:`ObjectIdentifier` |
| 1127 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1128 | Returns :attr:`~cryptography.x509.oid.ExtensionOID.NAME_CONSTRAINTS`. |
Paul Kehrer | 822f3d3 | 2015-08-06 11:47:32 +0100 | [diff] [blame] | 1129 | |
Paul Kehrer | e0017be | 2015-05-17 20:39:40 -0600 | [diff] [blame] | 1130 | .. attribute:: permitted_subtrees |
| 1131 | |
| 1132 | :type: list of :class:`GeneralName` objects or None |
| 1133 | |
| 1134 | The set of permitted name patterns. If a name matches this and an |
| 1135 | element in ``excluded_subtrees`` it is invalid. At least one of |
| 1136 | ``permitted_subtrees`` and ``excluded_subtrees`` will be non-None. |
| 1137 | |
| 1138 | .. attribute:: excluded_subtrees |
| 1139 | |
| 1140 | :type: list of :class:`GeneralName` objects or None |
| 1141 | |
| 1142 | Any name matching a restriction in the ``excluded_subtrees`` field is |
| 1143 | invalid regardless of information appearing in the |
| 1144 | ``permitted_subtrees``. At least one of ``permitted_subtrees`` and |
| 1145 | ``excluded_subtrees`` will be non-None. |
| 1146 | |
Paul Kehrer | 2eb4ed9 | 2015-04-11 15:33:45 -0400 | [diff] [blame] | 1147 | .. class:: AuthorityKeyIdentifier |
| 1148 | |
| 1149 | .. versionadded:: 0.9 |
| 1150 | |
| 1151 | The authority key identifier extension provides a means of identifying the |
| 1152 | public key corresponding to the private key used to sign a certificate. |
Paul Kehrer | 8c8cd72 | 2015-04-19 09:15:04 -0500 | [diff] [blame] | 1153 | This extension is typically used to assist in determining the appropriate |
| 1154 | certificate chain. For more information about generation and use of this |
| 1155 | extension see `RFC 5280 section 4.2.1.1`_. |
Paul Kehrer | 2eb4ed9 | 2015-04-11 15:33:45 -0400 | [diff] [blame] | 1156 | |
Paul Kehrer | 822f3d3 | 2015-08-06 11:47:32 +0100 | [diff] [blame] | 1157 | .. attribute:: oid |
| 1158 | |
| 1159 | .. versionadded:: 1.0 |
| 1160 | |
| 1161 | :type: :class:`ObjectIdentifier` |
| 1162 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1163 | Returns |
| 1164 | :attr:`~cryptography.x509.oid.ExtensionOID.AUTHORITY_KEY_IDENTIFIER`. |
Paul Kehrer | 822f3d3 | 2015-08-06 11:47:32 +0100 | [diff] [blame] | 1165 | |
Paul Kehrer | 2eb4ed9 | 2015-04-11 15:33:45 -0400 | [diff] [blame] | 1166 | .. attribute:: key_identifier |
| 1167 | |
| 1168 | :type: bytes |
| 1169 | |
Paul Kehrer | 9104b1d | 2015-04-18 09:23:44 -0500 | [diff] [blame] | 1170 | 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] | 1171 | signature. |
Paul Kehrer | 9104b1d | 2015-04-18 09:23:44 -0500 | [diff] [blame] | 1172 | |
Paul Kehrer | 2eb4ed9 | 2015-04-11 15:33:45 -0400 | [diff] [blame] | 1173 | .. attribute:: authority_cert_issuer |
| 1174 | |
| 1175 | :type: :class:`Name` or None |
| 1176 | |
Paul Kehrer | 9104b1d | 2015-04-18 09:23:44 -0500 | [diff] [blame] | 1177 | The :class:`Name` of the issuer's issuer. |
| 1178 | |
Paul Kehrer | 2eb4ed9 | 2015-04-11 15:33:45 -0400 | [diff] [blame] | 1179 | .. attribute:: authority_cert_serial_number |
| 1180 | |
| 1181 | :type: int or None |
| 1182 | |
Paul Kehrer | 9104b1d | 2015-04-18 09:23:44 -0500 | [diff] [blame] | 1183 | The serial number of the issuer's issuer. |
| 1184 | |
Paul Kehrer | 253929a | 2015-08-05 17:30:39 +0100 | [diff] [blame] | 1185 | .. classmethod:: from_issuer_public_key(public_key) |
| 1186 | |
| 1187 | .. versionadded:: 1.0 |
| 1188 | |
| 1189 | Creates a new AuthorityKeyIdentifier instance using the public key |
| 1190 | provided to generate the appropriate digest. This should be the |
Paul Kehrer | 26ac47f | 2015-08-08 15:20:52 -0500 | [diff] [blame] | 1191 | **issuer's public key**. The resulting object will contain |
| 1192 | :attr:`~cryptography.x509.AuthorityKeyIdentifier.key_identifier`, but |
| 1193 | :attr:`~cryptography.x509.AuthorityKeyIdentifier.authority_cert_issuer` |
| 1194 | and |
| 1195 | :attr:`~cryptography.x509.AuthorityKeyIdentifier.authority_cert_serial_number` |
| 1196 | will be None. |
| 1197 | The generated ``key_identifier`` is the SHA1 hash of the ``subjectPublicKey`` |
| 1198 | ASN.1 bit string. This is the first recommendation in :rfc:`5280` |
Paul Kehrer | 253929a | 2015-08-05 17:30:39 +0100 | [diff] [blame] | 1199 | section 4.2.1.2. |
| 1200 | |
Paul Kehrer | cc67182 | 2015-08-08 15:41:54 -0500 | [diff] [blame] | 1201 | :param public_key: One of |
| 1202 | :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey` |
| 1203 | , |
| 1204 | :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPublicKey` |
| 1205 | , or |
| 1206 | :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey`. |
Paul Kehrer | 253929a | 2015-08-05 17:30:39 +0100 | [diff] [blame] | 1207 | |
| 1208 | .. doctest:: |
| 1209 | |
| 1210 | >>> from cryptography import x509 |
| 1211 | >>> from cryptography.hazmat.backends import default_backend |
Paul Kehrer | cc67182 | 2015-08-08 15:41:54 -0500 | [diff] [blame] | 1212 | >>> issuer_cert = x509.load_pem_x509_certificate(pem_data, default_backend()) |
| 1213 | >>> x509.AuthorityKeyIdentifier.from_issuer_public_key(issuer_cert.public_key()) |
Paul Kehrer | 253929a | 2015-08-05 17:30:39 +0100 | [diff] [blame] | 1214 | <AuthorityKeyIdentifier(key_identifier='X\x01\x84$\x1b\xbc+R\x94J=\xa5\x10r\x14Q\xf5\xaf:\xc9', authority_cert_issuer=None, authority_cert_serial_number=None)> |
| 1215 | |
Paul Kehrer | 1eb82a6 | 2015-03-31 20:00:33 -0500 | [diff] [blame] | 1216 | .. class:: SubjectKeyIdentifier |
| 1217 | |
| 1218 | .. versionadded:: 0.9 |
| 1219 | |
| 1220 | The subject key identifier extension provides a means of identifying |
| 1221 | certificates that contain a particular public key. |
| 1222 | |
Paul Kehrer | 822f3d3 | 2015-08-06 11:47:32 +0100 | [diff] [blame] | 1223 | .. attribute:: oid |
| 1224 | |
| 1225 | .. versionadded:: 1.0 |
| 1226 | |
| 1227 | :type: :class:`ObjectIdentifier` |
| 1228 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1229 | Returns |
| 1230 | :attr:`~cryptography.x509.oid.ExtensionOID.SUBJECT_KEY_IDENTIFIER`. |
Paul Kehrer | 822f3d3 | 2015-08-06 11:47:32 +0100 | [diff] [blame] | 1231 | |
Paul Kehrer | 1eb82a6 | 2015-03-31 20:00:33 -0500 | [diff] [blame] | 1232 | .. attribute:: digest |
| 1233 | |
| 1234 | :type: bytes |
| 1235 | |
| 1236 | The binary value of the identifier. |
| 1237 | |
Paul Kehrer | d4a7f06 | 2015-08-05 18:32:18 +0100 | [diff] [blame] | 1238 | .. classmethod:: from_public_key(public_key) |
Paul Kehrer | f22f612 | 2015-08-05 12:57:13 +0100 | [diff] [blame] | 1239 | |
| 1240 | .. versionadded:: 1.0 |
| 1241 | |
| 1242 | Creates a new SubjectKeyIdentifier instance using the public key |
| 1243 | provided to generate the appropriate digest. This should be the public |
Paul Kehrer | eb9ec00 | 2015-08-08 10:03:02 -0500 | [diff] [blame] | 1244 | key that is in the certificate. The generated digest is the SHA1 hash |
| 1245 | of the ``subjectPublicKey`` ASN.1 bit string. This is the first |
| 1246 | recommendation in :rfc:`5280` section 4.2.1.2. |
Paul Kehrer | f22f612 | 2015-08-05 12:57:13 +0100 | [diff] [blame] | 1247 | |
| 1248 | :param public_key: One of |
| 1249 | :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey` |
| 1250 | , |
| 1251 | :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPublicKey` |
| 1252 | , or |
| 1253 | :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey`. |
| 1254 | |
Paul Kehrer | 253929a | 2015-08-05 17:30:39 +0100 | [diff] [blame] | 1255 | .. doctest:: |
| 1256 | |
| 1257 | >>> from cryptography import x509 |
| 1258 | >>> from cryptography.hazmat.backends import default_backend |
Paul Kehrer | cc67182 | 2015-08-08 15:41:54 -0500 | [diff] [blame] | 1259 | >>> csr = x509.load_pem_x509_csr(pem_req_data, default_backend()) |
| 1260 | >>> x509.SubjectKeyIdentifier.from_public_key(csr.public_key()) |
| 1261 | <SubjectKeyIdentifier(digest='\xdb\xaa\xf0\x06\x11\xdbD\xfe\xbf\x93\x03\x8av\x88WP7\xa6\x91\xf7')> |
Paul Kehrer | 253929a | 2015-08-05 17:30:39 +0100 | [diff] [blame] | 1262 | |
Paul Kehrer | 31bdf79 | 2015-03-25 14:11:00 -0500 | [diff] [blame] | 1263 | .. class:: SubjectAlternativeName |
| 1264 | |
| 1265 | .. versionadded:: 0.9 |
| 1266 | |
| 1267 | Subject alternative name is an X.509 extension that provides a list of |
| 1268 | :ref:`general name <general_name_classes>` instances that provide a set |
| 1269 | of identities for which the certificate is valid. The object is iterable to |
| 1270 | get every element. |
| 1271 | |
Paul Kehrer | 822f3d3 | 2015-08-06 11:47:32 +0100 | [diff] [blame] | 1272 | .. attribute:: oid |
| 1273 | |
| 1274 | .. versionadded:: 1.0 |
| 1275 | |
| 1276 | :type: :class:`ObjectIdentifier` |
| 1277 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1278 | Returns |
| 1279 | :attr:`~cryptography.x509.oid.ExtensionOID.SUBJECT_ALTERNATIVE_NAME`. |
Paul Kehrer | 822f3d3 | 2015-08-06 11:47:32 +0100 | [diff] [blame] | 1280 | |
Paul Kehrer | 31bdf79 | 2015-03-25 14:11:00 -0500 | [diff] [blame] | 1281 | .. method:: get_values_for_type(type) |
| 1282 | |
| 1283 | :param type: A :class:`GeneralName` provider. This is one of the |
| 1284 | :ref:`general name classes <general_name_classes>`. |
| 1285 | |
| 1286 | :returns: A list of values extracted from the matched general names. |
Joshua Tauberer | d2afad3 | 2015-07-06 22:37:53 +0000 | [diff] [blame] | 1287 | The type of the returned values depends on the :class:`GeneralName`. |
Paul Kehrer | 31bdf79 | 2015-03-25 14:11:00 -0500 | [diff] [blame] | 1288 | |
Paul Kehrer | 93ae805 | 2015-05-02 23:18:09 -0500 | [diff] [blame] | 1289 | .. doctest:: |
| 1290 | |
| 1291 | >>> from cryptography import x509 |
| 1292 | >>> from cryptography.hazmat.backends import default_backend |
| 1293 | >>> from cryptography.hazmat.primitives import hashes |
| 1294 | >>> cert = x509.load_pem_x509_certificate(cryptography_cert_pem, default_backend()) |
Paul Kehrer | d0cd507 | 2015-05-02 23:27:00 -0500 | [diff] [blame] | 1295 | >>> # Get the subjectAltName extension from the certificate |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1296 | >>> ext = cert.extensions.get_extension_for_oid(ExtensionOID.SUBJECT_ALTERNATIVE_NAME) |
Paul Kehrer | d0cd507 | 2015-05-02 23:27:00 -0500 | [diff] [blame] | 1297 | >>> # Get the dNSName entries from the SAN extension |
| 1298 | >>> ext.value.get_values_for_type(x509.DNSName) |
Paul Kehrer | 93ae805 | 2015-05-02 23:18:09 -0500 | [diff] [blame] | 1299 | [u'www.cryptography.io', u'cryptography.io'] |
| 1300 | |
Paul Kehrer | 8cf2642 | 2015-03-21 09:50:24 -0500 | [diff] [blame] | 1301 | |
Paul Kehrer | 99125c9 | 2015-06-07 18:37:10 -0500 | [diff] [blame] | 1302 | .. class:: IssuerAlternativeName |
| 1303 | |
| 1304 | .. versionadded:: 1.0 |
| 1305 | |
| 1306 | Issuer alternative name is an X.509 extension that provides a list of |
| 1307 | :ref:`general name <general_name_classes>` instances that provide a set |
| 1308 | of identities for the certificate issuer. The object is iterable to |
| 1309 | get every element. |
| 1310 | |
Paul Kehrer | 822f3d3 | 2015-08-06 11:47:32 +0100 | [diff] [blame] | 1311 | .. attribute:: oid |
| 1312 | |
| 1313 | .. versionadded:: 1.0 |
| 1314 | |
| 1315 | :type: :class:`ObjectIdentifier` |
| 1316 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1317 | Returns |
| 1318 | :attr:`~cryptography.x509.oid.ExtensionOID.ISSUER_ALTERNATIVE_NAME`. |
Paul Kehrer | 822f3d3 | 2015-08-06 11:47:32 +0100 | [diff] [blame] | 1319 | |
Paul Kehrer | 99125c9 | 2015-06-07 18:37:10 -0500 | [diff] [blame] | 1320 | .. method:: get_values_for_type(type) |
| 1321 | |
| 1322 | :param type: A :class:`GeneralName` provider. This is one of the |
| 1323 | :ref:`general name classes <general_name_classes>`. |
| 1324 | |
| 1325 | :returns: A list of values extracted from the matched general names. |
| 1326 | |
| 1327 | |
Paul Kehrer | 3e6d558 | 2015-05-02 21:57:56 -0500 | [diff] [blame] | 1328 | .. class:: AuthorityInformationAccess |
| 1329 | |
| 1330 | .. versionadded:: 0.9 |
| 1331 | |
| 1332 | The authority information access extension indicates how to access |
| 1333 | information and services for the issuer of the certificate in which |
| 1334 | the extension appears. Information and services may include online |
| 1335 | validation services (such as OCSP) and issuer data. It is an iterable, |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1336 | containing one or more :class:`~cryptography.x509.AccessDescription` |
| 1337 | instances. |
Paul Kehrer | 3e6d558 | 2015-05-02 21:57:56 -0500 | [diff] [blame] | 1338 | |
Paul Kehrer | 822f3d3 | 2015-08-06 11:47:32 +0100 | [diff] [blame] | 1339 | .. attribute:: oid |
| 1340 | |
| 1341 | .. versionadded:: 1.0 |
| 1342 | |
| 1343 | :type: :class:`ObjectIdentifier` |
| 1344 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1345 | Returns |
| 1346 | :attr:`~cryptography.x509.oid.ExtensionOID.AUTHORITY_INFORMATION_ACCESS`. |
Paul Kehrer | 822f3d3 | 2015-08-06 11:47:32 +0100 | [diff] [blame] | 1347 | |
Paul Kehrer | 3e6d558 | 2015-05-02 21:57:56 -0500 | [diff] [blame] | 1348 | |
| 1349 | .. class:: AccessDescription |
| 1350 | |
Paul Kehrer | 5a48552 | 2015-05-06 00:29:12 -0500 | [diff] [blame] | 1351 | .. versionadded:: 0.9 |
| 1352 | |
Paul Kehrer | 3e6d558 | 2015-05-02 21:57:56 -0500 | [diff] [blame] | 1353 | .. attribute:: access_method |
| 1354 | |
| 1355 | :type: :class:`ObjectIdentifier` |
| 1356 | |
Paul Kehrer | f506bca | 2015-05-02 22:31:47 -0500 | [diff] [blame] | 1357 | The access method defines what the ``access_location`` means. It must |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1358 | be either |
| 1359 | :attr:`~cryptography.x509.oid.AuthorityInformationAccessOID.OCSP` or |
| 1360 | :attr:`~cryptography.x509.oid.AuthorityInformationAccessOID.CA_ISSUERS`. |
| 1361 | If it is |
| 1362 | :attr:`~cryptography.x509.oid.AuthorityInformationAccessOID.OCSP` |
| 1363 | the access location will be where to obtain OCSP |
| 1364 | information for the certificate. If it is |
| 1365 | :attr:`~cryptography.x509.oid.AuthorityInformationAccessOID.CA_ISSUERS` |
| 1366 | the access location will provide additional information about the |
| 1367 | issuing certificate. |
Paul Kehrer | 3e6d558 | 2015-05-02 21:57:56 -0500 | [diff] [blame] | 1368 | |
| 1369 | .. attribute:: access_location |
| 1370 | |
| 1371 | :type: :class:`GeneralName` |
| 1372 | |
Paul Kehrer | f506bca | 2015-05-02 22:31:47 -0500 | [diff] [blame] | 1373 | Where to access the information defined by the access method. |
| 1374 | |
Paul Kehrer | 5a48552 | 2015-05-06 00:29:12 -0500 | [diff] [blame] | 1375 | .. class:: CRLDistributionPoints |
| 1376 | |
| 1377 | .. versionadded:: 0.9 |
| 1378 | |
| 1379 | The CRL distribution points extension identifies how CRL information is |
| 1380 | obtained. It is an iterable, containing one or more |
| 1381 | :class:`DistributionPoint` instances. |
| 1382 | |
Paul Kehrer | 822f3d3 | 2015-08-06 11:47:32 +0100 | [diff] [blame] | 1383 | .. attribute:: oid |
| 1384 | |
| 1385 | .. versionadded:: 1.0 |
| 1386 | |
| 1387 | :type: :class:`ObjectIdentifier` |
| 1388 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1389 | Returns |
| 1390 | :attr:`~cryptography.x509.oid.ExtensionOID.CRL_DISTRIBUTION_POINTS`. |
Paul Kehrer | 822f3d3 | 2015-08-06 11:47:32 +0100 | [diff] [blame] | 1391 | |
Paul Kehrer | 5a48552 | 2015-05-06 00:29:12 -0500 | [diff] [blame] | 1392 | .. class:: DistributionPoint |
| 1393 | |
| 1394 | .. versionadded:: 0.9 |
| 1395 | |
Paul Kehrer | 4e8dacd | 2015-05-09 10:38:23 -0500 | [diff] [blame] | 1396 | .. attribute:: full_name |
Paul Kehrer | 5a48552 | 2015-05-06 00:29:12 -0500 | [diff] [blame] | 1397 | |
Paul Kehrer | 4e8dacd | 2015-05-09 10:38:23 -0500 | [diff] [blame] | 1398 | :type: list of :class:`GeneralName` instances or None |
Paul Kehrer | 5a48552 | 2015-05-06 00:29:12 -0500 | [diff] [blame] | 1399 | |
Paul Kehrer | f2c072b | 2015-05-09 17:04:28 -0500 | [diff] [blame] | 1400 | This field describes methods to retrieve the CRL. At most one of |
| 1401 | ``full_name`` or ``relative_name`` will be non-None. |
Paul Kehrer | 4e8dacd | 2015-05-09 10:38:23 -0500 | [diff] [blame] | 1402 | |
| 1403 | .. attribute:: relative_name |
| 1404 | |
| 1405 | :type: :class:`Name` or None |
| 1406 | |
| 1407 | This field describes methods to retrieve the CRL relative to the CRL |
Paul Kehrer | f2c072b | 2015-05-09 17:04:28 -0500 | [diff] [blame] | 1408 | issuer. At most one of ``full_name`` or ``relative_name`` will be |
| 1409 | non-None. |
Paul Kehrer | 5a48552 | 2015-05-06 00:29:12 -0500 | [diff] [blame] | 1410 | |
| 1411 | .. attribute:: crl_issuer |
| 1412 | |
| 1413 | :type: list of :class:`GeneralName` instances or None |
| 1414 | |
| 1415 | Information about the issuer of the CRL. |
| 1416 | |
| 1417 | .. attribute:: reasons |
| 1418 | |
Paul Kehrer | 3fd0260 | 2015-05-09 19:46:13 -0500 | [diff] [blame] | 1419 | :type: frozenset of :class:`ReasonFlags` or None |
Paul Kehrer | 5a48552 | 2015-05-06 00:29:12 -0500 | [diff] [blame] | 1420 | |
| 1421 | The reasons a given distribution point may be used for when performing |
| 1422 | revocation checks. |
| 1423 | |
| 1424 | .. class:: ReasonFlags |
| 1425 | |
| 1426 | .. versionadded:: 0.9 |
| 1427 | |
Paul Kehrer | 4e8dacd | 2015-05-09 10:38:23 -0500 | [diff] [blame] | 1428 | An enumeration for CRL reasons. |
| 1429 | |
| 1430 | .. attribute:: unspecified |
| 1431 | |
| 1432 | It is unspecified why the certificate was revoked. This reason cannot |
| 1433 | be used as a reason flag in a :class:`DistributionPoint`. |
Paul Kehrer | 5a48552 | 2015-05-06 00:29:12 -0500 | [diff] [blame] | 1434 | |
| 1435 | .. attribute:: key_compromise |
| 1436 | |
Paul Kehrer | 4e8dacd | 2015-05-09 10:38:23 -0500 | [diff] [blame] | 1437 | This reason indicates that the private key was compromised. |
Paul Kehrer | 5a48552 | 2015-05-06 00:29:12 -0500 | [diff] [blame] | 1438 | |
| 1439 | .. attribute:: ca_compromise |
| 1440 | |
Paul Kehrer | 4e8dacd | 2015-05-09 10:38:23 -0500 | [diff] [blame] | 1441 | This reason indicates that the CA issuing the certificate was |
| 1442 | compromised. |
Paul Kehrer | 5a48552 | 2015-05-06 00:29:12 -0500 | [diff] [blame] | 1443 | |
| 1444 | .. attribute:: affiliation_changed |
| 1445 | |
Paul Kehrer | 4e8dacd | 2015-05-09 10:38:23 -0500 | [diff] [blame] | 1446 | This reason indicates that the subject's name or other information has |
| 1447 | changed. |
Paul Kehrer | 5a48552 | 2015-05-06 00:29:12 -0500 | [diff] [blame] | 1448 | |
| 1449 | .. attribute:: superseded |
| 1450 | |
Paul Kehrer | 4e8dacd | 2015-05-09 10:38:23 -0500 | [diff] [blame] | 1451 | This reason indicates that a certificate has been superseded. |
Paul Kehrer | 5a48552 | 2015-05-06 00:29:12 -0500 | [diff] [blame] | 1452 | |
| 1453 | .. attribute:: cessation_of_operation |
| 1454 | |
Paul Kehrer | 4e8dacd | 2015-05-09 10:38:23 -0500 | [diff] [blame] | 1455 | This reason indicates that the certificate is no longer required. |
Paul Kehrer | 5a48552 | 2015-05-06 00:29:12 -0500 | [diff] [blame] | 1456 | |
| 1457 | .. attribute:: certificate_hold |
| 1458 | |
Paul Kehrer | 4e8dacd | 2015-05-09 10:38:23 -0500 | [diff] [blame] | 1459 | This reason indicates that the certificate is on hold. |
Paul Kehrer | 5a48552 | 2015-05-06 00:29:12 -0500 | [diff] [blame] | 1460 | |
| 1461 | .. attribute:: privilege_withdrawn |
| 1462 | |
Paul Kehrer | 4e8dacd | 2015-05-09 10:38:23 -0500 | [diff] [blame] | 1463 | This reason indicates that the privilege granted by this certificate |
| 1464 | have been withdrawn. |
Paul Kehrer | 5a48552 | 2015-05-06 00:29:12 -0500 | [diff] [blame] | 1465 | |
| 1466 | .. attribute:: aa_compromise |
| 1467 | |
Paul Kehrer | 4e8dacd | 2015-05-09 10:38:23 -0500 | [diff] [blame] | 1468 | When an attribute authority has been compromised. |
| 1469 | |
| 1470 | .. attribute:: remove_from_crl |
| 1471 | |
| 1472 | This reason indicates that the certificate was on hold and should be |
| 1473 | removed from the CRL. This reason cannot be used as a reason flag |
| 1474 | in a :class:`DistributionPoint`. |
Paul Kehrer | 5a48552 | 2015-05-06 00:29:12 -0500 | [diff] [blame] | 1475 | |
Paul Kehrer | 16fae76 | 2015-05-01 23:14:20 -0500 | [diff] [blame] | 1476 | .. class:: InhibitAnyPolicy |
| 1477 | |
| 1478 | .. versionadded:: 1.0 |
| 1479 | |
| 1480 | The inhibit ``anyPolicy`` extension indicates that the special OID |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1481 | :attr:`~cryptography.x509.oid.CertificatePoliciesOID.ANY_POLICY`, is not |
| 1482 | considered an explicit match for other :class:`CertificatePolicies` except |
| 1483 | when it appears in an intermediate self-issued CA certificate. The value |
| 1484 | indicates the number of additional non-self-issued certificates that may |
| 1485 | appear in the path before |
| 1486 | :attr:`~cryptography.x509.oid.CertificatePoliciesOID.ANY_POLICY` is no |
| 1487 | longer permitted. For example, a value of one indicates that |
| 1488 | :attr:`~cryptography.x509.oid.CertificatePoliciesOID.ANY_POLICY` may be |
| 1489 | processed in certificates issued by the subject of this certificate, but |
| 1490 | not in additional certificates in the path. |
Paul Kehrer | 16fae76 | 2015-05-01 23:14:20 -0500 | [diff] [blame] | 1491 | |
Paul Kehrer | 822f3d3 | 2015-08-06 11:47:32 +0100 | [diff] [blame] | 1492 | .. attribute:: oid |
| 1493 | |
| 1494 | .. versionadded:: 1.0 |
| 1495 | |
| 1496 | :type: :class:`ObjectIdentifier` |
| 1497 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1498 | Returns |
| 1499 | :attr:`~cryptography.x509.oid.ExtensionOID.INHIBIT_ANY_POLICY`. |
Paul Kehrer | 822f3d3 | 2015-08-06 11:47:32 +0100 | [diff] [blame] | 1500 | |
Paul Kehrer | 16fae76 | 2015-05-01 23:14:20 -0500 | [diff] [blame] | 1501 | .. attribute:: skip_certs |
| 1502 | |
| 1503 | :type: int |
| 1504 | |
Paul Kehrer | 0d21092 | 2015-04-28 17:31:07 -0500 | [diff] [blame] | 1505 | .. class:: CertificatePolicies |
| 1506 | |
| 1507 | .. versionadded:: 0.9 |
| 1508 | |
Paul Kehrer | 2e87974 | 2015-05-02 23:09:56 -0500 | [diff] [blame] | 1509 | The certificate policies extension is an iterable, containing one or more |
| 1510 | :class:`PolicyInformation` instances. |
Paul Kehrer | 0d21092 | 2015-04-28 17:31:07 -0500 | [diff] [blame] | 1511 | |
Paul Kehrer | 822f3d3 | 2015-08-06 11:47:32 +0100 | [diff] [blame] | 1512 | .. attribute:: oid |
| 1513 | |
| 1514 | .. versionadded:: 1.0 |
| 1515 | |
| 1516 | :type: :class:`ObjectIdentifier` |
| 1517 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1518 | Returns |
| 1519 | :attr:`~cryptography.x509.oid.ExtensionOID.CERTIFICATE_POLICIES`. |
Paul Kehrer | 822f3d3 | 2015-08-06 11:47:32 +0100 | [diff] [blame] | 1520 | |
Paul Kehrer | 0d21092 | 2015-04-28 17:31:07 -0500 | [diff] [blame] | 1521 | Certificate Policies Classes |
| 1522 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 1523 | |
| 1524 | These classes may be present within a :class:`CertificatePolicies` instance. |
| 1525 | |
| 1526 | .. class:: PolicyInformation |
| 1527 | |
| 1528 | .. versionadded:: 0.9 |
| 1529 | |
| 1530 | Contains a policy identifier and an optional list of qualifiers. |
| 1531 | |
| 1532 | .. attribute:: policy_identifier |
| 1533 | |
| 1534 | :type: :class:`ObjectIdentifier` |
| 1535 | |
| 1536 | .. attribute:: policy_qualifiers |
| 1537 | |
| 1538 | :type: list |
| 1539 | |
Paul Kehrer | ba35b3b | 2015-05-10 13:07:59 -0500 | [diff] [blame] | 1540 | A list consisting of :term:`text` and/or :class:`UserNotice` objects. |
Paul Kehrer | 3f8ddeb | 2015-05-11 00:25:36 -0500 | [diff] [blame] | 1541 | If the value is text it is a pointer to the practice statement |
| 1542 | published by the certificate authority. If it is a user notice it is |
| 1543 | meant for display to the relying party when the certificate is |
| 1544 | used. |
Paul Kehrer | 2e87974 | 2015-05-02 23:09:56 -0500 | [diff] [blame] | 1545 | |
Paul Kehrer | 0d21092 | 2015-04-28 17:31:07 -0500 | [diff] [blame] | 1546 | .. class:: UserNotice |
| 1547 | |
| 1548 | .. versionadded:: 0.9 |
| 1549 | |
Paul Kehrer | 2e87974 | 2015-05-02 23:09:56 -0500 | [diff] [blame] | 1550 | User notices are intended for display to a relying party when a certificate |
| 1551 | is used. In practice, few if any UIs expose this data and it is a rarely |
| 1552 | encoded component. |
| 1553 | |
Paul Kehrer | 0d21092 | 2015-04-28 17:31:07 -0500 | [diff] [blame] | 1554 | .. attribute:: notice_reference |
| 1555 | |
| 1556 | :type: :class:`NoticeReference` or None |
| 1557 | |
Paul Kehrer | 2e87974 | 2015-05-02 23:09:56 -0500 | [diff] [blame] | 1558 | The notice reference field names an organization and identifies, |
| 1559 | by number, a particular statement prepared by that organization. |
| 1560 | |
Paul Kehrer | 0d21092 | 2015-04-28 17:31:07 -0500 | [diff] [blame] | 1561 | .. attribute:: explicit_text |
| 1562 | |
Paul Kehrer | 2e87974 | 2015-05-02 23:09:56 -0500 | [diff] [blame] | 1563 | This field includes an arbitrary textual statement directly in the |
| 1564 | certificate. |
| 1565 | |
Paul Kehrer | 0d21092 | 2015-04-28 17:31:07 -0500 | [diff] [blame] | 1566 | :type: :term:`text` |
| 1567 | |
| 1568 | .. class:: NoticeReference |
| 1569 | |
Paul Kehrer | 2e87974 | 2015-05-02 23:09:56 -0500 | [diff] [blame] | 1570 | Notice reference can name an organization and provide information about |
| 1571 | notices related to the certificate. For example, it might identify the |
| 1572 | organization name and notice number 1. Application software could |
| 1573 | have a notice file containing the current set of notices for the named |
| 1574 | organization; the application would then extract the notice text from the |
| 1575 | file and display it. In practice this is rarely seen. |
| 1576 | |
Paul Kehrer | 0d21092 | 2015-04-28 17:31:07 -0500 | [diff] [blame] | 1577 | .. versionadded:: 0.9 |
| 1578 | |
| 1579 | .. attribute:: organization |
| 1580 | |
Paul Kehrer | 66c6170 | 2015-05-12 16:39:18 -0500 | [diff] [blame] | 1581 | :type: :term:`text` |
Paul Kehrer | 0d21092 | 2015-04-28 17:31:07 -0500 | [diff] [blame] | 1582 | |
Paul Kehrer | 3f8ddeb | 2015-05-11 00:25:36 -0500 | [diff] [blame] | 1583 | .. attribute:: notice_numbers |
Paul Kehrer | 0d21092 | 2015-04-28 17:31:07 -0500 | [diff] [blame] | 1584 | |
Paul Kehrer | 66c6170 | 2015-05-12 16:39:18 -0500 | [diff] [blame] | 1585 | :type: list |
Paul Kehrer | 0d21092 | 2015-04-28 17:31:07 -0500 | [diff] [blame] | 1586 | |
Paul Kehrer | 66c6170 | 2015-05-12 16:39:18 -0500 | [diff] [blame] | 1587 | A list of integers. |
Paul Kehrer | 0d21092 | 2015-04-28 17:31:07 -0500 | [diff] [blame] | 1588 | |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 1589 | Object Identifiers |
| 1590 | ~~~~~~~~~~~~~~~~~~ |
| 1591 | |
Paul Kehrer | 4bb4649 | 2015-02-07 16:59:14 -0600 | [diff] [blame] | 1592 | X.509 elements are frequently identified by :class:`ObjectIdentifier` |
| 1593 | instances. The following common OIDs are available as constants. |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 1594 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1595 | .. currentmodule:: cryptography.x509.oid |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 1596 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1597 | .. class:: NameOID |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 1598 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1599 | These OIDs are typically seen in X.509 names. |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 1600 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1601 | .. versionadded:: 1.0 |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 1602 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1603 | .. attribute:: COMMON_NAME |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 1604 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1605 | Corresponds to the dotted string ``"2.5.4.3"``. Historically the domain |
| 1606 | name would be encoded here for server certificates. :rfc:`2818` |
| 1607 | deprecates this practice and names of that type should now be located |
| 1608 | in a :class:`~cryptography.x509.SubjectAlternativeName` extension. |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 1609 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1610 | .. attribute:: COUNTRY_NAME |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 1611 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1612 | Corresponds to the dotted string ``"2.5.4.6"``. |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 1613 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1614 | .. attribute:: LOCALITY_NAME |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 1615 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1616 | Corresponds to the dotted string ``"2.5.4.7"``. |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 1617 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1618 | .. attribute:: STATE_OR_PROVINCE_NAME |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 1619 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1620 | Corresponds to the dotted string ``"2.5.4.8"``. |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 1621 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1622 | .. attribute:: ORGANIZATION_NAME |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 1623 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1624 | Corresponds to the dotted string ``"2.5.4.10"``. |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 1625 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1626 | .. attribute:: ORGANIZATIONAL_UNIT_NAME |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 1627 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1628 | Corresponds to the dotted string ``"2.5.4.11"``. |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 1629 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1630 | .. attribute:: SERIAL_NUMBER |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 1631 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1632 | Corresponds to the dotted string ``"2.5.4.5"``. This is distinct from |
| 1633 | the serial number of the certificate itself (which can be obtained with |
| 1634 | :func:`~cryptography.x509.Certificate.serial`). |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 1635 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1636 | .. attribute:: SURNAME |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 1637 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1638 | Corresponds to the dotted string ``"2.5.4.4"``. |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 1639 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1640 | .. attribute:: GIVEN_NAME |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 1641 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1642 | Corresponds to the dotted string ``"2.5.4.42"``. |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 1643 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1644 | .. attribute:: TITLE |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 1645 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1646 | Corresponds to the dotted string ``"2.5.4.12"``. |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 1647 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1648 | .. attribute:: GENERATION_QUALIFIER |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 1649 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1650 | Corresponds to the dotted string ``"2.5.4.44"``. |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 1651 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1652 | .. attribute:: DN_QUALIFIER |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 1653 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1654 | Corresponds to the dotted string ``"2.5.4.46"``. This specifies |
| 1655 | disambiguating information to add to the relative distinguished name of an |
| 1656 | entry. See :rfc:`2256`. |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 1657 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1658 | .. attribute:: PSEUDONYM |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 1659 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1660 | Corresponds to the dotted string ``"2.5.4.65"``. |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 1661 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1662 | .. attribute:: DOMAIN_COMPONENT |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 1663 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1664 | Corresponds to the dotted string ``"0.9.2342.19200300.100.1.25"``. A string |
| 1665 | holding one component of a domain name. See :rfc:`4519`. |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 1666 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1667 | .. attribute:: EMAIL_ADDRESS |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 1668 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1669 | Corresponds to the dotted string ``"1.2.840.113549.1.9.1"``. |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 1670 | |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 1671 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1672 | .. class:: SignatureAlgorithmOID |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 1673 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1674 | .. versionadded:: 1.0 |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 1675 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1676 | .. attribute:: RSA_WITH_MD5 |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 1677 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1678 | Corresponds to the dotted string ``"1.2.840.113549.1.1.4"``. This is |
| 1679 | an MD5 digest signed by an RSA key. |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 1680 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1681 | .. attribute:: RSA_WITH_SHA1 |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 1682 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1683 | Corresponds to the dotted string ``"1.2.840.113549.1.1.5"``. This is |
| 1684 | a SHA1 digest signed by an RSA key. |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 1685 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1686 | .. attribute:: RSA_WITH_SHA224 |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 1687 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1688 | Corresponds to the dotted string ``"1.2.840.113549.1.1.14"``. This is |
| 1689 | a SHA224 digest signed by an RSA key. |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 1690 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1691 | .. attribute:: RSA_WITH_SHA256 |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 1692 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1693 | Corresponds to the dotted string ``"1.2.840.113549.1.1.11"``. This is |
| 1694 | a SHA256 digest signed by an RSA key. |
Alex Gaynor | 3aadabf | 2015-06-23 22:06:21 -0400 | [diff] [blame] | 1695 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1696 | .. attribute:: RSA_WITH_SHA384 |
Alex Gaynor | 3aadabf | 2015-06-23 22:06:21 -0400 | [diff] [blame] | 1697 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1698 | Corresponds to the dotted string ``"1.2.840.113549.1.1.12"``. This is |
| 1699 | a SHA384 digest signed by an RSA key. |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 1700 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1701 | .. attribute:: RSA_WITH_SHA512 |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 1702 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1703 | Corresponds to the dotted string ``"1.2.840.113549.1.1.13"``. This is |
| 1704 | a SHA512 digest signed by an RSA key. |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 1705 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1706 | .. attribute:: ECDSA_WITH_SHA1 |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 1707 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1708 | Corresponds to the dotted string ``"1.2.840.10045.4.1"``. This is a SHA1 |
| 1709 | digest signed by an ECDSA key. |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 1710 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1711 | .. attribute:: ECDSA_WITH_SHA224 |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 1712 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1713 | Corresponds to the dotted string ``"1.2.840.10045.4.3.1"``. This is |
| 1714 | a SHA224 digest signed by an ECDSA key. |
| 1715 | |
| 1716 | .. attribute:: ECDSA_WITH_SHA256 |
| 1717 | |
| 1718 | Corresponds to the dotted string ``"1.2.840.10045.4.3.2"``. This is |
| 1719 | a SHA256 digest signed by an ECDSA key. |
| 1720 | |
| 1721 | .. attribute:: ECDSA_WITH_SHA384 |
| 1722 | |
| 1723 | Corresponds to the dotted string ``"1.2.840.10045.4.3.3"``. This is |
| 1724 | a SHA384 digest signed by an ECDSA key. |
| 1725 | |
| 1726 | .. attribute:: ECDSA_WITH_SHA512 |
| 1727 | |
| 1728 | Corresponds to the dotted string ``"1.2.840.10045.4.3.4"``. This is |
| 1729 | a SHA512 digest signed by an ECDSA key. |
| 1730 | |
| 1731 | .. attribute:: DSA_WITH_SHA1 |
| 1732 | |
| 1733 | Corresponds to the dotted string ``"1.2.840.10040.4.3"``. This is |
| 1734 | a SHA1 digest signed by a DSA key. |
| 1735 | |
| 1736 | .. attribute:: DSA_WITH_SHA224 |
| 1737 | |
| 1738 | Corresponds to the dotted string ``"2.16.840.1.101.3.4.3.1"``. This is |
| 1739 | a SHA224 digest signed by a DSA key. |
| 1740 | |
| 1741 | .. attribute:: DSA_WITH_SHA256 |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 1742 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1743 | Corresponds to the dotted string ``"2.16.840.1.101.3.4.3.2"``. This is |
| 1744 | a SHA256 digest signed by a DSA key. |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 1745 | |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 1746 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1747 | .. class:: ExtendedKeyUsageOID |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 1748 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1749 | .. versionadded:: 1.0 |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 1750 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1751 | .. attribute:: SERVER_AUTH |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 1752 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1753 | Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.1"``. This is used |
| 1754 | to denote that a certificate may be used for TLS web server |
| 1755 | authentication. |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 1756 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1757 | .. attribute:: CLIENT_AUTH |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 1758 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1759 | Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.2"``. This is used |
| 1760 | to denote that a certificate may be used for TLS web client |
| 1761 | authentication. |
Paul Kehrer | ffa2a15 | 2015-03-31 08:18:25 -0500 | [diff] [blame] | 1762 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1763 | .. attribute:: CODE_SIGNING |
Paul Kehrer | e1513fa | 2015-03-30 23:08:17 -0500 | [diff] [blame] | 1764 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1765 | Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.3"``. This is used |
| 1766 | to denote that a certificate may be used for code signing. |
Paul Kehrer | e1513fa | 2015-03-30 23:08:17 -0500 | [diff] [blame] | 1767 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1768 | .. attribute:: EMAIL_PROTECTION |
Paul Kehrer | e1513fa | 2015-03-30 23:08:17 -0500 | [diff] [blame] | 1769 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1770 | Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.4"``. This is used |
| 1771 | to denote that a certificate may be used for email protection. |
Paul Kehrer | e1513fa | 2015-03-30 23:08:17 -0500 | [diff] [blame] | 1772 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1773 | .. attribute:: TIME_STAMPING |
Paul Kehrer | e1513fa | 2015-03-30 23:08:17 -0500 | [diff] [blame] | 1774 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1775 | Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.8"``. This is used |
| 1776 | to denote that a certificate may be used for time stamping. |
Paul Kehrer | e1513fa | 2015-03-30 23:08:17 -0500 | [diff] [blame] | 1777 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1778 | .. attribute:: OCSP_SIGNING |
Paul Kehrer | e1513fa | 2015-03-30 23:08:17 -0500 | [diff] [blame] | 1779 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1780 | Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.9"``. This is used |
| 1781 | to denote that a certificate may be used for signing OCSP responses. |
Paul Kehrer | e1513fa | 2015-03-30 23:08:17 -0500 | [diff] [blame] | 1782 | |
Paul Kehrer | e1513fa | 2015-03-30 23:08:17 -0500 | [diff] [blame] | 1783 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1784 | .. class:: AuthorityInformationAccessOID |
Paul Kehrer | e1513fa | 2015-03-30 23:08:17 -0500 | [diff] [blame] | 1785 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1786 | .. versionadded:: 1.0 |
Paul Kehrer | e1513fa | 2015-03-30 23:08:17 -0500 | [diff] [blame] | 1787 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1788 | .. attribute:: OCSP |
Paul Kehrer | e1513fa | 2015-03-30 23:08:17 -0500 | [diff] [blame] | 1789 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1790 | Corresponds to the dotted string ``"1.3.6.1.5.5.7.48.1"``. Used as the |
| 1791 | identifier for OCSP data in |
| 1792 | :class:`~cryptography.x509.AccessDescription` objects. |
Paul Kehrer | e1513fa | 2015-03-30 23:08:17 -0500 | [diff] [blame] | 1793 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1794 | .. attribute:: CA_ISSUERS |
Paul Kehrer | 3e6d558 | 2015-05-02 21:57:56 -0500 | [diff] [blame] | 1795 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1796 | Corresponds to the dotted string ``"1.3.6.1.5.5.7.48.2"``. Used as the |
| 1797 | identifier for CA issuer data in |
| 1798 | :class:`~cryptography.x509.AccessDescription` objects. |
Paul Kehrer | 3e6d558 | 2015-05-02 21:57:56 -0500 | [diff] [blame] | 1799 | |
Paul Kehrer | 3e6d558 | 2015-05-02 21:57:56 -0500 | [diff] [blame] | 1800 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1801 | .. class:: CertificatePoliciesOID |
Paul Kehrer | 3e6d558 | 2015-05-02 21:57:56 -0500 | [diff] [blame] | 1802 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1803 | .. versionadded:: 1.0 |
Paul Kehrer | 3e6d558 | 2015-05-02 21:57:56 -0500 | [diff] [blame] | 1804 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1805 | .. attribute:: CPS_QUALIFIER |
Paul Kehrer | 2e87974 | 2015-05-02 23:09:56 -0500 | [diff] [blame] | 1806 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1807 | 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] | 1808 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1809 | .. attribute:: CPS_USER_NOTICE |
Paul Kehrer | 2e87974 | 2015-05-02 23:09:56 -0500 | [diff] [blame] | 1810 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1811 | 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] | 1812 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1813 | .. attribute:: ANY_POLICY |
Paul Kehrer | 2e87974 | 2015-05-02 23:09:56 -0500 | [diff] [blame] | 1814 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1815 | Corresponds to the dotted string ``"2.5.29.32.0"``. |
Paul Kehrer | 16fae76 | 2015-05-01 23:14:20 -0500 | [diff] [blame] | 1816 | |
Paul Kehrer | 16fae76 | 2015-05-01 23:14:20 -0500 | [diff] [blame] | 1817 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1818 | .. class:: ExtensionOID |
Paul Kehrer | 5553d57 | 2015-03-23 21:08:01 -0500 | [diff] [blame] | 1819 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1820 | .. versionadded:: 1.0 |
Paul Kehrer | 2bb9464 | 2015-03-21 09:54:17 -0500 | [diff] [blame] | 1821 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1822 | .. attribute:: BASIC_CONSTRAINTS |
Paul Kehrer | 2bb9464 | 2015-03-21 09:54:17 -0500 | [diff] [blame] | 1823 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1824 | Corresponds to the dotted string ``"2.5.29.19"``. The identifier for the |
| 1825 | :class:`~cryptography.x509.BasicConstraints` extension type. |
Paul Kehrer | 2bb9464 | 2015-03-21 09:54:17 -0500 | [diff] [blame] | 1826 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1827 | .. attribute:: KEY_USAGE |
Paul Kehrer | cecbbba | 2015-03-30 14:58:38 -0500 | [diff] [blame] | 1828 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1829 | Corresponds to the dotted string ``"2.5.29.15"``. The identifier for the |
| 1830 | :class:`~cryptography.x509.KeyUsage` extension type. |
Paul Kehrer | cecbbba | 2015-03-30 14:58:38 -0500 | [diff] [blame] | 1831 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1832 | .. attribute:: SUBJECT_ALTERNATIVE_NAME |
Paul Kehrer | d4f632e | 2015-05-12 08:25:42 -0500 | [diff] [blame] | 1833 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1834 | Corresponds to the dotted string ``"2.5.29.17"``. The identifier for the |
| 1835 | :class:`~cryptography.x509.SubjectAlternativeName` extension type. |
Paul Kehrer | d4f632e | 2015-05-12 08:25:42 -0500 | [diff] [blame] | 1836 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1837 | .. attribute:: ISSUER_ALTERNATIVE_NAME |
Paul Kehrer | 99125c9 | 2015-06-07 18:37:10 -0500 | [diff] [blame] | 1838 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1839 | Corresponds to the dotted string ``"2.5.29.18"``. The identifier for the |
| 1840 | :class:`~cryptography.x509.IssuerAlternativeName` extension type. |
Paul Kehrer | 99125c9 | 2015-06-07 18:37:10 -0500 | [diff] [blame] | 1841 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1842 | .. attribute:: SUBJECT_KEY_IDENTIFIER |
Paul Kehrer | d4f632e | 2015-05-12 08:25:42 -0500 | [diff] [blame] | 1843 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1844 | Corresponds to the dotted string ``"2.5.29.14"``. The identifier for the |
| 1845 | :class:`~cryptography.x509.SubjectKeyIdentifier` extension type. |
Paul Kehrer | d4f632e | 2015-05-12 08:25:42 -0500 | [diff] [blame] | 1846 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1847 | .. attribute:: NAME_CONSTRAINTS |
Paul Kehrer | e0017be | 2015-05-17 20:39:40 -0600 | [diff] [blame] | 1848 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1849 | Corresponds to the dotted string ``"2.5.29.30"``. The identifier for the |
| 1850 | :class:`~cryptography.x509.NameConstraints` extension type. |
Paul Kehrer | e0017be | 2015-05-17 20:39:40 -0600 | [diff] [blame] | 1851 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1852 | .. attribute:: CRL_DISTRIBUTION_POINTS |
Paul Kehrer | d4f632e | 2015-05-12 08:25:42 -0500 | [diff] [blame] | 1853 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1854 | Corresponds to the dotted string ``"2.5.29.31"``. The identifier for the |
| 1855 | :class:`~cryptography.x509.CRLDistributionPoints` extension type. |
Paul Kehrer | d4f632e | 2015-05-12 08:25:42 -0500 | [diff] [blame] | 1856 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1857 | .. attribute:: CERTIFICATE_POLICIES |
Paul Kehrer | d4f632e | 2015-05-12 08:25:42 -0500 | [diff] [blame] | 1858 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1859 | Corresponds to the dotted string ``"2.5.29.32"``. The identifier for the |
| 1860 | :class:`~cryptography.x509.CertificatePolicies` extension type. |
Paul Kehrer | d4f632e | 2015-05-12 08:25:42 -0500 | [diff] [blame] | 1861 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1862 | .. attribute:: AUTHORITY_KEY_IDENTIFIER |
Paul Kehrer | d4f632e | 2015-05-12 08:25:42 -0500 | [diff] [blame] | 1863 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1864 | Corresponds to the dotted string ``"2.5.29.35"``. The identifier for the |
| 1865 | :class:`~cryptography.x509.AuthorityKeyIdentifier` extension type. |
Paul Kehrer | d4f632e | 2015-05-12 08:25:42 -0500 | [diff] [blame] | 1866 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1867 | .. attribute:: EXTENDED_KEY_USAGE |
Paul Kehrer | d4f632e | 2015-05-12 08:25:42 -0500 | [diff] [blame] | 1868 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1869 | Corresponds to the dotted string ``"2.5.29.37"``. The identifier for the |
| 1870 | :class:`~cryptography.x509.ExtendedKeyUsage` extension type. |
Paul Kehrer | d4f632e | 2015-05-12 08:25:42 -0500 | [diff] [blame] | 1871 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1872 | .. attribute:: AUTHORITY_INFORMATION_ACCESS |
Paul Kehrer | d4f632e | 2015-05-12 08:25:42 -0500 | [diff] [blame] | 1873 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1874 | Corresponds to the dotted string ``"1.3.6.1.5.5.7.1.1"``. The identifier |
| 1875 | for the :class:`~cryptography.x509.AuthorityInformationAccess` extension |
| 1876 | type. |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 1877 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1878 | .. attribute:: INHIBIT_ANY_POLICY |
Paul Kehrer | b33de93 | 2015-08-06 23:41:05 +0100 | [diff] [blame] | 1879 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1880 | Corresponds to the dotted string ``"2.5.29.54"``. The identifier |
| 1881 | for the :class:`~cryptography.x509.InhibitAnyPolicy` extension type. |
Paul Kehrer | b33de93 | 2015-08-06 23:41:05 +0100 | [diff] [blame] | 1882 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1883 | .. attribute:: OCSP_NO_CHECK |
Paul Kehrer | 4a1038e | 2015-05-18 10:28:31 -0700 | [diff] [blame] | 1884 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1885 | Corresponds to the dotted string ``"1.3.6.1.5.5.7.48.1.5"``. The |
| 1886 | identifier for the :class:`~cryptography.x509.OCSPNoCheck` extension |
| 1887 | type. |
Paul Kehrer | 4a1038e | 2015-05-18 10:28:31 -0700 | [diff] [blame] | 1888 | |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 1889 | Exceptions |
| 1890 | ~~~~~~~~~~ |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1891 | .. currentmodule:: cryptography.x509 |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 1892 | |
Paul Kehrer | e76cd27 | 2014-12-14 19:00:51 -0600 | [diff] [blame] | 1893 | .. class:: InvalidVersion |
Paul Kehrer | a68fd33 | 2014-11-27 07:08:40 -1000 | [diff] [blame] | 1894 | |
| 1895 | 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] | 1896 | |
Paul Kehrer | d5cccf7 | 2014-12-15 17:20:33 -0600 | [diff] [blame] | 1897 | .. attribute:: parsed_version |
| 1898 | |
Paul Kehrer | bbffc40 | 2014-12-17 13:33:55 -0600 | [diff] [blame] | 1899 | :type: int |
| 1900 | |
| 1901 | Returns the raw version that was parsed from the certificate. |
Paul Kehrer | d5cccf7 | 2014-12-15 17:20:33 -0600 | [diff] [blame] | 1902 | |
Paul Kehrer | fbb7ac8 | 2015-03-16 19:26:29 -0500 | [diff] [blame] | 1903 | .. class:: DuplicateExtension |
| 1904 | |
| 1905 | This is raised when more than one X.509 extension of the same type is |
| 1906 | found within a certificate. |
| 1907 | |
| 1908 | .. attribute:: oid |
| 1909 | |
| 1910 | :type: :class:`ObjectIdentifier` |
| 1911 | |
| 1912 | Returns the OID. |
| 1913 | |
| 1914 | .. class:: UnsupportedExtension |
| 1915 | |
| 1916 | This is raised when a certificate contains an unsupported extension type. |
| 1917 | |
| 1918 | .. attribute:: oid |
| 1919 | |
| 1920 | :type: :class:`ObjectIdentifier` |
| 1921 | |
| 1922 | Returns the OID. |
| 1923 | |
Paul Kehrer | fa56a23 | 2015-03-17 13:14:03 -0500 | [diff] [blame] | 1924 | .. class:: ExtensionNotFound |
| 1925 | |
| 1926 | This is raised when calling :meth:`Extensions.get_extension_for_oid` with |
| 1927 | an extension OID that is not present in the certificate. |
| 1928 | |
| 1929 | .. attribute:: oid |
| 1930 | |
| 1931 | :type: :class:`ObjectIdentifier` |
| 1932 | |
| 1933 | Returns the OID. |
| 1934 | |
Paul Kehrer | 9089c91 | 2015-04-20 22:15:20 -0500 | [diff] [blame] | 1935 | .. class:: UnsupportedGeneralNameType |
| 1936 | |
| 1937 | This is raised when a certificate contains an unsupported general name |
| 1938 | type in an extension. |
| 1939 | |
Paul Kehrer | bed0735 | 2015-04-21 08:31:10 -0500 | [diff] [blame] | 1940 | .. attribute:: type |
| 1941 | |
Paul Kehrer | 0a621bf | 2015-04-22 09:22:56 -0500 | [diff] [blame] | 1942 | :type: int |
| 1943 | |
| 1944 | The integer value of the unsupported type. The complete list of |
| 1945 | types can be found in `RFC 5280 section 4.2.1.6`_. |
Paul Kehrer | bed0735 | 2015-04-21 08:31:10 -0500 | [diff] [blame] | 1946 | |
Paul Kehrer | 016e08a | 2014-11-26 09:41:18 -1000 | [diff] [blame] | 1947 | |
Paul Kehrer | c7c9a43 | 2015-04-19 09:20:13 -0500 | [diff] [blame] | 1948 | .. _`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] | 1949 | .. _`RFC 5280 section 4.2.1.6`: https://tools.ietf.org/html/rfc5280#section-4.2.1.6 |