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