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