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