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 | |
Alex Gaynor | 5ce1404 | 2016-05-29 13:13:46 -0400 | [diff] [blame] | 123 | .. doctest:: |
| 124 | |
| 125 | >>> from cryptography import x509 |
| 126 | >>> from cryptography.hazmat.backends import default_backend |
| 127 | >>> cert = x509.load_pem_x509_certificate(pem_data, default_backend()) |
Chelsea Winfree | e295f3a | 2016-06-02 21:15:54 -0700 | [diff] [blame] | 128 | >>> cert.serial_number |
Alex Gaynor | 5ce1404 | 2016-05-29 13:13:46 -0400 | [diff] [blame] | 129 | 2 |
| 130 | |
Paul Kehrer | 016e08a | 2014-11-26 09:41:18 -1000 | [diff] [blame] | 131 | .. function:: load_der_x509_certificate(data, backend) |
| 132 | |
| 133 | .. versionadded:: 0.7 |
| 134 | |
Paul Kehrer | e76cd27 | 2014-12-14 19:00:51 -0600 | [diff] [blame] | 135 | Deserialize a certificate from DER encoded data. DER is a binary format |
Paul Kehrer | 92aac38 | 2014-12-15 16:25:28 -0600 | [diff] [blame] | 136 | and is commonly found in files with the ``.cer`` extension (although file |
| 137 | extensions are not a guarantee of encoding type). |
Paul Kehrer | 016e08a | 2014-11-26 09:41:18 -1000 | [diff] [blame] | 138 | |
| 139 | :param bytes data: The DER encoded certificate data. |
| 140 | |
| 141 | :param backend: A backend supporting the |
| 142 | :class:`~cryptography.hazmat.backends.interfaces.X509Backend` |
| 143 | interface. |
| 144 | |
Paul Kehrer | e76cd27 | 2014-12-14 19:00:51 -0600 | [diff] [blame] | 145 | :returns: An instance of :class:`~cryptography.x509.Certificate`. |
Paul Kehrer | 016e08a | 2014-11-26 09:41:18 -1000 | [diff] [blame] | 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 | |
Alex Gaynor | 5ce1404 | 2016-05-29 13:13:46 -0400 | [diff] [blame] | 167 | .. doctest:: |
| 168 | |
| 169 | >>> from cryptography import x509 |
| 170 | >>> from cryptography.hazmat.backends import default_backend |
| 171 | >>> from cryptography.hazmat.primitives import hashes |
| 172 | >>> crl = x509.load_pem_x509_crl(pem_crl_data, default_backend()) |
| 173 | >>> isinstance(crl.signature_hash_algorithm, hashes.SHA256) |
| 174 | True |
| 175 | |
Erik Trauschke | dc57040 | 2015-09-24 20:24:28 -0700 | [diff] [blame] | 176 | .. function:: load_der_x509_crl(data, backend) |
| 177 | |
| 178 | .. versionadded:: 1.1 |
| 179 | |
| 180 | Deserialize a certificate revocation list (CRL) from DER encoded data. DER |
| 181 | is a binary format. |
| 182 | |
| 183 | :param bytes data: The DER encoded request data. |
| 184 | |
| 185 | :param backend: A backend supporting the |
| 186 | :class:`~cryptography.hazmat.backends.interfaces.X509Backend` |
| 187 | interface. |
| 188 | |
| 189 | :returns: An instance of |
| 190 | :class:`~cryptography.x509.CertificateRevocationList`. |
| 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 | |
Alex Gaynor | 5ce1404 | 2016-05-29 13:13:46 -0400 | [diff] [blame] | 213 | .. doctest:: |
| 214 | |
| 215 | >>> from cryptography import x509 |
| 216 | >>> from cryptography.hazmat.backends import default_backend |
| 217 | >>> from cryptography.hazmat.primitives import hashes |
| 218 | >>> csr = x509.load_pem_x509_csr(pem_req_data, default_backend()) |
| 219 | >>> isinstance(csr.signature_hash_algorithm, hashes.SHA1) |
| 220 | True |
| 221 | |
Paul Kehrer | 1effb6e | 2015-03-30 15:05:59 -0500 | [diff] [blame] | 222 | .. function:: load_der_x509_csr(data, backend) |
| 223 | |
| 224 | .. versionadded:: 0.9 |
| 225 | |
| 226 | Deserialize a certificate signing request (CSR) from DER encoded data. DER |
| 227 | is a binary format and is not commonly used with CSRs. |
| 228 | |
| 229 | :param bytes data: The DER encoded request data. |
| 230 | |
| 231 | :param backend: A backend supporting the |
| 232 | :class:`~cryptography.hazmat.backends.interfaces.X509Backend` |
| 233 | interface. |
| 234 | |
| 235 | :returns: An instance of |
| 236 | :class:`~cryptography.x509.CertificateSigningRequest`. |
| 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 | |
Chelsea Winfree | e295f3a | 2016-06-02 21:15:54 -0700 | [diff] [blame] | 276 | .. attribute:: serial_number |
Paul Kehrer | b2de948 | 2014-12-11 14:54:48 -0600 | [diff] [blame] | 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 | |
Chelsea Winfree | e295f3a | 2016-06-02 21:15:54 -0700 | [diff] [blame] | 284 | >>> cert.serial_number |
Paul Kehrer | cc8a26e | 2014-12-16 12:40:16 -0600 | [diff] [blame] | 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 | c7b29b8 | 2016-09-01 09:17:21 +0800 | [diff] [blame] | 357 | .. attribute:: signature_algorithm_oid |
| 358 | |
| 359 | .. versionadded:: 1.6 |
| 360 | |
| 361 | :type: :class:`ObjectIdentifier` |
| 362 | |
| 363 | Returns the :class:`ObjectIdentifier` of the signature algorithm used |
| 364 | to sign the certificate. This will be one of the OIDs from |
| 365 | :class:`~cryptography.x509.oid.SignatureAlgorithmOID`. |
| 366 | |
| 367 | |
| 368 | .. doctest:: |
| 369 | |
| 370 | >>> cert.signature_algorithm_oid |
| 371 | <ObjectIdentifier(oid=1.2.840.113549.1.1.11, name=sha256WithRSAEncryption)> |
| 372 | |
Paul Kehrer | fbb7ac8 | 2015-03-16 19:26:29 -0500 | [diff] [blame] | 373 | .. attribute:: extensions |
| 374 | |
| 375 | :type: :class:`Extensions` |
| 376 | |
| 377 | The extensions encoded in the certificate. |
| 378 | |
| 379 | :raises cryptography.x509.DuplicateExtension: If more than one |
| 380 | extension of the same type is found within the certificate. |
| 381 | |
Paul Kehrer | bed0735 | 2015-04-21 08:31:10 -0500 | [diff] [blame] | 382 | :raises cryptography.x509.UnsupportedGeneralNameType: If an extension |
| 383 | contains a general name that is not supported. |
| 384 | |
Paul Kehrer | b896881 | 2015-05-15 09:01:34 -0700 | [diff] [blame] | 385 | :raises UnicodeError: If an extension contains IDNA encoding that is |
| 386 | invalid or not compliant with IDNA 2008. |
| 387 | |
Paul Kehrer | fa56a23 | 2015-03-17 13:14:03 -0500 | [diff] [blame] | 388 | .. doctest:: |
| 389 | |
| 390 | >>> for ext in cert.extensions: |
| 391 | ... print(ext) |
Paul Kehrer | d774de9 | 2015-05-03 10:52:25 -0500 | [diff] [blame] | 392 | <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] | 393 | <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] | 394 | <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] | 395 | <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] | 396 | <Extension(oid=<ObjectIdentifier(oid=2.5.29.19, name=basicConstraints)>, critical=True, value=<BasicConstraints(ca=True, path_length=None)>)> |
| 397 | |
Paul Kehrer | d91e7c1 | 2015-10-01 16:50:42 -0500 | [diff] [blame] | 398 | .. attribute:: signature |
| 399 | |
| 400 | .. versionadded:: 1.2 |
| 401 | |
| 402 | :type: bytes |
| 403 | |
| 404 | The bytes of the certificate's signature. |
| 405 | |
Paul Kehrer | d289805 | 2015-11-03 22:00:41 +0900 | [diff] [blame] | 406 | .. attribute:: tbs_certificate_bytes |
Paul Kehrer | d91e7c1 | 2015-10-01 16:50:42 -0500 | [diff] [blame] | 407 | |
| 408 | .. versionadded:: 1.2 |
| 409 | |
| 410 | :type: bytes |
| 411 | |
| 412 | The DER encoded bytes payload (as defined by :rfc:`5280`) that is hashed |
| 413 | and then signed by the private key of the certificate's issuer. This |
| 414 | data may be used to validate a signature, but use extreme caution as |
| 415 | certificate validation is a complex problem that involves much more |
| 416 | than just signature checks. |
| 417 | |
Andre Caron | a8aded6 | 2015-05-19 20:11:57 -0400 | [diff] [blame] | 418 | .. method:: public_bytes(encoding) |
| 419 | |
Alex Gaynor | d0b376b | 2015-07-05 13:58:12 -0400 | [diff] [blame] | 420 | .. versionadded:: 1.0 |
| 421 | |
Andre Caron | a8aded6 | 2015-05-19 20:11:57 -0400 | [diff] [blame] | 422 | :param encoding: The |
| 423 | :class:`~cryptography.hazmat.primitives.serialization.Encoding` |
| 424 | that will be used to serialize the certificate. |
| 425 | |
| 426 | :return bytes: The data that can be written to a file or sent |
| 427 | over the network to be verified by clients. |
| 428 | |
Erik Trauschke | 2dcce90 | 2015-05-14 16:12:24 -0700 | [diff] [blame] | 429 | X.509 CRL (Certificate Revocation List) Object |
| 430 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 431 | |
| 432 | .. class:: CertificateRevocationList |
| 433 | |
| 434 | .. versionadded:: 1.0 |
| 435 | |
Erik Trauschke | 3cdabaf | 2015-10-13 09:42:53 -0700 | [diff] [blame] | 436 | A CertificateRevocationList is an object representing a list of revoked |
| 437 | certificates. The object is iterable and will yield the RevokedCertificate |
| 438 | objects stored in this CRL. |
| 439 | |
| 440 | .. doctest:: |
Erik Trauschke | b14f7d1 | 2015-10-13 09:55:39 -0700 | [diff] [blame] | 441 | |
Erik Trauschke | 3cdabaf | 2015-10-13 09:42:53 -0700 | [diff] [blame] | 442 | >>> len(crl) |
| 443 | 1 |
Paul Kehrer | dcdf967 | 2015-10-21 20:27:28 -0500 | [diff] [blame] | 444 | >>> revoked_certificate = crl[0] |
| 445 | >>> type(revoked_certificate) |
Erik Trauschke | 3cdabaf | 2015-10-13 09:42:53 -0700 | [diff] [blame] | 446 | <class 'cryptography.hazmat.backends.openssl.x509._RevokedCertificate'> |
| 447 | >>> for r in crl: |
| 448 | ... print(r.serial_number) |
| 449 | 0 |
| 450 | |
Erik Trauschke | 2dcce90 | 2015-05-14 16:12:24 -0700 | [diff] [blame] | 451 | .. method:: fingerprint(algorithm) |
| 452 | |
| 453 | :param algorithm: The |
| 454 | :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` |
| 455 | that will be used to generate the fingerprint. |
| 456 | |
| 457 | :return bytes: The fingerprint using the supplied hash algorithm, as |
| 458 | bytes. |
| 459 | |
Erik Trauschke | dc57040 | 2015-09-24 20:24:28 -0700 | [diff] [blame] | 460 | .. doctest:: |
| 461 | |
| 462 | >>> from cryptography.hazmat.primitives import hashes |
| 463 | >>> crl.fingerprint(hashes.SHA256()) |
| 464 | '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' |
| 465 | |
Erik Trauschke | 2dcce90 | 2015-05-14 16:12:24 -0700 | [diff] [blame] | 466 | .. attribute:: signature_hash_algorithm |
| 467 | |
| 468 | :type: :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` |
| 469 | |
| 470 | Returns the |
| 471 | :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` which |
| 472 | was used in signing this CRL. |
| 473 | |
Erik Trauschke | dc57040 | 2015-09-24 20:24:28 -0700 | [diff] [blame] | 474 | .. doctest:: |
| 475 | |
| 476 | >>> from cryptography.hazmat.primitives import hashes |
| 477 | >>> isinstance(crl.signature_hash_algorithm, hashes.SHA256) |
| 478 | True |
| 479 | |
Paul Kehrer | c7b29b8 | 2016-09-01 09:17:21 +0800 | [diff] [blame] | 480 | .. attribute:: signature_algorithm_oid |
| 481 | |
| 482 | .. versionadded:: 1.6 |
| 483 | |
| 484 | :type: :class:`ObjectIdentifier` |
| 485 | |
| 486 | Returns the :class:`ObjectIdentifier` of the signature algorithm used |
| 487 | to sign the CRL. This will be one of the OIDs from |
| 488 | :class:`~cryptography.x509.oid.SignatureAlgorithmOID`. |
| 489 | |
| 490 | .. doctest:: |
| 491 | |
| 492 | >>> crl.signature_algorithm_oid |
| 493 | <ObjectIdentifier(oid=1.2.840.113549.1.1.11, name=sha256WithRSAEncryption)> |
| 494 | |
Erik Trauschke | 2dcce90 | 2015-05-14 16:12:24 -0700 | [diff] [blame] | 495 | .. attribute:: issuer |
| 496 | |
| 497 | :type: :class:`Name` |
| 498 | |
| 499 | The :class:`Name` of the issuer. |
| 500 | |
Erik Trauschke | dc57040 | 2015-09-24 20:24:28 -0700 | [diff] [blame] | 501 | .. doctest:: |
| 502 | |
| 503 | >>> crl.issuer |
| 504 | <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')>])> |
| 505 | |
Erik Trauschke | 2dcce90 | 2015-05-14 16:12:24 -0700 | [diff] [blame] | 506 | .. attribute:: next_update |
| 507 | |
| 508 | :type: :class:`datetime.datetime` |
| 509 | |
| 510 | A naïve datetime representing when the next update to this CRL is |
| 511 | expected. |
| 512 | |
Erik Trauschke | dc57040 | 2015-09-24 20:24:28 -0700 | [diff] [blame] | 513 | .. doctest:: |
| 514 | |
| 515 | >>> crl.next_update |
| 516 | datetime.datetime(2016, 1, 1, 0, 0) |
| 517 | |
Erik Trauschke | 2dcce90 | 2015-05-14 16:12:24 -0700 | [diff] [blame] | 518 | .. attribute:: last_update |
| 519 | |
| 520 | :type: :class:`datetime.datetime` |
| 521 | |
| 522 | A naïve datetime representing when the this CRL was last updated. |
| 523 | |
Erik Trauschke | dc57040 | 2015-09-24 20:24:28 -0700 | [diff] [blame] | 524 | .. doctest:: |
Erik Trauschke | 2dcce90 | 2015-05-14 16:12:24 -0700 | [diff] [blame] | 525 | |
Erik Trauschke | dc57040 | 2015-09-24 20:24:28 -0700 | [diff] [blame] | 526 | >>> crl.last_update |
| 527 | datetime.datetime(2015, 1, 1, 0, 0) |
Erik Trauschke | 2dcce90 | 2015-05-14 16:12:24 -0700 | [diff] [blame] | 528 | |
| 529 | .. attribute:: extensions |
| 530 | |
| 531 | :type: :class:`Extensions` |
| 532 | |
| 533 | The extensions encoded in the CRL. |
| 534 | |
Erik Trauschke | 6abe2bb | 2015-11-19 10:27:01 -0800 | [diff] [blame] | 535 | .. attribute:: signature |
| 536 | |
| 537 | .. versionadded:: 1.2 |
| 538 | |
| 539 | :type: bytes |
| 540 | |
| 541 | The bytes of the CRL's signature. |
| 542 | |
| 543 | .. attribute:: tbs_certlist_bytes |
| 544 | |
| 545 | .. versionadded:: 1.2 |
| 546 | |
| 547 | :type: bytes |
| 548 | |
| 549 | The DER encoded bytes payload (as defined by :rfc:`5280`) that is hashed |
| 550 | and then signed by the private key of the CRL's issuer. This data may be |
| 551 | used to validate a signature, but use extreme caution as CRL validation |
| 552 | is a complex problem that involves much more than just signature checks. |
| 553 | |
Paul Kehrer | 54a837d | 2015-12-20 23:42:32 -0600 | [diff] [blame] | 554 | .. method:: public_bytes(encoding) |
| 555 | |
| 556 | .. versionadded:: 1.2 |
| 557 | |
| 558 | :param encoding: The |
| 559 | :class:`~cryptography.hazmat.primitives.serialization.Encoding` |
| 560 | that will be used to serialize the certificate revocation list. |
| 561 | |
| 562 | :return bytes: The data that can be written to a file or sent |
| 563 | over the network and used as part of a certificate verification |
| 564 | process. |
| 565 | |
Vincent Pelletier | 6c02ee8 | 2017-08-12 22:05:00 +0900 | [diff] [blame] | 566 | .. method:: is_signature_valid(public_key) |
| 567 | |
| 568 | .. versionadded:: 2.1 |
| 569 | |
Paul Kehrer | f944c40 | 2017-08-12 08:52:55 -0500 | [diff] [blame] | 570 | .. warning:: |
| 571 | |
| 572 | Checking the validity of the signature on the CRL is insufficient |
| 573 | to know if the CRL should be trusted. More details are available |
| 574 | in :rfc:`5280`. |
| 575 | |
Vincent Pelletier | 6c02ee8 | 2017-08-12 22:05:00 +0900 | [diff] [blame] | 576 | Returns True if the CRL signature is correct for given public key, |
| 577 | False otherwise. |
Erik Trauschke | 6abe2bb | 2015-11-19 10:27:01 -0800 | [diff] [blame] | 578 | |
Andre Caron | 9bbfcea | 2015-05-18 20:55:29 -0400 | [diff] [blame] | 579 | X.509 Certificate Builder |
| 580 | ~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 581 | |
| 582 | .. class:: CertificateBuilder |
| 583 | |
Ian Cordasco | 1517a4b | 2015-08-02 22:11:19 -0500 | [diff] [blame] | 584 | .. versionadded:: 1.0 |
| 585 | |
| 586 | .. doctest:: |
| 587 | |
| 588 | >>> from cryptography import x509 |
| 589 | >>> from cryptography.hazmat.backends import default_backend |
| 590 | >>> from cryptography.hazmat.primitives import hashes |
| 591 | >>> from cryptography.hazmat.primitives.asymmetric import rsa |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 592 | >>> from cryptography.x509.oid import NameOID |
Ian Cordasco | 1517a4b | 2015-08-02 22:11:19 -0500 | [diff] [blame] | 593 | >>> import datetime |
Ian Cordasco | 1517a4b | 2015-08-02 22:11:19 -0500 | [diff] [blame] | 594 | >>> one_day = datetime.timedelta(1, 0, 0) |
| 595 | >>> private_key = rsa.generate_private_key( |
| 596 | ... public_exponent=65537, |
| 597 | ... key_size=2048, |
| 598 | ... backend=default_backend() |
| 599 | ... ) |
Cory Benfield | c47b252 | 2015-12-07 15:25:12 +0000 | [diff] [blame] | 600 | >>> public_key = private_key.public_key() |
Ian Cordasco | 1517a4b | 2015-08-02 22:11:19 -0500 | [diff] [blame] | 601 | >>> builder = x509.CertificateBuilder() |
| 602 | >>> builder = builder.subject_name(x509.Name([ |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 603 | ... x509.NameAttribute(NameOID.COMMON_NAME, u'cryptography.io'), |
Ian Cordasco | 1517a4b | 2015-08-02 22:11:19 -0500 | [diff] [blame] | 604 | ... ])) |
| 605 | >>> builder = builder.issuer_name(x509.Name([ |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 606 | ... x509.NameAttribute(NameOID.COMMON_NAME, u'cryptography.io'), |
Ian Cordasco | 1517a4b | 2015-08-02 22:11:19 -0500 | [diff] [blame] | 607 | ... ])) |
| 608 | >>> builder = builder.not_valid_before(datetime.datetime.today() - one_day) |
| 609 | >>> builder = builder.not_valid_after(datetime.datetime(2018, 8, 2)) |
Paul Kehrer | 8b89bcc | 2016-09-03 11:31:43 -0500 | [diff] [blame] | 610 | >>> builder = builder.serial_number(x509.random_serial_number()) |
Ian Cordasco | 1517a4b | 2015-08-02 22:11:19 -0500 | [diff] [blame] | 611 | >>> builder = builder.public_key(public_key) |
| 612 | >>> builder = builder.add_extension( |
Paul Kehrer | 1bab7bc | 2017-01-18 13:44:40 +0800 | [diff] [blame] | 613 | ... x509.SubjectAlternativeName( |
Alex Gaynor | cdaf3ff | 2017-07-30 13:08:51 -0400 | [diff] [blame] | 614 | ... [x509.DNSName(b'cryptography.io')] |
Paul Kehrer | 1bab7bc | 2017-01-18 13:44:40 +0800 | [diff] [blame] | 615 | ... ), |
| 616 | ... critical=False |
| 617 | ... ) |
| 618 | >>> builder = builder.add_extension( |
Ian Cordasco | 1517a4b | 2015-08-02 22:11:19 -0500 | [diff] [blame] | 619 | ... x509.BasicConstraints(ca=False, path_length=None), critical=True, |
| 620 | ... ) |
| 621 | >>> certificate = builder.sign( |
| 622 | ... private_key=private_key, algorithm=hashes.SHA256(), |
| 623 | ... backend=default_backend() |
| 624 | ... ) |
| 625 | >>> isinstance(certificate, x509.Certificate) |
| 626 | True |
| 627 | |
Ian Cordasco | 0092a0b | 2015-07-18 21:46:41 -0500 | [diff] [blame] | 628 | .. method:: issuer_name(name) |
Andre Caron | 9bbfcea | 2015-05-18 20:55:29 -0400 | [diff] [blame] | 629 | |
| 630 | Sets the issuer's distinguished name. |
| 631 | |
Ian Cordasco | c9682ad | 2015-08-01 12:11:13 -0500 | [diff] [blame] | 632 | :param name: The :class:`~cryptography.x509.Name` that describes the |
| 633 | issuer (CA). |
Andre Caron | 9bbfcea | 2015-05-18 20:55:29 -0400 | [diff] [blame] | 634 | |
Ian Cordasco | 0092a0b | 2015-07-18 21:46:41 -0500 | [diff] [blame] | 635 | .. method:: subject_name(name) |
Andre Caron | 9bbfcea | 2015-05-18 20:55:29 -0400 | [diff] [blame] | 636 | |
| 637 | Sets the subject's distinguished name. |
| 638 | |
Ian Cordasco | c9682ad | 2015-08-01 12:11:13 -0500 | [diff] [blame] | 639 | :param name: The :class:`~cryptography.x509.Name` that describes the |
Ian Cordasco | 85fc4d5 | 2015-08-01 20:29:31 -0500 | [diff] [blame] | 640 | subject. |
Andre Caron | 9bbfcea | 2015-05-18 20:55:29 -0400 | [diff] [blame] | 641 | |
Ian Cordasco | 0092a0b | 2015-07-18 21:46:41 -0500 | [diff] [blame] | 642 | .. method:: public_key(public_key) |
Andre Caron | 9bbfcea | 2015-05-18 20:55:29 -0400 | [diff] [blame] | 643 | |
| 644 | Sets the subject's public key. |
| 645 | |
Ian Cordasco | 8f57142 | 2015-08-02 11:31:08 -0500 | [diff] [blame] | 646 | :param public_key: The subject's public key. This can be one of |
| 647 | :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey`, |
| 648 | :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPublicKey` or |
| 649 | :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey` |
Andre Caron | 9bbfcea | 2015-05-18 20:55:29 -0400 | [diff] [blame] | 650 | |
Ian Cordasco | 0092a0b | 2015-07-18 21:46:41 -0500 | [diff] [blame] | 651 | .. method:: serial_number(serial_number) |
Andre Caron | 9bbfcea | 2015-05-18 20:55:29 -0400 | [diff] [blame] | 652 | |
| 653 | Sets the certificate's serial number (an integer). The CA's policy |
Paul Kehrer | 8b89bcc | 2016-09-03 11:31:43 -0500 | [diff] [blame] | 654 | determines how it attributes serial numbers to certificates. This |
| 655 | number must uniquely identify the certificate given the issuer. |
| 656 | `CABForum Guidelines`_ require entropy in the serial number |
| 657 | to provide protection against hash collision attacks. For more |
| 658 | information on secure random number generation, see |
| 659 | :doc:`/random-numbers`. |
Andre Caron | 9bbfcea | 2015-05-18 20:55:29 -0400 | [diff] [blame] | 660 | |
| 661 | :param serial_number: Integer number that will be used by the CA to |
| 662 | identify this certificate (most notably during certificate |
Paul Kehrer | 8b89bcc | 2016-09-03 11:31:43 -0500 | [diff] [blame] | 663 | revocation checking). Users should consider using |
| 664 | :func:`~cryptography.x509.random_serial_number` when possible. |
Andre Caron | 9bbfcea | 2015-05-18 20:55:29 -0400 | [diff] [blame] | 665 | |
Ian Cordasco | 0092a0b | 2015-07-18 21:46:41 -0500 | [diff] [blame] | 666 | .. method:: not_valid_before(time) |
Andre Caron | 9bbfcea | 2015-05-18 20:55:29 -0400 | [diff] [blame] | 667 | |
| 668 | Sets the certificate's activation time. This is the time from which |
| 669 | clients can start trusting the certificate. It may be different from |
| 670 | the time at which the certificate was created. |
| 671 | |
Ian Cordasco | 17c8900 | 2015-08-02 21:13:59 -0500 | [diff] [blame] | 672 | :param time: The :class:`datetime.datetime` object (in UTC) that marks the |
Andre Caron | 9bbfcea | 2015-05-18 20:55:29 -0400 | [diff] [blame] | 673 | activation time for the certificate. The certificate may not be |
| 674 | trusted clients if it is used before this time. |
| 675 | |
Ian Cordasco | 0092a0b | 2015-07-18 21:46:41 -0500 | [diff] [blame] | 676 | .. method:: not_valid_after(time) |
Andre Caron | 9bbfcea | 2015-05-18 20:55:29 -0400 | [diff] [blame] | 677 | |
| 678 | Sets the certificate's expiration time. This is the time from which |
| 679 | clients should no longer trust the certificate. The CA's policy will |
| 680 | determine how long the certificate should remain in use. |
| 681 | |
Ian Cordasco | 17c8900 | 2015-08-02 21:13:59 -0500 | [diff] [blame] | 682 | :param time: The :class:`datetime.datetime` object (in UTC) that marks the |
Andre Caron | 9bbfcea | 2015-05-18 20:55:29 -0400 | [diff] [blame] | 683 | expiration time for the certificate. The certificate may not be |
| 684 | trusted clients if it is used after this time. |
| 685 | |
Ian Cordasco | 17c8900 | 2015-08-02 21:13:59 -0500 | [diff] [blame] | 686 | .. method:: add_extension(extension, critical) |
Andre Caron | 9bbfcea | 2015-05-18 20:55:29 -0400 | [diff] [blame] | 687 | |
| 688 | Adds an X.509 extension to the certificate. |
| 689 | |
Paul Kehrer | 2c145cc | 2015-10-02 11:27:21 -0500 | [diff] [blame] | 690 | :param extension: An extension conforming to the |
| 691 | :class:`~cryptography.x509.ExtensionType` interface. |
Andre Caron | 9bbfcea | 2015-05-18 20:55:29 -0400 | [diff] [blame] | 692 | |
Ian Cordasco | 17c8900 | 2015-08-02 21:13:59 -0500 | [diff] [blame] | 693 | :param critical: Set to ``True`` if the extension must be understood and |
| 694 | handled by whoever reads the certificate. |
| 695 | |
Paul Kehrer | 9add80e | 2015-08-03 17:53:14 +0100 | [diff] [blame] | 696 | .. method:: sign(private_key, algorithm, backend) |
Andre Caron | 9bbfcea | 2015-05-18 20:55:29 -0400 | [diff] [blame] | 697 | |
| 698 | Sign the certificate using the CA's private key. |
| 699 | |
Ian Cordasco | c5e1c25 | 2015-07-31 23:33:35 -0500 | [diff] [blame] | 700 | :param private_key: The |
| 701 | :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey`, |
| 702 | :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPrivateKey` or |
| 703 | :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateKey` |
| 704 | that will be used to sign the certificate. |
| 705 | |
Andre Caron | 9bbfcea | 2015-05-18 20:55:29 -0400 | [diff] [blame] | 706 | :param algorithm: The |
| 707 | :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` that |
| 708 | will be used to generate the signature. |
| 709 | |
Paul Kehrer | 9add80e | 2015-08-03 17:53:14 +0100 | [diff] [blame] | 710 | :param backend: Backend that will be used to build the certificate. |
| 711 | Must support the |
| 712 | :class:`~cryptography.hazmat.backends.interfaces.X509Backend` |
| 713 | interface. |
| 714 | |
Benjamin Peterson | 9ed312b | 2015-10-12 20:51:34 -0700 | [diff] [blame] | 715 | :returns: :class:`~cryptography.x509.Certificate` |
Andre Caron | 9bbfcea | 2015-05-18 20:55:29 -0400 | [diff] [blame] | 716 | |
| 717 | |
Paul Kehrer | 5aadb9c | 2015-03-11 20:48:42 -0500 | [diff] [blame] | 718 | X.509 CSR (Certificate Signing Request) Object |
| 719 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
Paul Kehrer | dc480ad | 2015-02-23 12:14:54 -0600 | [diff] [blame] | 720 | |
Paul Kehrer | a1a1f23 | 2015-03-15 15:34:35 -0500 | [diff] [blame] | 721 | .. class:: CertificateSigningRequest |
Paul Kehrer | dc480ad | 2015-02-23 12:14:54 -0600 | [diff] [blame] | 722 | |
| 723 | .. versionadded:: 0.9 |
| 724 | |
| 725 | .. method:: public_key() |
| 726 | |
Alex Gaynor | 4c2561a | 2015-10-12 23:53:39 -0400 | [diff] [blame] | 727 | The public key associated with the request. |
| 728 | |
| 729 | :returns: |
Paul Kehrer | dc480ad | 2015-02-23 12:14:54 -0600 | [diff] [blame] | 730 | :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey` or |
| 731 | :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPublicKey` or |
| 732 | :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey` |
| 733 | |
Paul Kehrer | dc480ad | 2015-02-23 12:14:54 -0600 | [diff] [blame] | 734 | .. doctest:: |
| 735 | |
| 736 | >>> from cryptography.hazmat.primitives.asymmetric import rsa |
Paul Kehrer | a1a1f23 | 2015-03-15 15:34:35 -0500 | [diff] [blame] | 737 | >>> public_key = csr.public_key() |
Paul Kehrer | dc480ad | 2015-02-23 12:14:54 -0600 | [diff] [blame] | 738 | >>> isinstance(public_key, rsa.RSAPublicKey) |
| 739 | True |
| 740 | |
| 741 | .. attribute:: subject |
| 742 | |
| 743 | :type: :class:`Name` |
| 744 | |
| 745 | The :class:`Name` of the subject. |
| 746 | |
| 747 | .. attribute:: signature_hash_algorithm |
| 748 | |
| 749 | :type: :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` |
| 750 | |
| 751 | Returns the |
| 752 | :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` which |
| 753 | was used in signing this request. |
| 754 | |
| 755 | .. doctest:: |
| 756 | |
| 757 | >>> from cryptography.hazmat.primitives import hashes |
Paul Kehrer | a1a1f23 | 2015-03-15 15:34:35 -0500 | [diff] [blame] | 758 | >>> isinstance(csr.signature_hash_algorithm, hashes.SHA1) |
Paul Kehrer | dc480ad | 2015-02-23 12:14:54 -0600 | [diff] [blame] | 759 | True |
| 760 | |
Paul Kehrer | c7b29b8 | 2016-09-01 09:17:21 +0800 | [diff] [blame] | 761 | .. attribute:: signature_algorithm_oid |
| 762 | |
| 763 | .. versionadded:: 1.6 |
| 764 | |
| 765 | :type: :class:`ObjectIdentifier` |
| 766 | |
| 767 | Returns the :class:`ObjectIdentifier` of the signature algorithm used |
| 768 | to sign the request. This will be one of the OIDs from |
| 769 | :class:`~cryptography.x509.oid.SignatureAlgorithmOID`. |
| 770 | |
| 771 | .. doctest:: |
| 772 | |
| 773 | >>> csr.signature_algorithm_oid |
| 774 | <ObjectIdentifier(oid=1.2.840.113549.1.1.5, name=sha1WithRSAEncryption)> |
| 775 | |
Paul Kehrer | c4e6194 | 2015-08-01 21:21:13 +0100 | [diff] [blame] | 776 | .. attribute:: extensions |
| 777 | |
| 778 | :type: :class:`Extensions` |
| 779 | |
| 780 | The extensions encoded in the certificate signing request. |
| 781 | |
| 782 | :raises cryptography.x509.DuplicateExtension: If more than one |
Paul Kehrer | 24283d2 | 2015-08-01 21:31:19 +0100 | [diff] [blame] | 783 | extension of the same type is found within the certificate signing request. |
Paul Kehrer | c4e6194 | 2015-08-01 21:21:13 +0100 | [diff] [blame] | 784 | |
Paul Kehrer | c4e6194 | 2015-08-01 21:21:13 +0100 | [diff] [blame] | 785 | :raises cryptography.x509.UnsupportedGeneralNameType: If an extension |
| 786 | contains a general name that is not supported. |
| 787 | |
| 788 | :raises UnicodeError: If an extension contains IDNA encoding that is |
| 789 | invalid or not compliant with IDNA 2008. |
| 790 | |
| 791 | |
Andre Caron | 476c5df | 2015-05-18 10:23:28 -0400 | [diff] [blame] | 792 | .. method:: public_bytes(encoding) |
| 793 | |
Alex Gaynor | d0b376b | 2015-07-05 13:58:12 -0400 | [diff] [blame] | 794 | .. versionadded:: 1.0 |
| 795 | |
Andre Caron | 476c5df | 2015-05-18 10:23:28 -0400 | [diff] [blame] | 796 | :param encoding: The |
| 797 | :class:`~cryptography.hazmat.primitives.serialization.Encoding` |
| 798 | that will be used to serialize the certificate request. |
| 799 | |
| 800 | :return bytes: The data that can be written to a file or sent |
| 801 | over the network to be signed by the certificate |
| 802 | authority. |
| 803 | |
Paul Kehrer | ab20939 | 2015-12-01 14:50:31 -0600 | [diff] [blame] | 804 | .. attribute:: signature |
| 805 | |
| 806 | .. versionadded:: 1.2 |
| 807 | |
| 808 | :type: bytes |
| 809 | |
| 810 | The bytes of the certificate signing request's signature. |
| 811 | |
| 812 | .. attribute:: tbs_certrequest_bytes |
| 813 | |
| 814 | .. versionadded:: 1.2 |
| 815 | |
| 816 | :type: bytes |
| 817 | |
| 818 | The DER encoded bytes payload (as defined by :rfc:`2986`) that is |
| 819 | hashed and then signed by the private key (corresponding to the public |
| 820 | key embedded in the CSR). This data may be used to validate the CSR |
| 821 | signature. |
| 822 | |
Joern Heissler | fbda8ce | 2016-01-18 00:24:44 +0100 | [diff] [blame] | 823 | .. attribute:: is_signature_valid |
Joern Heissler | 1bd77e2 | 2016-01-13 22:51:37 +0100 | [diff] [blame] | 824 | |
| 825 | .. versionadded:: 1.3 |
| 826 | |
Joern Heissler | fbda8ce | 2016-01-18 00:24:44 +0100 | [diff] [blame] | 827 | Returns True if the CSR signature is correct, False otherwise. |
Joern Heissler | 1bd77e2 | 2016-01-13 22:51:37 +0100 | [diff] [blame] | 828 | |
Paul Kehrer | bfac2d1 | 2015-12-19 23:32:08 -0600 | [diff] [blame] | 829 | X.509 Certificate Revocation List Builder |
| 830 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 831 | |
| 832 | .. class:: CertificateRevocationListBuilder |
| 833 | |
| 834 | .. versionadded:: 1.2 |
| 835 | |
| 836 | .. doctest:: |
| 837 | |
| 838 | >>> from cryptography import x509 |
| 839 | >>> from cryptography.hazmat.backends import default_backend |
| 840 | >>> from cryptography.hazmat.primitives import hashes |
| 841 | >>> from cryptography.hazmat.primitives.asymmetric import rsa |
| 842 | >>> from cryptography.x509.oid import NameOID |
| 843 | >>> import datetime |
| 844 | >>> one_day = datetime.timedelta(1, 0, 0) |
| 845 | >>> private_key = rsa.generate_private_key( |
| 846 | ... public_exponent=65537, |
| 847 | ... key_size=2048, |
| 848 | ... backend=default_backend() |
| 849 | ... ) |
| 850 | >>> builder = x509.CertificateRevocationListBuilder() |
| 851 | >>> builder = builder.issuer_name(x509.Name([ |
| 852 | ... x509.NameAttribute(NameOID.COMMON_NAME, u'cryptography.io CA'), |
| 853 | ... ])) |
| 854 | >>> builder = builder.last_update(datetime.datetime.today()) |
| 855 | >>> builder = builder.next_update(datetime.datetime.today() + one_day) |
Paul Kehrer | 4c7fd5f | 2015-12-25 13:40:55 -0600 | [diff] [blame] | 856 | >>> revoked_cert = x509.RevokedCertificateBuilder().serial_number( |
| 857 | ... 333 |
| 858 | ... ).revocation_date( |
| 859 | ... datetime.datetime.today() |
| 860 | ... ).build(default_backend()) |
| 861 | >>> builder = builder.add_revoked_certificate(revoked_cert) |
Paul Kehrer | bfac2d1 | 2015-12-19 23:32:08 -0600 | [diff] [blame] | 862 | >>> crl = builder.sign( |
| 863 | ... private_key=private_key, algorithm=hashes.SHA256(), |
| 864 | ... backend=default_backend() |
| 865 | ... ) |
Paul Kehrer | 4c7fd5f | 2015-12-25 13:40:55 -0600 | [diff] [blame] | 866 | >>> len(crl) |
| 867 | 1 |
Paul Kehrer | bfac2d1 | 2015-12-19 23:32:08 -0600 | [diff] [blame] | 868 | |
| 869 | .. method:: issuer_name(name) |
| 870 | |
| 871 | Sets the issuer's distinguished name. |
| 872 | |
| 873 | :param name: The :class:`~cryptography.x509.Name` that describes the |
| 874 | issuer (CA). |
| 875 | |
| 876 | .. method:: last_update(time) |
| 877 | |
Paul Kehrer | 0325b9d | 2015-12-24 19:19:59 -0600 | [diff] [blame] | 878 | Sets this CRL's activation time. This is the time from which |
| 879 | clients can start trusting this CRL. It may be different from |
| 880 | the time at which this CRL was created. This is also known as the |
Paul Kehrer | bfac2d1 | 2015-12-19 23:32:08 -0600 | [diff] [blame] | 881 | ``thisUpdate`` time. |
| 882 | |
Paul Kehrer | 0325b9d | 2015-12-24 19:19:59 -0600 | [diff] [blame] | 883 | :param time: The :class:`datetime.datetime` object (in UTC) that marks |
| 884 | the activation time for this CRL. The CRL may not be trusted if it |
| 885 | is used before this time. |
Paul Kehrer | bfac2d1 | 2015-12-19 23:32:08 -0600 | [diff] [blame] | 886 | |
| 887 | .. method:: next_update(time) |
| 888 | |
Paul Kehrer | 0325b9d | 2015-12-24 19:19:59 -0600 | [diff] [blame] | 889 | Sets this CRL's next update time. This is the time by which |
| 890 | a new CRL will be issued. The CA is allowed to issue a new CRL before |
| 891 | this date, however clients are not required to check for it. |
Paul Kehrer | bfac2d1 | 2015-12-19 23:32:08 -0600 | [diff] [blame] | 892 | |
Paul Kehrer | 0325b9d | 2015-12-24 19:19:59 -0600 | [diff] [blame] | 893 | :param time: The :class:`datetime.datetime` object (in UTC) that marks |
| 894 | the next update time for this CRL. |
Paul Kehrer | bfac2d1 | 2015-12-19 23:32:08 -0600 | [diff] [blame] | 895 | |
Paul Kehrer | 426b48d | 2015-12-24 20:50:43 -0600 | [diff] [blame] | 896 | .. method:: add_extension(extension, critical) |
| 897 | |
| 898 | Adds an X.509 extension to this CRL. |
| 899 | |
| 900 | :param extension: An extension with the |
| 901 | :class:`~cryptography.x509.ExtensionType` interface. |
| 902 | |
| 903 | :param critical: Set to ``True`` if the extension must be understood and |
| 904 | handled by whoever reads the CRL. |
| 905 | |
Paul Kehrer | 4c7fd5f | 2015-12-25 13:40:55 -0600 | [diff] [blame] | 906 | .. method:: add_revoked_certificate(revoked_certificate) |
| 907 | |
| 908 | Adds a revoked certificate to this CRL. |
| 909 | |
| 910 | :param revoked_certificate: An instance of |
| 911 | :class:`~cryptography.x509.RevokedCertificate`. These can be |
| 912 | obtained from an existing CRL or created with |
| 913 | :class:`~cryptography.x509.RevokedCertificateBuilder`. |
| 914 | |
Paul Kehrer | bfac2d1 | 2015-12-19 23:32:08 -0600 | [diff] [blame] | 915 | .. method:: sign(private_key, algorithm, backend) |
| 916 | |
Paul Kehrer | 0325b9d | 2015-12-24 19:19:59 -0600 | [diff] [blame] | 917 | Sign this CRL using the CA's private key. |
Paul Kehrer | bfac2d1 | 2015-12-19 23:32:08 -0600 | [diff] [blame] | 918 | |
| 919 | :param private_key: The |
| 920 | :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey`, |
| 921 | :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPrivateKey` or |
| 922 | :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateKey` |
| 923 | that will be used to sign the certificate. |
| 924 | |
| 925 | :param algorithm: The |
| 926 | :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` that |
| 927 | will be used to generate the signature. |
| 928 | |
| 929 | :param backend: Backend that will be used to build the CRL. |
| 930 | Must support the |
| 931 | :class:`~cryptography.hazmat.backends.interfaces.X509Backend` |
| 932 | interface. |
| 933 | |
| 934 | :returns: :class:`~cryptography.x509.CertificateRevocationList` |
| 935 | |
Erik Trauschke | 2dcce90 | 2015-05-14 16:12:24 -0700 | [diff] [blame] | 936 | X.509 Revoked Certificate Object |
Erik Trauschke | c5a8d17 | 2015-05-28 10:24:25 -0700 | [diff] [blame] | 937 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
Erik Trauschke | 2dcce90 | 2015-05-14 16:12:24 -0700 | [diff] [blame] | 938 | |
| 939 | .. class:: RevokedCertificate |
| 940 | |
| 941 | .. versionadded:: 1.0 |
| 942 | |
| 943 | .. attribute:: serial_number |
| 944 | |
| 945 | :type: :class:`int` |
| 946 | |
| 947 | An integer representing the serial number of the revoked certificate. |
| 948 | |
Erik Trauschke | dc57040 | 2015-09-24 20:24:28 -0700 | [diff] [blame] | 949 | .. doctest:: |
| 950 | |
Erik Trauschke | 3cdabaf | 2015-10-13 09:42:53 -0700 | [diff] [blame] | 951 | >>> revoked_certificate.serial_number |
Erik Trauschke | dc57040 | 2015-09-24 20:24:28 -0700 | [diff] [blame] | 952 | 0 |
| 953 | |
Erik Trauschke | 2dcce90 | 2015-05-14 16:12:24 -0700 | [diff] [blame] | 954 | .. attribute:: revocation_date |
| 955 | |
| 956 | :type: :class:`datetime.datetime` |
| 957 | |
| 958 | A naïve datetime representing the date this certificates was revoked. |
| 959 | |
Erik Trauschke | dc57040 | 2015-09-24 20:24:28 -0700 | [diff] [blame] | 960 | .. doctest:: |
| 961 | |
Erik Trauschke | 77f5a25 | 2015-10-14 08:06:38 -0700 | [diff] [blame] | 962 | >>> revoked_certificate.revocation_date |
Erik Trauschke | dc57040 | 2015-09-24 20:24:28 -0700 | [diff] [blame] | 963 | datetime.datetime(2015, 1, 1, 0, 0) |
| 964 | |
Erik Trauschke | 2dcce90 | 2015-05-14 16:12:24 -0700 | [diff] [blame] | 965 | .. attribute:: extensions |
| 966 | |
| 967 | :type: :class:`Extensions` |
| 968 | |
| 969 | The extensions encoded in the revoked certificate. |
Andre Caron | 476c5df | 2015-05-18 10:23:28 -0400 | [diff] [blame] | 970 | |
Erik Trauschke | dc57040 | 2015-09-24 20:24:28 -0700 | [diff] [blame] | 971 | .. doctest:: |
| 972 | |
Erik Trauschke | 77f5a25 | 2015-10-14 08:06:38 -0700 | [diff] [blame] | 973 | >>> for ext in revoked_certificate.extensions: |
Erik Trauschke | dc57040 | 2015-09-24 20:24:28 -0700 | [diff] [blame] | 974 | ... print(ext) |
Paul Kehrer | 23c0bbc | 2015-12-25 22:35:19 -0600 | [diff] [blame] | 975 | <Extension(oid=<ObjectIdentifier(oid=2.5.29.24, name=invalidityDate)>, critical=False, value=<InvalidityDate(invalidity_date=2015-01-01 00:00:00)>)> |
Paul Kehrer | 7058ece | 2015-12-25 22:28:29 -0600 | [diff] [blame] | 976 | <Extension(oid=<ObjectIdentifier(oid=2.5.29.21, name=cRLReason)>, critical=False, value=<CRLReason(reason=ReasonFlags.key_compromise)>)> |
Erik Trauschke | dc57040 | 2015-09-24 20:24:28 -0700 | [diff] [blame] | 977 | |
Paul Kehrer | c33ffd7 | 2015-12-25 10:59:22 -0600 | [diff] [blame] | 978 | X.509 Revoked Certificate Builder |
| 979 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 980 | |
| 981 | .. class:: RevokedCertificateBuilder |
| 982 | |
| 983 | This class is used to create :class:`~cryptography.x509.RevokedCertificate` |
| 984 | objects that can be used with the |
| 985 | :class:`~cryptography.x509.CertificateRevocationListBuilder`. |
| 986 | |
| 987 | .. versionadded:: 1.2 |
| 988 | |
| 989 | .. doctest:: |
| 990 | |
| 991 | >>> from cryptography import x509 |
| 992 | >>> from cryptography.hazmat.backends import default_backend |
| 993 | >>> import datetime |
| 994 | >>> builder = x509.RevokedCertificateBuilder() |
| 995 | >>> builder = builder.revocation_date(datetime.datetime.today()) |
| 996 | >>> builder = builder.serial_number(3333) |
| 997 | >>> revoked_certificate = builder.build(default_backend()) |
| 998 | >>> isinstance(revoked_certificate, x509.RevokedCertificate) |
| 999 | True |
| 1000 | |
| 1001 | .. method:: serial_number(serial_number) |
| 1002 | |
| 1003 | Sets the revoked certificate's serial number. |
| 1004 | |
| 1005 | :param serial_number: Integer number that is used to identify the |
| 1006 | revoked certificate. |
| 1007 | |
| 1008 | .. method:: revocation_date(time) |
| 1009 | |
| 1010 | Sets the certificate's revocation date. |
| 1011 | |
| 1012 | :param time: The :class:`datetime.datetime` object (in UTC) that marks the |
| 1013 | revocation time for the certificate. |
| 1014 | |
Paul Kehrer | e5f152b | 2015-12-25 23:55:47 -0600 | [diff] [blame] | 1015 | .. method:: add_extension(extension, critical) |
| 1016 | |
| 1017 | Adds an X.509 extension to this revoked certificate. |
| 1018 | |
| 1019 | :param extension: An instance of one of the |
| 1020 | :ref:`CRL entry extensions <crl_entry_extensions>`. |
| 1021 | |
| 1022 | :param critical: Set to ``True`` if the extension must be understood and |
| 1023 | handled. |
| 1024 | |
Paul Kehrer | c33ffd7 | 2015-12-25 10:59:22 -0600 | [diff] [blame] | 1025 | .. method:: build(backend) |
| 1026 | |
| 1027 | Create a revoked certificate object using the provided backend. |
| 1028 | |
| 1029 | :param backend: Backend that will be used to build the revoked |
| 1030 | certificate. Must support the |
| 1031 | :class:`~cryptography.hazmat.backends.interfaces.X509Backend` |
| 1032 | interface. |
| 1033 | |
| 1034 | :returns: :class:`~cryptography.x509.RevokedCertificate` |
| 1035 | |
Andre Caron | 0ef595f | 2015-05-18 13:53:43 -0400 | [diff] [blame] | 1036 | X.509 CSR (Certificate Signing Request) Builder Object |
| 1037 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 1038 | |
| 1039 | .. class:: CertificateSigningRequestBuilder |
| 1040 | |
Andre Caron | d259ee5 | 2015-06-02 23:47:11 -0400 | [diff] [blame] | 1041 | .. versionadded:: 1.0 |
| 1042 | |
| 1043 | .. doctest:: |
| 1044 | |
| 1045 | >>> from cryptography import x509 |
| 1046 | >>> from cryptography.hazmat.backends import default_backend |
| 1047 | >>> from cryptography.hazmat.primitives import hashes |
| 1048 | >>> from cryptography.hazmat.primitives.asymmetric import rsa |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1049 | >>> from cryptography.x509.oid import NameOID |
Andre Caron | d259ee5 | 2015-06-02 23:47:11 -0400 | [diff] [blame] | 1050 | >>> private_key = rsa.generate_private_key( |
| 1051 | ... public_exponent=65537, |
| 1052 | ... key_size=2048, |
| 1053 | ... backend=default_backend() |
| 1054 | ... ) |
| 1055 | >>> builder = x509.CertificateSigningRequestBuilder() |
Andre Caron | a9a5117 | 2015-06-06 20:18:44 -0400 | [diff] [blame] | 1056 | >>> builder = builder.subject_name(x509.Name([ |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1057 | ... x509.NameAttribute(NameOID.COMMON_NAME, u'cryptography.io'), |
Andre Caron | d259ee5 | 2015-06-02 23:47:11 -0400 | [diff] [blame] | 1058 | ... ])) |
Ian Cordasco | f06b6be | 2015-06-21 10:09:18 -0500 | [diff] [blame] | 1059 | >>> builder = builder.add_extension( |
Ian Cordasco | 0112b02 | 2015-06-16 17:51:18 -0500 | [diff] [blame] | 1060 | ... x509.BasicConstraints(ca=False, path_length=None), critical=True, |
Andre Caron | 472fd69 | 2015-06-06 20:04:44 -0400 | [diff] [blame] | 1061 | ... ) |
Andre Caron | d259ee5 | 2015-06-02 23:47:11 -0400 | [diff] [blame] | 1062 | >>> request = builder.sign( |
Alex Gaynor | de9e584 | 2015-06-26 20:11:23 -0400 | [diff] [blame] | 1063 | ... private_key, hashes.SHA256(), default_backend() |
Andre Caron | d259ee5 | 2015-06-02 23:47:11 -0400 | [diff] [blame] | 1064 | ... ) |
| 1065 | >>> isinstance(request, x509.CertificateSigningRequest) |
| 1066 | True |
| 1067 | |
Andre Caron | a9a5117 | 2015-06-06 20:18:44 -0400 | [diff] [blame] | 1068 | .. method:: subject_name(name) |
Andre Caron | 0ef595f | 2015-05-18 13:53:43 -0400 | [diff] [blame] | 1069 | |
Andre Caron | 341ff85 | 2015-06-06 20:14:31 -0400 | [diff] [blame] | 1070 | :param name: The :class:`~cryptography.x509.Name` of the certificate |
| 1071 | subject. |
| 1072 | :returns: A new |
| 1073 | :class:`~cryptography.x509.CertificateSigningRequestBuilder`. |
Andre Caron | 0ef595f | 2015-05-18 13:53:43 -0400 | [diff] [blame] | 1074 | |
Ian Cordasco | f06b6be | 2015-06-21 10:09:18 -0500 | [diff] [blame] | 1075 | .. method:: add_extension(extension, critical) |
Andre Caron | 0ef595f | 2015-05-18 13:53:43 -0400 | [diff] [blame] | 1076 | |
Paul Kehrer | 2c145cc | 2015-10-02 11:27:21 -0500 | [diff] [blame] | 1077 | :param extension: An extension conforming to the |
| 1078 | :class:`~cryptography.x509.ExtensionType` interface. |
Andre Caron | 472fd69 | 2015-06-06 20:04:44 -0400 | [diff] [blame] | 1079 | :param critical: Set to `True` if the extension must be understood and |
| 1080 | handled by whoever reads the certificate. |
Andre Caron | 341ff85 | 2015-06-06 20:14:31 -0400 | [diff] [blame] | 1081 | :returns: A new |
| 1082 | :class:`~cryptography.x509.CertificateSigningRequestBuilder`. |
Andre Caron | 0ef595f | 2015-05-18 13:53:43 -0400 | [diff] [blame] | 1083 | |
Alex Gaynor | b3b0fbe | 2015-06-26 19:57:18 -0400 | [diff] [blame] | 1084 | .. method:: sign(private_key, algorithm, backend) |
Andre Caron | 0ef595f | 2015-05-18 13:53:43 -0400 | [diff] [blame] | 1085 | |
| 1086 | :param backend: Backend that will be used to sign the request. |
| 1087 | Must support the |
| 1088 | :class:`~cryptography.hazmat.backends.interfaces.X509Backend` |
| 1089 | interface. |
| 1090 | |
| 1091 | :param private_key: The |
Andre Caron | 24f9bf4 | 2015-06-06 20:14:54 -0400 | [diff] [blame] | 1092 | :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey`, |
| 1093 | :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPrivateKey` or |
| 1094 | :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateKey` |
Andre Caron | 0ef595f | 2015-05-18 13:53:43 -0400 | [diff] [blame] | 1095 | that will be used to sign the request. When the request is |
| 1096 | signed by a certificate authority, the private key's associated |
| 1097 | public key will be stored in the resulting certificate. |
| 1098 | |
| 1099 | :param algorithm: The |
| 1100 | :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` |
| 1101 | that will be used to generate the request signature. |
| 1102 | |
Andre Caron | 341ff85 | 2015-06-06 20:14:31 -0400 | [diff] [blame] | 1103 | :returns: A new |
| 1104 | :class:`~cryptography.x509.CertificateSigningRequest`. |
Andre Caron | 0ef595f | 2015-05-18 13:53:43 -0400 | [diff] [blame] | 1105 | |
| 1106 | |
Paul Kehrer | 719d536 | 2015-01-01 20:03:52 -0600 | [diff] [blame] | 1107 | .. class:: Name |
| 1108 | |
| 1109 | .. versionadded:: 0.8 |
| 1110 | |
Paul Kehrer | 53d8d49 | 2015-02-13 18:47:30 -0600 | [diff] [blame] | 1111 | 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] | 1112 | 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] | 1113 | obtain the specific type you want. Names are sometimes represented as a |
Paul Kehrer | 53d8d49 | 2015-02-13 18:47:30 -0600 | [diff] [blame] | 1114 | slash or comma delimited string (e.g. ``/CN=mydomain.com/O=My Org/C=US`` or |
| 1115 | ``CN=mydomain.com, O=My Org, C=US``). |
Paul Kehrer | 719d536 | 2015-01-01 20:03:52 -0600 | [diff] [blame] | 1116 | |
Fraser Tweedale | 01ee6f5 | 2016-11-12 01:28:56 +1000 | [diff] [blame] | 1117 | Technically, a Name is a list of *sets* of attributes, called *Relative |
| 1118 | Distinguished Names* or *RDNs*, although multi-valued RDNs are rarely |
| 1119 | encountered. The iteration order of values within a multi-valued RDN is |
| 1120 | undefined. If you need to handle multi-valued RDNs, the ``rdns`` property |
| 1121 | gives access to an ordered list of :class:`RelativeDistinguishedName` |
| 1122 | objects. |
| 1123 | |
| 1124 | A Name can be initialized with an iterable of :class:`NameAttribute` (the |
| 1125 | common case where each RDN has a single attribute) or an iterable of |
| 1126 | :class:`RelativeDistinguishedName` objects (in the rare case of |
| 1127 | multi-valued RDNs). |
| 1128 | |
Paul Kehrer | 53d8d49 | 2015-02-13 18:47:30 -0600 | [diff] [blame] | 1129 | .. doctest:: |
Paul Kehrer | 719d536 | 2015-01-01 20:03:52 -0600 | [diff] [blame] | 1130 | |
Paul Kehrer | 8b21a4a | 2015-02-14 07:56:36 -0600 | [diff] [blame] | 1131 | >>> len(cert.subject) |
Paul Kehrer | 53d8d49 | 2015-02-13 18:47:30 -0600 | [diff] [blame] | 1132 | 3 |
Paul Kehrer | 8b21a4a | 2015-02-14 07:56:36 -0600 | [diff] [blame] | 1133 | >>> for attribute in cert.subject: |
| 1134 | ... print(attribute) |
| 1135 | <NameAttribute(oid=<ObjectIdentifier(oid=2.5.4.6, name=countryName)>, value=u'US')> |
| 1136 | <NameAttribute(oid=<ObjectIdentifier(oid=2.5.4.10, name=organizationName)>, value=u'Test Certificates 2011')> |
| 1137 | <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] | 1138 | |
Fraser Tweedale | 01ee6f5 | 2016-11-12 01:28:56 +1000 | [diff] [blame] | 1139 | .. attribute:: rdns |
| 1140 | |
| 1141 | .. versionadded:: 1.6 |
| 1142 | |
| 1143 | :type: list of :class:`RelativeDistinguishedName` |
| 1144 | |
Paul Kehrer | e901d64 | 2015-02-11 18:50:58 -0600 | [diff] [blame] | 1145 | .. method:: get_attributes_for_oid(oid) |
Paul Kehrer | 719d536 | 2015-01-01 20:03:52 -0600 | [diff] [blame] | 1146 | |
Paul Kehrer | e901d64 | 2015-02-11 18:50:58 -0600 | [diff] [blame] | 1147 | :param oid: An :class:`ObjectIdentifier` instance. |
Paul Kehrer | 719d536 | 2015-01-01 20:03:52 -0600 | [diff] [blame] | 1148 | |
Paul Kehrer | e901d64 | 2015-02-11 18:50:58 -0600 | [diff] [blame] | 1149 | :returns: A list of :class:`NameAttribute` instances that match the |
| 1150 | OID provided. If nothing matches an empty list will be returned. |
Paul Kehrer | 719d536 | 2015-01-01 20:03:52 -0600 | [diff] [blame] | 1151 | |
| 1152 | .. doctest:: |
| 1153 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1154 | >>> cert.subject.get_attributes_for_oid(NameOID.COMMON_NAME) |
Paul Kehrer | e901d64 | 2015-02-11 18:50:58 -0600 | [diff] [blame] | 1155 | [<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] | 1156 | |
Paul Kehrer | 3a15b03 | 2016-11-13 14:30:11 -0800 | [diff] [blame] | 1157 | .. method:: public_bytes(backend) |
| 1158 | |
| 1159 | .. versionadded:: 1.6 |
| 1160 | |
| 1161 | :param backend: A backend supporting the |
| 1162 | :class:`~cryptography.hazmat.backends.interfaces.X509Backend` |
| 1163 | interface. |
| 1164 | |
| 1165 | :return bytes: The DER encoded name. |
| 1166 | |
Paul Kehrer | e76cd27 | 2014-12-14 19:00:51 -0600 | [diff] [blame] | 1167 | .. class:: Version |
Paul Kehrer | 016e08a | 2014-11-26 09:41:18 -1000 | [diff] [blame] | 1168 | |
| 1169 | .. versionadded:: 0.7 |
| 1170 | |
| 1171 | An enumeration for X.509 versions. |
| 1172 | |
| 1173 | .. attribute:: v1 |
| 1174 | |
| 1175 | For version 1 X.509 certificates. |
| 1176 | |
| 1177 | .. attribute:: v3 |
| 1178 | |
| 1179 | For version 3 X.509 certificates. |
| 1180 | |
Paul Kehrer | 806bfb2 | 2015-02-02 17:05:24 -0600 | [diff] [blame] | 1181 | .. class:: NameAttribute |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 1182 | |
| 1183 | .. versionadded:: 0.8 |
| 1184 | |
Fraser Tweedale | 01ee6f5 | 2016-11-12 01:28:56 +1000 | [diff] [blame] | 1185 | An X.509 name consists of a list of :class:`RelativeDistinguishedName` |
| 1186 | instances, which consist of a set of :class:`NameAttribute` instances. |
Paul Kehrer | 5b0a8d6 | 2015-01-30 20:05:55 -0600 | [diff] [blame] | 1187 | |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 1188 | .. attribute:: oid |
| 1189 | |
| 1190 | :type: :class:`ObjectIdentifier` |
| 1191 | |
| 1192 | The attribute OID. |
| 1193 | |
| 1194 | .. attribute:: value |
| 1195 | |
Paul Kehrer | d5852cb | 2015-01-30 08:25:23 -0600 | [diff] [blame] | 1196 | :type: :term:`text` |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 1197 | |
| 1198 | The value of the attribute. |
| 1199 | |
Fraser Tweedale | 02467dd | 2016-11-07 15:54:04 +1000 | [diff] [blame] | 1200 | |
| 1201 | .. class:: RelativeDistinguishedName(attributes) |
| 1202 | |
| 1203 | .. versionadded:: 1.6 |
| 1204 | |
| 1205 | A relative distinguished name is a non-empty set of name attributes. The |
| 1206 | object is iterable to get every attribute. |
| 1207 | |
| 1208 | .. method:: get_attributes_for_oid(oid) |
| 1209 | |
| 1210 | :param oid: An :class:`ObjectIdentifier` instance. |
| 1211 | |
| 1212 | :returns: A list of :class:`NameAttribute` instances that match the OID |
| 1213 | provided. The list should contain zero or one values. |
| 1214 | |
| 1215 | |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 1216 | .. class:: ObjectIdentifier |
| 1217 | |
| 1218 | .. versionadded:: 0.8 |
| 1219 | |
Paul Kehrer | 5b0a8d6 | 2015-01-30 20:05:55 -0600 | [diff] [blame] | 1220 | Object identifiers (frequently seen abbreviated as OID) identify the type |
Paul Kehrer | 806bfb2 | 2015-02-02 17:05:24 -0600 | [diff] [blame] | 1221 | of a value (see: :class:`NameAttribute`). |
Paul Kehrer | 5b0a8d6 | 2015-01-30 20:05:55 -0600 | [diff] [blame] | 1222 | |
Paul Kehrer | d44f9a6 | 2015-02-04 14:47:34 -0600 | [diff] [blame] | 1223 | .. attribute:: dotted_string |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 1224 | |
| 1225 | :type: :class:`str` |
| 1226 | |
Paul Kehrer | fedf4f4 | 2015-02-06 11:22:07 -0600 | [diff] [blame] | 1227 | 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] | 1228 | |
Paul Kehrer | 31bdf79 | 2015-03-25 14:11:00 -0500 | [diff] [blame] | 1229 | .. _general_name_classes: |
| 1230 | |
| 1231 | General Name Classes |
| 1232 | ~~~~~~~~~~~~~~~~~~~~ |
| 1233 | |
| 1234 | .. class:: GeneralName |
| 1235 | |
| 1236 | .. versionadded:: 0.9 |
| 1237 | |
| 1238 | This is the generic interface that all the following classes are registered |
| 1239 | against. |
| 1240 | |
Paul Kehrer | 47c32ba | 2015-10-28 09:12:07 +0900 | [diff] [blame] | 1241 | .. class:: RFC822Name(value) |
Paul Kehrer | 31bdf79 | 2015-03-25 14:11:00 -0500 | [diff] [blame] | 1242 | |
| 1243 | .. versionadded:: 0.9 |
| 1244 | |
Paul Kehrer | 3e15ca5 | 2017-08-01 21:21:19 -0500 | [diff] [blame] | 1245 | ..note:: |
| 1246 | |
| 1247 | Starting with version 2.1 unicode input is deprecated. If passing an |
Paul Kehrer | 1b86dc5 | 2017-09-20 23:42:34 +0800 | [diff] [blame] | 1248 | email address containing an internationalized domain name (IDN) you |
| 1249 | should first IDNA encode the hostname and then pass the resulting |
| 1250 | bytes. |
| 1251 | |
| 1252 | This corresponds to an email address. For example, ``user@example.com``. |
| 1253 | |
| 1254 | :param bytes value: The email address. If the address contains an |
| 1255 | internationalized domain name then it must be encoded to an |
| 1256 | :term:`A-label` before being passed. |
Paul Kehrer | 3e15ca5 | 2017-08-01 21:21:19 -0500 | [diff] [blame] | 1257 | |
| 1258 | .. attribute:: bytes_value |
| 1259 | |
| 1260 | .. versionadded:: 2.1 |
| 1261 | |
| 1262 | :type: bytes |
| 1263 | |
Paul Kehrer | 1b86dc5 | 2017-09-20 23:42:34 +0800 | [diff] [blame] | 1264 | The value as a byte string. This will contain an :term:`A-label` if |
| 1265 | the domain in the address is an internationalized domain name. |
| 1266 | |
Paul Kehrer | 31bdf79 | 2015-03-25 14:11:00 -0500 | [diff] [blame] | 1267 | .. attribute:: value |
| 1268 | |
Paul Kehrer | 3e15ca5 | 2017-08-01 21:21:19 -0500 | [diff] [blame] | 1269 | .. deprecated:: 2.1 |
| 1270 | |
| 1271 | Deprecated accessor for the idna-decoded value of :attr:`bytes_value` |
| 1272 | |
Paul Kehrer | 31bdf79 | 2015-03-25 14:11:00 -0500 | [diff] [blame] | 1273 | :type: :term:`text` |
| 1274 | |
Paul Kehrer | 47c32ba | 2015-10-28 09:12:07 +0900 | [diff] [blame] | 1275 | .. class:: DNSName(value) |
Paul Kehrer | 31bdf79 | 2015-03-25 14:11:00 -0500 | [diff] [blame] | 1276 | |
| 1277 | .. versionadded:: 0.9 |
| 1278 | |
Paul Kehrer | 1b86dc5 | 2017-09-20 23:42:34 +0800 | [diff] [blame] | 1279 | ..note:: |
| 1280 | |
| 1281 | Starting with version 2.1 unicode input is deprecated. If passing an |
| 1282 | internationalized domain name (IDN) you should first IDNA encode the |
| 1283 | hostname and then pass the resulting bytes. |
| 1284 | |
Paul Kehrer | 31bdf79 | 2015-03-25 14:11:00 -0500 | [diff] [blame] | 1285 | This corresponds to a domain name. For example, ``cryptography.io``. |
| 1286 | |
Paul Kehrer | 1b86dc5 | 2017-09-20 23:42:34 +0800 | [diff] [blame] | 1287 | :param bytes value: The domain name. If it is an internationalized domain |
| 1288 | name then it must be encoded to an :term:`A-label` before being passed. |
| 1289 | |
Alex Gaynor | cdaf3ff | 2017-07-30 13:08:51 -0400 | [diff] [blame] | 1290 | .. attribute:: bytes_value |
| 1291 | |
Paul Kehrer | 908bbd3 | 2017-08-01 11:39:21 -0500 | [diff] [blame] | 1292 | .. versionadded:: 2.1 |
| 1293 | |
Alex Gaynor | cdaf3ff | 2017-07-30 13:08:51 -0400 | [diff] [blame] | 1294 | :type: bytes |
| 1295 | |
Paul Kehrer | 1b86dc5 | 2017-09-20 23:42:34 +0800 | [diff] [blame] | 1296 | The value as a byte string. This will contain an :term:`A-label` if |
| 1297 | it is an internationalized domain name. |
| 1298 | |
Paul Kehrer | 31bdf79 | 2015-03-25 14:11:00 -0500 | [diff] [blame] | 1299 | .. attribute:: value |
| 1300 | |
Paul Kehrer | 908bbd3 | 2017-08-01 11:39:21 -0500 | [diff] [blame] | 1301 | .. deprecated:: 2.1 |
| 1302 | |
Alex Gaynor | cdaf3ff | 2017-07-30 13:08:51 -0400 | [diff] [blame] | 1303 | Deprecated accessor for the idna-decoded value of :attr:`bytes_value` |
| 1304 | |
Paul Kehrer | 31bdf79 | 2015-03-25 14:11:00 -0500 | [diff] [blame] | 1305 | :type: :term:`text` |
| 1306 | |
Paul Kehrer | 47c32ba | 2015-10-28 09:12:07 +0900 | [diff] [blame] | 1307 | .. class:: DirectoryName(value) |
Paul Kehrer | 31bdf79 | 2015-03-25 14:11:00 -0500 | [diff] [blame] | 1308 | |
| 1309 | .. versionadded:: 0.9 |
| 1310 | |
| 1311 | This corresponds to a directory name. |
| 1312 | |
| 1313 | .. attribute:: value |
| 1314 | |
| 1315 | :type: :class:`Name` |
| 1316 | |
Paul Kehrer | 47c32ba | 2015-10-28 09:12:07 +0900 | [diff] [blame] | 1317 | .. class:: UniformResourceIdentifier(value) |
Paul Kehrer | 31bdf79 | 2015-03-25 14:11:00 -0500 | [diff] [blame] | 1318 | |
| 1319 | .. versionadded:: 0.9 |
| 1320 | |
Paul Kehrer | 6c29d74 | 2017-08-01 19:27:06 -0500 | [diff] [blame] | 1321 | ..note:: |
Paul Kehrer | b8ef82e | 2015-04-22 16:04:24 -0500 | [diff] [blame] | 1322 | |
Paul Kehrer | 6c29d74 | 2017-08-01 19:27:06 -0500 | [diff] [blame] | 1323 | Starting with version 2.1 unicode input is deprecated. If passing an |
Paul Kehrer | 1b86dc5 | 2017-09-20 23:42:34 +0800 | [diff] [blame] | 1324 | internationalized domain name (IDN) within the URI you should first |
| 1325 | IDNA encode the hostname and then pass the resulting bytes. |
| 1326 | |
| 1327 | This corresponds to a uniform resource identifier. For example, |
| 1328 | ``https://cryptography.io``. |
| 1329 | |
| 1330 | :param bytes value: The URI. If it contains an internationalized domain |
| 1331 | name then it must be encoded to an :term:`A-label` before being passed. |
Paul Kehrer | 6c29d74 | 2017-08-01 19:27:06 -0500 | [diff] [blame] | 1332 | |
| 1333 | .. attribute:: bytes_value |
| 1334 | |
| 1335 | .. versionadded:: 2.1 |
| 1336 | |
| 1337 | :type: bytes |
Paul Kehrer | 31bdf79 | 2015-03-25 14:11:00 -0500 | [diff] [blame] | 1338 | |
Paul Kehrer | 1b86dc5 | 2017-09-20 23:42:34 +0800 | [diff] [blame] | 1339 | The value as a byte string. This will contain an :term:`A-label` if |
| 1340 | the URI contains an internationalized domain name. |
| 1341 | |
Paul Kehrer | 31bdf79 | 2015-03-25 14:11:00 -0500 | [diff] [blame] | 1342 | .. attribute:: value |
| 1343 | |
Paul Kehrer | 6c29d74 | 2017-08-01 19:27:06 -0500 | [diff] [blame] | 1344 | .. deprecated:: 2.1 |
| 1345 | |
| 1346 | Deprecated accessor for the idna-decoded value of :attr:`bytes_value` |
| 1347 | |
Paul Kehrer | 31bdf79 | 2015-03-25 14:11:00 -0500 | [diff] [blame] | 1348 | :type: :term:`text` |
| 1349 | |
Paul Kehrer | 47c32ba | 2015-10-28 09:12:07 +0900 | [diff] [blame] | 1350 | .. class:: IPAddress(value) |
Paul Kehrer | 31bdf79 | 2015-03-25 14:11:00 -0500 | [diff] [blame] | 1351 | |
| 1352 | .. versionadded:: 0.9 |
| 1353 | |
| 1354 | This corresponds to an IP address. |
| 1355 | |
| 1356 | .. attribute:: value |
| 1357 | |
Paul Kehrer | eb17793 | 2015-05-17 18:33:33 -0700 | [diff] [blame] | 1358 | :type: :class:`~ipaddress.IPv4Address`, |
| 1359 | :class:`~ipaddress.IPv6Address`, :class:`~ipaddress.IPv4Network`, |
| 1360 | or :class:`~ipaddress.IPv6Network`. |
Paul Kehrer | 31bdf79 | 2015-03-25 14:11:00 -0500 | [diff] [blame] | 1361 | |
Paul Kehrer | 47c32ba | 2015-10-28 09:12:07 +0900 | [diff] [blame] | 1362 | .. class:: RegisteredID(value) |
Paul Kehrer | 31bdf79 | 2015-03-25 14:11:00 -0500 | [diff] [blame] | 1363 | |
| 1364 | .. versionadded:: 0.9 |
| 1365 | |
| 1366 | This corresponds to a registered ID. |
| 1367 | |
| 1368 | .. attribute:: value |
| 1369 | |
| 1370 | :type: :class:`ObjectIdentifier` |
| 1371 | |
Paul Kehrer | 47c32ba | 2015-10-28 09:12:07 +0900 | [diff] [blame] | 1372 | .. class:: OtherName(type_id, value) |
Joshua Tauberer | 2ee5e3c | 2015-07-04 20:09:46 +0000 | [diff] [blame] | 1373 | |
| 1374 | .. versionadded:: 1.0 |
| 1375 | |
Joshua Tauberer | 18b6fc8 | 2015-07-05 21:44:51 +0000 | [diff] [blame] | 1376 | 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] | 1377 | |
| 1378 | .. attribute:: type_id |
| 1379 | |
| 1380 | :type: :class:`ObjectIdentifier` |
| 1381 | |
| 1382 | .. attribute:: value |
| 1383 | |
| 1384 | :type: `bytes` |
| 1385 | |
Paul Kehrer | 8cf2642 | 2015-03-21 09:50:24 -0500 | [diff] [blame] | 1386 | X.509 Extensions |
| 1387 | ~~~~~~~~~~~~~~~~ |
| 1388 | |
Paul Kehrer | fbb7ac8 | 2015-03-16 19:26:29 -0500 | [diff] [blame] | 1389 | .. class:: Extensions |
| 1390 | |
| 1391 | .. versionadded:: 0.9 |
| 1392 | |
| 1393 | An X.509 Extensions instance is an ordered list of extensions. The object |
| 1394 | is iterable to get every extension. |
| 1395 | |
Paul Kehrer | fa56a23 | 2015-03-17 13:14:03 -0500 | [diff] [blame] | 1396 | .. method:: get_extension_for_oid(oid) |
| 1397 | |
| 1398 | :param oid: An :class:`ObjectIdentifier` instance. |
| 1399 | |
| 1400 | :returns: An instance of the extension class. |
| 1401 | |
| 1402 | :raises cryptography.x509.ExtensionNotFound: If the certificate does |
| 1403 | not have the extension requested. |
| 1404 | |
Paul Kehrer | fa56a23 | 2015-03-17 13:14:03 -0500 | [diff] [blame] | 1405 | .. doctest:: |
| 1406 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1407 | >>> from cryptography.x509.oid import ExtensionOID |
| 1408 | >>> cert.extensions.get_extension_for_oid(ExtensionOID.BASIC_CONSTRAINTS) |
Paul Kehrer | fa56a23 | 2015-03-17 13:14:03 -0500 | [diff] [blame] | 1409 | <Extension(oid=<ObjectIdentifier(oid=2.5.29.19, name=basicConstraints)>, critical=True, value=<BasicConstraints(ca=True, path_length=None)>)> |
| 1410 | |
Phoebe Queen | 019b7f8 | 2015-08-12 03:52:03 +0100 | [diff] [blame] | 1411 | .. method:: get_extension_for_class(extclass) |
| 1412 | |
Phoebe Queen | 6a603eb | 2015-08-12 14:14:49 +0100 | [diff] [blame] | 1413 | .. versionadded:: 1.1 |
| 1414 | |
Phoebe Queen | 019b7f8 | 2015-08-12 03:52:03 +0100 | [diff] [blame] | 1415 | :param extclass: An extension class. |
| 1416 | |
| 1417 | :returns: An instance of the extension class. |
| 1418 | |
| 1419 | :raises cryptography.x509.ExtensionNotFound: If the certificate does |
| 1420 | not have the extension requested. |
| 1421 | |
| 1422 | .. doctest:: |
| 1423 | |
| 1424 | >>> from cryptography import x509 |
| 1425 | >>> cert.extensions.get_extension_for_class(x509.BasicConstraints) |
| 1426 | <Extension(oid=<ObjectIdentifier(oid=2.5.29.19, name=basicConstraints)>, critical=True, value=<BasicConstraints(ca=True, path_length=None)>)> |
| 1427 | |
Paul Kehrer | 8cf2642 | 2015-03-21 09:50:24 -0500 | [diff] [blame] | 1428 | .. class:: Extension |
| 1429 | |
| 1430 | .. versionadded:: 0.9 |
| 1431 | |
Paul Kehrer | 8589466 | 2015-03-22 13:19:31 -0500 | [diff] [blame] | 1432 | .. attribute:: oid |
| 1433 | |
| 1434 | :type: :class:`ObjectIdentifier` |
| 1435 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1436 | One of the :class:`~cryptography.x509.oid.ExtensionOID` OIDs. |
Paul Kehrer | 8cf2642 | 2015-03-21 09:50:24 -0500 | [diff] [blame] | 1437 | |
| 1438 | .. attribute:: critical |
| 1439 | |
| 1440 | :type: bool |
| 1441 | |
Paul Kehrer | 58b7569 | 2015-03-22 23:24:58 -0500 | [diff] [blame] | 1442 | Determines whether a given extension is critical or not. :rfc:`5280` |
| 1443 | requires that "A certificate-using system MUST reject the certificate |
| 1444 | if it encounters a critical extension it does not recognize or a |
| 1445 | critical extension that contains information that it cannot process". |
Paul Kehrer | 8cf2642 | 2015-03-21 09:50:24 -0500 | [diff] [blame] | 1446 | |
Paul Kehrer | 8589466 | 2015-03-22 13:19:31 -0500 | [diff] [blame] | 1447 | .. attribute:: value |
| 1448 | |
| 1449 | Returns an instance of the extension type corresponding to the OID. |
| 1450 | |
Paul Kehrer | 14f0bd0 | 2015-08-06 11:55:18 +0100 | [diff] [blame] | 1451 | .. class:: ExtensionType |
| 1452 | |
| 1453 | .. versionadded:: 1.0 |
| 1454 | |
| 1455 | This is the interface against which all the following extension types are |
| 1456 | registered. |
| 1457 | |
Paul Kehrer | 47c32ba | 2015-10-28 09:12:07 +0900 | [diff] [blame] | 1458 | .. 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] | 1459 | |
| 1460 | .. versionadded:: 0.9 |
| 1461 | |
| 1462 | The key usage extension defines the purpose of the key contained in the |
| 1463 | certificate. The usage restriction might be employed when a key that could |
Paul Kehrer | b33de93 | 2015-08-06 23:41:05 +0100 | [diff] [blame] | 1464 | be used for more than one operation is to be restricted. |
Paul Kehrer | cecbbba | 2015-03-30 14:58:38 -0500 | [diff] [blame] | 1465 | |
Paul Kehrer | 822f3d3 | 2015-08-06 11:47:32 +0100 | [diff] [blame] | 1466 | .. attribute:: oid |
| 1467 | |
| 1468 | .. versionadded:: 1.0 |
| 1469 | |
| 1470 | :type: :class:`ObjectIdentifier` |
| 1471 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1472 | Returns :attr:`~cryptography.x509.oid.ExtensionOID.KEY_USAGE`. |
Paul Kehrer | 822f3d3 | 2015-08-06 11:47:32 +0100 | [diff] [blame] | 1473 | |
Paul Kehrer | cecbbba | 2015-03-30 14:58:38 -0500 | [diff] [blame] | 1474 | .. attribute:: digital_signature |
| 1475 | |
| 1476 | :type: bool |
| 1477 | |
Paul Kehrer | 738407b | 2015-04-01 22:39:02 -0500 | [diff] [blame] | 1478 | 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] | 1479 | digital signatures, other than signatures on certificates |
| 1480 | (``key_cert_sign``) and CRLs (``crl_sign``). |
| 1481 | |
| 1482 | .. attribute:: content_commitment |
| 1483 | |
| 1484 | :type: bool |
| 1485 | |
Paul Kehrer | 738407b | 2015-04-01 22:39:02 -0500 | [diff] [blame] | 1486 | 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] | 1487 | digital signatures, other than signatures on certificates |
| 1488 | (``key_cert_sign``) and CRLs (``crl_sign``). It is used to provide a |
| 1489 | non-repudiation service that protects against the signing entity |
| 1490 | falsely denying some action. In the case of later conflict, a |
| 1491 | reliable third party may determine the authenticity of the signed |
| 1492 | data. This was called ``non_repudiation`` in older revisions of the |
| 1493 | X.509 specification. |
| 1494 | |
| 1495 | .. attribute:: key_encipherment |
| 1496 | |
| 1497 | :type: bool |
| 1498 | |
Paul Kehrer | 738407b | 2015-04-01 22:39:02 -0500 | [diff] [blame] | 1499 | This purpose is set to true when the subject public key is used for |
| 1500 | enciphering private or secret keys. |
Paul Kehrer | cecbbba | 2015-03-30 14:58:38 -0500 | [diff] [blame] | 1501 | |
| 1502 | .. attribute:: data_encipherment |
| 1503 | |
| 1504 | :type: bool |
| 1505 | |
Paul Kehrer | 738407b | 2015-04-01 22:39:02 -0500 | [diff] [blame] | 1506 | This purpose is set to true when the subject public key is used for |
| 1507 | directly enciphering raw user data without the use of an intermediate |
| 1508 | symmetric cipher. |
Paul Kehrer | cecbbba | 2015-03-30 14:58:38 -0500 | [diff] [blame] | 1509 | |
| 1510 | .. attribute:: key_agreement |
| 1511 | |
| 1512 | :type: bool |
| 1513 | |
Paul Kehrer | 738407b | 2015-04-01 22:39:02 -0500 | [diff] [blame] | 1514 | This purpose is set to true when the subject public key is used for key |
| 1515 | agreement. For example, when a Diffie-Hellman key is to be used for |
| 1516 | key management, then this purpose is set to true. |
Paul Kehrer | cecbbba | 2015-03-30 14:58:38 -0500 | [diff] [blame] | 1517 | |
| 1518 | .. attribute:: key_cert_sign |
| 1519 | |
| 1520 | :type: bool |
| 1521 | |
Paul Kehrer | 738407b | 2015-04-01 22:39:02 -0500 | [diff] [blame] | 1522 | This purpose is set to true when the subject public key is used for |
| 1523 | verifying signatures on public key certificates. If this purpose is set |
| 1524 | to true then ``ca`` must be true in the :class:`BasicConstraints` |
| 1525 | extension. |
Paul Kehrer | cecbbba | 2015-03-30 14:58:38 -0500 | [diff] [blame] | 1526 | |
| 1527 | .. attribute:: crl_sign |
| 1528 | |
| 1529 | :type: bool |
| 1530 | |
Paul Kehrer | 738407b | 2015-04-01 22:39:02 -0500 | [diff] [blame] | 1531 | This purpose is set to true when the subject public key is used for |
| 1532 | verifying signatures on certificate revocation lists. |
Paul Kehrer | cecbbba | 2015-03-30 14:58:38 -0500 | [diff] [blame] | 1533 | |
| 1534 | .. attribute:: encipher_only |
| 1535 | |
| 1536 | :type: bool |
| 1537 | |
Paul Kehrer | 738407b | 2015-04-01 22:39:02 -0500 | [diff] [blame] | 1538 | When this purposes is set to true and the ``key_agreement`` purpose is |
| 1539 | also set, the subject public key may be used only for enciphering data |
| 1540 | while performing key agreement. |
Paul Kehrer | cecbbba | 2015-03-30 14:58:38 -0500 | [diff] [blame] | 1541 | |
| 1542 | :raises ValueError: This is raised if accessed when ``key_agreement`` |
| 1543 | is false. |
| 1544 | |
| 1545 | .. attribute:: decipher_only |
| 1546 | |
| 1547 | :type: bool |
| 1548 | |
Paul Kehrer | 738407b | 2015-04-01 22:39:02 -0500 | [diff] [blame] | 1549 | When this purposes is set to true and the ``key_agreement`` purpose is |
| 1550 | also set, the subject public key may be used only for deciphering data |
| 1551 | while performing key agreement. |
Paul Kehrer | cecbbba | 2015-03-30 14:58:38 -0500 | [diff] [blame] | 1552 | |
| 1553 | :raises ValueError: This is raised if accessed when ``key_agreement`` |
| 1554 | is false. |
| 1555 | |
| 1556 | |
Paul Kehrer | 47c32ba | 2015-10-28 09:12:07 +0900 | [diff] [blame] | 1557 | .. class:: BasicConstraints(ca, path_length) |
Paul Kehrer | 8cf2642 | 2015-03-21 09:50:24 -0500 | [diff] [blame] | 1558 | |
| 1559 | .. versionadded:: 0.9 |
| 1560 | |
Paul Kehrer | 8589466 | 2015-03-22 13:19:31 -0500 | [diff] [blame] | 1561 | 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] | 1562 | certificate is allowed to sign additional certificates and what path |
Paul Kehrer | b33de93 | 2015-08-06 23:41:05 +0100 | [diff] [blame] | 1563 | length restrictions may exist. |
Paul Kehrer | 8cf2642 | 2015-03-21 09:50:24 -0500 | [diff] [blame] | 1564 | |
Paul Kehrer | 822f3d3 | 2015-08-06 11:47:32 +0100 | [diff] [blame] | 1565 | .. attribute:: oid |
| 1566 | |
| 1567 | .. versionadded:: 1.0 |
| 1568 | |
| 1569 | :type: :class:`ObjectIdentifier` |
| 1570 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1571 | Returns :attr:`~cryptography.x509.oid.ExtensionOID.BASIC_CONSTRAINTS`. |
Paul Kehrer | 822f3d3 | 2015-08-06 11:47:32 +0100 | [diff] [blame] | 1572 | |
Paul Kehrer | 8cf2642 | 2015-03-21 09:50:24 -0500 | [diff] [blame] | 1573 | .. attribute:: ca |
| 1574 | |
| 1575 | :type: bool |
| 1576 | |
| 1577 | Whether the certificate can sign certificates. |
| 1578 | |
| 1579 | .. attribute:: path_length |
| 1580 | |
Paul Kehrer | fd1444c | 2015-03-21 19:47:05 -0500 | [diff] [blame] | 1581 | :type: int or None |
Paul Kehrer | 8cf2642 | 2015-03-21 09:50:24 -0500 | [diff] [blame] | 1582 | |
| 1583 | The maximum path length for certificates subordinate to this |
| 1584 | certificate. This attribute only has meaning if ``ca`` is true. |
| 1585 | If ``ca`` is true then a path length of None means there's no |
| 1586 | restriction on the number of subordinate CAs in the certificate chain. |
Alex Gaynor | 99c5f15 | 2015-05-03 10:01:04 -0400 | [diff] [blame] | 1587 | If it is zero or greater then it defines the maximum length for a |
| 1588 | subordinate CA's certificate chain. For example, a ``path_length`` of 1 |
| 1589 | means the certificate can sign a subordinate CA, but the subordinate CA |
| 1590 | is not allowed to create subordinates with ``ca`` set to true. |
Paul Kehrer | 8cf2642 | 2015-03-21 09:50:24 -0500 | [diff] [blame] | 1591 | |
Paul Kehrer | 47c32ba | 2015-10-28 09:12:07 +0900 | [diff] [blame] | 1592 | .. class:: ExtendedKeyUsage(usages) |
Paul Kehrer | ffa2a15 | 2015-03-31 08:18:25 -0500 | [diff] [blame] | 1593 | |
| 1594 | .. versionadded:: 0.9 |
| 1595 | |
| 1596 | This extension indicates one or more purposes for which the certified |
| 1597 | public key may be used, in addition to or in place of the basic |
| 1598 | purposes indicated in the key usage extension. The object is |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1599 | iterable to obtain the list of |
| 1600 | :class:`~cryptography.x509.oid.ExtendedKeyUsageOID` OIDs present. |
Paul Kehrer | ffa2a15 | 2015-03-31 08:18:25 -0500 | [diff] [blame] | 1601 | |
Paul Kehrer | 1cb9e55 | 2015-10-28 09:37:29 +0900 | [diff] [blame] | 1602 | :param list usages: A list of |
Paul Kehrer | 47c32ba | 2015-10-28 09:12:07 +0900 | [diff] [blame] | 1603 | :class:`~cryptography.x509.oid.ExtendedKeyUsageOID` OIDs. |
| 1604 | |
Paul Kehrer | 822f3d3 | 2015-08-06 11:47:32 +0100 | [diff] [blame] | 1605 | .. attribute:: oid |
| 1606 | |
| 1607 | .. versionadded:: 1.0 |
| 1608 | |
| 1609 | :type: :class:`ObjectIdentifier` |
| 1610 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1611 | Returns :attr:`~cryptography.x509.oid.ExtensionOID.EXTENDED_KEY_USAGE`. |
Paul Kehrer | 822f3d3 | 2015-08-06 11:47:32 +0100 | [diff] [blame] | 1612 | |
| 1613 | |
Paul Kehrer | 47c32ba | 2015-10-28 09:12:07 +0900 | [diff] [blame] | 1614 | .. class:: OCSPNoCheck() |
Paul Kehrer | 4a1038e | 2015-05-18 10:28:31 -0700 | [diff] [blame] | 1615 | |
Paul Kehrer | 506a215 | 2015-05-26 08:01:18 -0500 | [diff] [blame] | 1616 | .. versionadded:: 1.0 |
Paul Kehrer | 4a1038e | 2015-05-18 10:28:31 -0700 | [diff] [blame] | 1617 | |
| 1618 | This presence of this extension indicates that an OCSP client can trust a |
| 1619 | responder for the lifetime of the responder's certificate. CAs issuing |
| 1620 | such a certificate should realize that a compromise of the responder's key |
| 1621 | is as serious as the compromise of a CA key used to sign CRLs, at least for |
| 1622 | the validity period of this certificate. CA's may choose to issue this type |
| 1623 | of certificate with a very short lifetime and renew it frequently. This |
| 1624 | extension is only relevant when the certificate is an authorized OCSP |
| 1625 | responder. |
| 1626 | |
Paul Kehrer | 822f3d3 | 2015-08-06 11:47:32 +0100 | [diff] [blame] | 1627 | .. attribute:: oid |
| 1628 | |
| 1629 | .. versionadded:: 1.0 |
| 1630 | |
| 1631 | :type: :class:`ObjectIdentifier` |
| 1632 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1633 | Returns :attr:`~cryptography.x509.oid.ExtensionOID.OCSP_NO_CHECK`. |
Paul Kehrer | 822f3d3 | 2015-08-06 11:47:32 +0100 | [diff] [blame] | 1634 | |
Paul Kehrer | 5d66966 | 2017-09-11 09:16:34 +0800 | [diff] [blame] | 1635 | |
| 1636 | .. class:: TLSFeature(features) |
| 1637 | |
| 1638 | .. versionadded:: 2.1 |
| 1639 | |
| 1640 | The TLS Feature extension is defined in :rfc:`7633` and is used in |
| 1641 | certificates for OCSP Must-Staple. The object is iterable to get every |
| 1642 | element. |
| 1643 | |
| 1644 | :param list features: A list of features to enable from the |
| 1645 | :class:`~cryptography.x509.TLSFeatureType` enum. At this time only |
| 1646 | ``status_request`` or ``status_request_v2`` are allowed. |
| 1647 | |
| 1648 | .. attribute:: oid |
| 1649 | |
| 1650 | :type: :class:`ObjectIdentifier` |
| 1651 | |
| 1652 | Returns :attr:`~cryptography.x509.oid.ExtensionOID.TLS_FEATURE`. |
| 1653 | |
| 1654 | .. class:: TLSFeatureType |
| 1655 | |
| 1656 | .. versionadded:: 2.1 |
| 1657 | |
| 1658 | An enumeration of TLS Feature types. |
| 1659 | |
| 1660 | .. attribute:: status_request |
| 1661 | |
| 1662 | This feature type is defined in :rfc:`6066` and, when embedded in |
| 1663 | an X.509 certificate, signals to the client that it should require |
| 1664 | a stapled OCSP response in the TLS handshake. Commonly known as OCSP |
| 1665 | Must-Staple in certificates. |
| 1666 | |
| 1667 | .. attribute:: status_request_v2 |
| 1668 | |
| 1669 | This feature type is defined in :rfc:`6961`. This value is not |
| 1670 | commonly used and if you want to enable OCSP Must-Staple you should |
| 1671 | use ``status_request``. |
| 1672 | |
| 1673 | |
Paul Kehrer | 47c32ba | 2015-10-28 09:12:07 +0900 | [diff] [blame] | 1674 | .. class:: NameConstraints(permitted_subtrees, excluded_subtrees) |
Paul Kehrer | e0017be | 2015-05-17 20:39:40 -0600 | [diff] [blame] | 1675 | |
| 1676 | .. versionadded:: 1.0 |
| 1677 | |
| 1678 | The name constraints extension, which only has meaning in a CA certificate, |
| 1679 | defines a name space within which all subject names in certificates issued |
| 1680 | beneath the CA certificate must (or must not) be in. For specific details |
| 1681 | on the way this extension should be processed see :rfc:`5280`. |
| 1682 | |
Paul Kehrer | 822f3d3 | 2015-08-06 11:47:32 +0100 | [diff] [blame] | 1683 | .. attribute:: oid |
| 1684 | |
| 1685 | .. versionadded:: 1.0 |
| 1686 | |
| 1687 | :type: :class:`ObjectIdentifier` |
| 1688 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1689 | Returns :attr:`~cryptography.x509.oid.ExtensionOID.NAME_CONSTRAINTS`. |
Paul Kehrer | 822f3d3 | 2015-08-06 11:47:32 +0100 | [diff] [blame] | 1690 | |
Paul Kehrer | e0017be | 2015-05-17 20:39:40 -0600 | [diff] [blame] | 1691 | .. attribute:: permitted_subtrees |
| 1692 | |
| 1693 | :type: list of :class:`GeneralName` objects or None |
| 1694 | |
| 1695 | The set of permitted name patterns. If a name matches this and an |
| 1696 | element in ``excluded_subtrees`` it is invalid. At least one of |
| 1697 | ``permitted_subtrees`` and ``excluded_subtrees`` will be non-None. |
| 1698 | |
| 1699 | .. attribute:: excluded_subtrees |
| 1700 | |
| 1701 | :type: list of :class:`GeneralName` objects or None |
| 1702 | |
| 1703 | Any name matching a restriction in the ``excluded_subtrees`` field is |
| 1704 | invalid regardless of information appearing in the |
| 1705 | ``permitted_subtrees``. At least one of ``permitted_subtrees`` and |
| 1706 | ``excluded_subtrees`` will be non-None. |
| 1707 | |
Paul Kehrer | 47c32ba | 2015-10-28 09:12:07 +0900 | [diff] [blame] | 1708 | .. class:: AuthorityKeyIdentifier(key_identifier, authority_cert_issuer, authority_cert_serial_number) |
Paul Kehrer | 2eb4ed9 | 2015-04-11 15:33:45 -0400 | [diff] [blame] | 1709 | |
| 1710 | .. versionadded:: 0.9 |
| 1711 | |
| 1712 | The authority key identifier extension provides a means of identifying the |
| 1713 | public key corresponding to the private key used to sign a certificate. |
Paul Kehrer | 8c8cd72 | 2015-04-19 09:15:04 -0500 | [diff] [blame] | 1714 | This extension is typically used to assist in determining the appropriate |
| 1715 | certificate chain. For more information about generation and use of this |
| 1716 | extension see `RFC 5280 section 4.2.1.1`_. |
Paul Kehrer | 2eb4ed9 | 2015-04-11 15:33:45 -0400 | [diff] [blame] | 1717 | |
Paul Kehrer | 822f3d3 | 2015-08-06 11:47:32 +0100 | [diff] [blame] | 1718 | .. attribute:: oid |
| 1719 | |
| 1720 | .. versionadded:: 1.0 |
| 1721 | |
| 1722 | :type: :class:`ObjectIdentifier` |
| 1723 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1724 | Returns |
| 1725 | :attr:`~cryptography.x509.oid.ExtensionOID.AUTHORITY_KEY_IDENTIFIER`. |
Paul Kehrer | 822f3d3 | 2015-08-06 11:47:32 +0100 | [diff] [blame] | 1726 | |
Paul Kehrer | 2eb4ed9 | 2015-04-11 15:33:45 -0400 | [diff] [blame] | 1727 | .. attribute:: key_identifier |
| 1728 | |
| 1729 | :type: bytes |
| 1730 | |
Paul Kehrer | 9104b1d | 2015-04-18 09:23:44 -0500 | [diff] [blame] | 1731 | 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] | 1732 | signature. |
Paul Kehrer | 9104b1d | 2015-04-18 09:23:44 -0500 | [diff] [blame] | 1733 | |
Paul Kehrer | 2eb4ed9 | 2015-04-11 15:33:45 -0400 | [diff] [blame] | 1734 | .. attribute:: authority_cert_issuer |
| 1735 | |
| 1736 | :type: :class:`Name` or None |
| 1737 | |
Paul Kehrer | 9104b1d | 2015-04-18 09:23:44 -0500 | [diff] [blame] | 1738 | The :class:`Name` of the issuer's issuer. |
| 1739 | |
Paul Kehrer | 2eb4ed9 | 2015-04-11 15:33:45 -0400 | [diff] [blame] | 1740 | .. attribute:: authority_cert_serial_number |
| 1741 | |
| 1742 | :type: int or None |
| 1743 | |
Paul Kehrer | 9104b1d | 2015-04-18 09:23:44 -0500 | [diff] [blame] | 1744 | The serial number of the issuer's issuer. |
| 1745 | |
Paul Kehrer | 253929a | 2015-08-05 17:30:39 +0100 | [diff] [blame] | 1746 | .. classmethod:: from_issuer_public_key(public_key) |
| 1747 | |
| 1748 | .. versionadded:: 1.0 |
| 1749 | |
Paul Kehrer | 2d8e574 | 2016-03-12 09:27:55 -0400 | [diff] [blame] | 1750 | .. note:: |
| 1751 | |
| 1752 | This method should be used if the issuer certificate does not |
| 1753 | contain a :class:`~cryptography.x509.SubjectKeyIdentifier`. |
| 1754 | Otherwise, use |
| 1755 | :meth:`~cryptography.x509.AuthorityKeyIdentifier.from_issuer_subject_key_identifier`. |
| 1756 | |
Paul Kehrer | 253929a | 2015-08-05 17:30:39 +0100 | [diff] [blame] | 1757 | Creates a new AuthorityKeyIdentifier instance using the public key |
| 1758 | provided to generate the appropriate digest. This should be the |
Paul Kehrer | 26ac47f | 2015-08-08 15:20:52 -0500 | [diff] [blame] | 1759 | **issuer's public key**. The resulting object will contain |
| 1760 | :attr:`~cryptography.x509.AuthorityKeyIdentifier.key_identifier`, but |
| 1761 | :attr:`~cryptography.x509.AuthorityKeyIdentifier.authority_cert_issuer` |
| 1762 | and |
| 1763 | :attr:`~cryptography.x509.AuthorityKeyIdentifier.authority_cert_serial_number` |
| 1764 | will be None. |
| 1765 | The generated ``key_identifier`` is the SHA1 hash of the ``subjectPublicKey`` |
| 1766 | ASN.1 bit string. This is the first recommendation in :rfc:`5280` |
Paul Kehrer | 253929a | 2015-08-05 17:30:39 +0100 | [diff] [blame] | 1767 | section 4.2.1.2. |
| 1768 | |
Paul Kehrer | cc67182 | 2015-08-08 15:41:54 -0500 | [diff] [blame] | 1769 | :param public_key: One of |
| 1770 | :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey` |
| 1771 | , |
| 1772 | :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPublicKey` |
| 1773 | , or |
| 1774 | :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey`. |
Paul Kehrer | 253929a | 2015-08-05 17:30:39 +0100 | [diff] [blame] | 1775 | |
| 1776 | .. doctest:: |
| 1777 | |
| 1778 | >>> from cryptography import x509 |
| 1779 | >>> from cryptography.hazmat.backends import default_backend |
Paul Kehrer | cc67182 | 2015-08-08 15:41:54 -0500 | [diff] [blame] | 1780 | >>> issuer_cert = x509.load_pem_x509_certificate(pem_data, default_backend()) |
| 1781 | >>> x509.AuthorityKeyIdentifier.from_issuer_public_key(issuer_cert.public_key()) |
Paul Kehrer | 253929a | 2015-08-05 17:30:39 +0100 | [diff] [blame] | 1782 | <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)> |
| 1783 | |
Paul Kehrer | 61ff356 | 2016-03-11 22:51:27 -0400 | [diff] [blame] | 1784 | .. classmethod:: from_issuer_subject_key_identifier(ski) |
| 1785 | |
| 1786 | .. versionadded:: 1.3 |
| 1787 | |
Paul Kehrer | 2d8e574 | 2016-03-12 09:27:55 -0400 | [diff] [blame] | 1788 | .. note:: |
| 1789 | This method should be used if the issuer certificate contains a |
| 1790 | :class:`~cryptography.x509.SubjectKeyIdentifier`. Otherwise, use |
| 1791 | :meth:`~cryptography.x509.AuthorityKeyIdentifier.from_issuer_public_key`. |
| 1792 | |
Paul Kehrer | 61ff356 | 2016-03-11 22:51:27 -0400 | [diff] [blame] | 1793 | Creates a new AuthorityKeyIdentifier instance using the |
| 1794 | SubjectKeyIdentifier from the issuer certificate. The resulting object |
| 1795 | will contain |
| 1796 | :attr:`~cryptography.x509.AuthorityKeyIdentifier.key_identifier`, but |
| 1797 | :attr:`~cryptography.x509.AuthorityKeyIdentifier.authority_cert_issuer` |
| 1798 | and |
| 1799 | :attr:`~cryptography.x509.AuthorityKeyIdentifier.authority_cert_serial_number` |
| 1800 | will be None. |
| 1801 | |
| 1802 | :param ski: The |
| 1803 | :class:`~cryptography.x509.SubjectKeyIdentifier` from the issuer |
| 1804 | certificate. |
| 1805 | |
| 1806 | .. doctest:: |
| 1807 | |
| 1808 | >>> from cryptography import x509 |
| 1809 | >>> from cryptography.hazmat.backends import default_backend |
| 1810 | >>> issuer_cert = x509.load_pem_x509_certificate(pem_data, default_backend()) |
| 1811 | >>> ski = issuer_cert.extensions.get_extension_for_class(x509.SubjectKeyIdentifier) |
| 1812 | >>> x509.AuthorityKeyIdentifier.from_issuer_subject_key_identifier(ski) |
| 1813 | <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)> |
| 1814 | |
Paul Kehrer | 47c32ba | 2015-10-28 09:12:07 +0900 | [diff] [blame] | 1815 | .. class:: SubjectKeyIdentifier(digest) |
Paul Kehrer | 1eb82a6 | 2015-03-31 20:00:33 -0500 | [diff] [blame] | 1816 | |
| 1817 | .. versionadded:: 0.9 |
| 1818 | |
| 1819 | The subject key identifier extension provides a means of identifying |
| 1820 | certificates that contain a particular public key. |
| 1821 | |
Paul Kehrer | 822f3d3 | 2015-08-06 11:47:32 +0100 | [diff] [blame] | 1822 | .. attribute:: oid |
| 1823 | |
| 1824 | .. versionadded:: 1.0 |
| 1825 | |
| 1826 | :type: :class:`ObjectIdentifier` |
| 1827 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1828 | Returns |
| 1829 | :attr:`~cryptography.x509.oid.ExtensionOID.SUBJECT_KEY_IDENTIFIER`. |
Paul Kehrer | 822f3d3 | 2015-08-06 11:47:32 +0100 | [diff] [blame] | 1830 | |
Paul Kehrer | 1eb82a6 | 2015-03-31 20:00:33 -0500 | [diff] [blame] | 1831 | .. attribute:: digest |
| 1832 | |
| 1833 | :type: bytes |
| 1834 | |
| 1835 | The binary value of the identifier. |
| 1836 | |
Paul Kehrer | d4a7f06 | 2015-08-05 18:32:18 +0100 | [diff] [blame] | 1837 | .. classmethod:: from_public_key(public_key) |
Paul Kehrer | f22f612 | 2015-08-05 12:57:13 +0100 | [diff] [blame] | 1838 | |
| 1839 | .. versionadded:: 1.0 |
| 1840 | |
| 1841 | Creates a new SubjectKeyIdentifier instance using the public key |
| 1842 | provided to generate the appropriate digest. This should be the public |
Paul Kehrer | eb9ec00 | 2015-08-08 10:03:02 -0500 | [diff] [blame] | 1843 | key that is in the certificate. The generated digest is the SHA1 hash |
| 1844 | of the ``subjectPublicKey`` ASN.1 bit string. This is the first |
| 1845 | recommendation in :rfc:`5280` section 4.2.1.2. |
Paul Kehrer | f22f612 | 2015-08-05 12:57:13 +0100 | [diff] [blame] | 1846 | |
| 1847 | :param public_key: One of |
| 1848 | :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey` |
| 1849 | , |
| 1850 | :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPublicKey` |
| 1851 | , or |
| 1852 | :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey`. |
| 1853 | |
Paul Kehrer | 253929a | 2015-08-05 17:30:39 +0100 | [diff] [blame] | 1854 | .. doctest:: |
| 1855 | |
| 1856 | >>> from cryptography import x509 |
| 1857 | >>> from cryptography.hazmat.backends import default_backend |
Paul Kehrer | cc67182 | 2015-08-08 15:41:54 -0500 | [diff] [blame] | 1858 | >>> csr = x509.load_pem_x509_csr(pem_req_data, default_backend()) |
| 1859 | >>> x509.SubjectKeyIdentifier.from_public_key(csr.public_key()) |
| 1860 | <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] | 1861 | |
Paul Kehrer | 47c32ba | 2015-10-28 09:12:07 +0900 | [diff] [blame] | 1862 | .. class:: SubjectAlternativeName(general_names) |
Paul Kehrer | 31bdf79 | 2015-03-25 14:11:00 -0500 | [diff] [blame] | 1863 | |
| 1864 | .. versionadded:: 0.9 |
| 1865 | |
| 1866 | Subject alternative name is an X.509 extension that provides a list of |
| 1867 | :ref:`general name <general_name_classes>` instances that provide a set |
| 1868 | of identities for which the certificate is valid. The object is iterable to |
| 1869 | get every element. |
| 1870 | |
Paul Kehrer | 1cb9e55 | 2015-10-28 09:37:29 +0900 | [diff] [blame] | 1871 | :param list general_names: A list of :class:`GeneralName` instances. |
Paul Kehrer | 47c32ba | 2015-10-28 09:12:07 +0900 | [diff] [blame] | 1872 | |
Paul Kehrer | 822f3d3 | 2015-08-06 11:47:32 +0100 | [diff] [blame] | 1873 | .. attribute:: oid |
| 1874 | |
| 1875 | .. versionadded:: 1.0 |
| 1876 | |
| 1877 | :type: :class:`ObjectIdentifier` |
| 1878 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1879 | Returns |
| 1880 | :attr:`~cryptography.x509.oid.ExtensionOID.SUBJECT_ALTERNATIVE_NAME`. |
Paul Kehrer | 822f3d3 | 2015-08-06 11:47:32 +0100 | [diff] [blame] | 1881 | |
Paul Kehrer | 31bdf79 | 2015-03-25 14:11:00 -0500 | [diff] [blame] | 1882 | .. method:: get_values_for_type(type) |
| 1883 | |
Gabriel Orisaka | 617fe4b | 2016-07-31 10:49:59 -0300 | [diff] [blame] | 1884 | :param type: A :class:`GeneralName` instance. This is one of the |
Paul Kehrer | 31bdf79 | 2015-03-25 14:11:00 -0500 | [diff] [blame] | 1885 | :ref:`general name classes <general_name_classes>`. |
| 1886 | |
| 1887 | :returns: A list of values extracted from the matched general names. |
Joshua Tauberer | d2afad3 | 2015-07-06 22:37:53 +0000 | [diff] [blame] | 1888 | The type of the returned values depends on the :class:`GeneralName`. |
Paul Kehrer | 31bdf79 | 2015-03-25 14:11:00 -0500 | [diff] [blame] | 1889 | |
Paul Kehrer | 93ae805 | 2015-05-02 23:18:09 -0500 | [diff] [blame] | 1890 | .. doctest:: |
| 1891 | |
| 1892 | >>> from cryptography import x509 |
| 1893 | >>> from cryptography.hazmat.backends import default_backend |
| 1894 | >>> from cryptography.hazmat.primitives import hashes |
| 1895 | >>> cert = x509.load_pem_x509_certificate(cryptography_cert_pem, default_backend()) |
Paul Kehrer | d0cd507 | 2015-05-02 23:27:00 -0500 | [diff] [blame] | 1896 | >>> # Get the subjectAltName extension from the certificate |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1897 | >>> ext = cert.extensions.get_extension_for_oid(ExtensionOID.SUBJECT_ALTERNATIVE_NAME) |
Paul Kehrer | d0cd507 | 2015-05-02 23:27:00 -0500 | [diff] [blame] | 1898 | >>> # Get the dNSName entries from the SAN extension |
| 1899 | >>> ext.value.get_values_for_type(x509.DNSName) |
Paul Kehrer | 93ae805 | 2015-05-02 23:18:09 -0500 | [diff] [blame] | 1900 | [u'www.cryptography.io', u'cryptography.io'] |
| 1901 | |
Paul Kehrer | 8cf2642 | 2015-03-21 09:50:24 -0500 | [diff] [blame] | 1902 | |
Paul Kehrer | 47c32ba | 2015-10-28 09:12:07 +0900 | [diff] [blame] | 1903 | .. class:: IssuerAlternativeName(general_names) |
Paul Kehrer | 99125c9 | 2015-06-07 18:37:10 -0500 | [diff] [blame] | 1904 | |
| 1905 | .. versionadded:: 1.0 |
| 1906 | |
| 1907 | Issuer alternative name is an X.509 extension that provides a list of |
| 1908 | :ref:`general name <general_name_classes>` instances that provide a set |
| 1909 | of identities for the certificate issuer. The object is iterable to |
| 1910 | get every element. |
| 1911 | |
Paul Kehrer | 1cb9e55 | 2015-10-28 09:37:29 +0900 | [diff] [blame] | 1912 | :param list general_names: A list of :class:`GeneralName` instances. |
Paul Kehrer | 47c32ba | 2015-10-28 09:12:07 +0900 | [diff] [blame] | 1913 | |
Paul Kehrer | 822f3d3 | 2015-08-06 11:47:32 +0100 | [diff] [blame] | 1914 | .. attribute:: oid |
| 1915 | |
| 1916 | .. versionadded:: 1.0 |
| 1917 | |
| 1918 | :type: :class:`ObjectIdentifier` |
| 1919 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1920 | Returns |
| 1921 | :attr:`~cryptography.x509.oid.ExtensionOID.ISSUER_ALTERNATIVE_NAME`. |
Paul Kehrer | 822f3d3 | 2015-08-06 11:47:32 +0100 | [diff] [blame] | 1922 | |
Paul Kehrer | 99125c9 | 2015-06-07 18:37:10 -0500 | [diff] [blame] | 1923 | .. method:: get_values_for_type(type) |
| 1924 | |
Gabriel Orisaka | 617fe4b | 2016-07-31 10:49:59 -0300 | [diff] [blame] | 1925 | :param type: A :class:`GeneralName` instance. This is one of the |
Paul Kehrer | 99125c9 | 2015-06-07 18:37:10 -0500 | [diff] [blame] | 1926 | :ref:`general name classes <general_name_classes>`. |
| 1927 | |
| 1928 | :returns: A list of values extracted from the matched general names. |
| 1929 | |
| 1930 | |
Alex Gaynor | 6a0718f | 2017-06-04 13:36:58 -0400 | [diff] [blame] | 1931 | .. class:: PrecertificateSignedCertificateTimestamps(scts) |
| 1932 | |
| 1933 | .. versionadded:: 2.0 |
| 1934 | |
| 1935 | This extension contains |
| 1936 | :class:`~cryptography.x509.certificate_transparency.SignedCertificateTimestamp` |
| 1937 | instances which were issued for the pre-certificate corresponding to this |
| 1938 | certificate. These can be used to verify that the certificate is included |
| 1939 | in a public Certificate Transparency log. |
| 1940 | |
| 1941 | It is an iterable containing one or more |
| 1942 | :class:`~cryptography.x509.certificate_transparency.SignedCertificateTimestamp` |
| 1943 | objects. |
| 1944 | |
| 1945 | :param list scts: A ``list`` of |
| 1946 | :class:`~cryptography.x509.certificate_transparency.SignedCertificateTimestamp` |
| 1947 | objects. |
| 1948 | |
| 1949 | .. attribute:: oid |
| 1950 | |
| 1951 | :type: :class:`ObjectIdentifier` |
| 1952 | |
| 1953 | Returns |
| 1954 | :attr:`~cryptography.x509.oid.ExtensionOID.PRECERT_SIGNED_CERTIFICATE_TIMESTAMPS`. |
| 1955 | |
| 1956 | |
Paul Kehrer | 5e3cc98 | 2017-09-22 21:29:36 +0800 | [diff] [blame] | 1957 | .. class:: DeltaCRLIndicator(crl_number) |
| 1958 | |
| 1959 | .. versionadded:: 2.1 |
| 1960 | |
| 1961 | The delta CRL indicator is a CRL extension that identifies a CRL as being |
| 1962 | a delta CRL. Delta CRLs contain updates to revocation information |
| 1963 | previously distributed, rather than all the information that would appear |
| 1964 | in a complete CRL. |
| 1965 | |
| 1966 | :param int crl_number: The CRL number of the complete CRL that the |
| 1967 | delta CRL is updating. |
| 1968 | |
| 1969 | .. attribute:: oid |
| 1970 | |
| 1971 | :type: :class:`ObjectIdentifier` |
| 1972 | |
| 1973 | Returns |
| 1974 | :attr:`~cryptography.x509.oid.ExtensionOID.DELTA_CRL_INDICATOR`. |
| 1975 | |
| 1976 | .. attribute:: crl_number |
| 1977 | |
| 1978 | :type: int |
| 1979 | |
| 1980 | |
Paul Kehrer | 47c32ba | 2015-10-28 09:12:07 +0900 | [diff] [blame] | 1981 | .. class:: AuthorityInformationAccess(descriptions) |
Paul Kehrer | 3e6d558 | 2015-05-02 21:57:56 -0500 | [diff] [blame] | 1982 | |
| 1983 | .. versionadded:: 0.9 |
| 1984 | |
| 1985 | The authority information access extension indicates how to access |
| 1986 | information and services for the issuer of the certificate in which |
| 1987 | the extension appears. Information and services may include online |
| 1988 | validation services (such as OCSP) and issuer data. It is an iterable, |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 1989 | containing one or more :class:`~cryptography.x509.AccessDescription` |
| 1990 | instances. |
Paul Kehrer | 3e6d558 | 2015-05-02 21:57:56 -0500 | [diff] [blame] | 1991 | |
Paul Kehrer | 1cb9e55 | 2015-10-28 09:37:29 +0900 | [diff] [blame] | 1992 | :param list descriptions: A list of :class:`AccessDescription` objects. |
Paul Kehrer | 47c32ba | 2015-10-28 09:12:07 +0900 | [diff] [blame] | 1993 | |
Paul Kehrer | 822f3d3 | 2015-08-06 11:47:32 +0100 | [diff] [blame] | 1994 | .. attribute:: oid |
| 1995 | |
| 1996 | .. versionadded:: 1.0 |
| 1997 | |
| 1998 | :type: :class:`ObjectIdentifier` |
| 1999 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2000 | Returns |
| 2001 | :attr:`~cryptography.x509.oid.ExtensionOID.AUTHORITY_INFORMATION_ACCESS`. |
Paul Kehrer | 822f3d3 | 2015-08-06 11:47:32 +0100 | [diff] [blame] | 2002 | |
Paul Kehrer | 3e6d558 | 2015-05-02 21:57:56 -0500 | [diff] [blame] | 2003 | |
Paul Kehrer | 47c32ba | 2015-10-28 09:12:07 +0900 | [diff] [blame] | 2004 | .. class:: AccessDescription(access_method, access_location) |
Paul Kehrer | 3e6d558 | 2015-05-02 21:57:56 -0500 | [diff] [blame] | 2005 | |
Paul Kehrer | 5a48552 | 2015-05-06 00:29:12 -0500 | [diff] [blame] | 2006 | .. versionadded:: 0.9 |
| 2007 | |
Paul Kehrer | 3e6d558 | 2015-05-02 21:57:56 -0500 | [diff] [blame] | 2008 | .. attribute:: access_method |
| 2009 | |
| 2010 | :type: :class:`ObjectIdentifier` |
| 2011 | |
Paul Kehrer | f506bca | 2015-05-02 22:31:47 -0500 | [diff] [blame] | 2012 | The access method defines what the ``access_location`` means. It must |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2013 | be either |
| 2014 | :attr:`~cryptography.x509.oid.AuthorityInformationAccessOID.OCSP` or |
| 2015 | :attr:`~cryptography.x509.oid.AuthorityInformationAccessOID.CA_ISSUERS`. |
| 2016 | If it is |
| 2017 | :attr:`~cryptography.x509.oid.AuthorityInformationAccessOID.OCSP` |
| 2018 | the access location will be where to obtain OCSP |
| 2019 | information for the certificate. If it is |
| 2020 | :attr:`~cryptography.x509.oid.AuthorityInformationAccessOID.CA_ISSUERS` |
| 2021 | the access location will provide additional information about the |
| 2022 | issuing certificate. |
Paul Kehrer | 3e6d558 | 2015-05-02 21:57:56 -0500 | [diff] [blame] | 2023 | |
| 2024 | .. attribute:: access_location |
| 2025 | |
| 2026 | :type: :class:`GeneralName` |
| 2027 | |
Paul Kehrer | f506bca | 2015-05-02 22:31:47 -0500 | [diff] [blame] | 2028 | Where to access the information defined by the access method. |
| 2029 | |
Paul Kehrer | b76bcf8 | 2017-09-24 08:44:12 +0800 | [diff] [blame^] | 2030 | .. class:: FreshestCRL(distribution_points) |
| 2031 | |
| 2032 | .. versionadded:: 2.1 |
| 2033 | |
| 2034 | The freshest CRL extension (also known as Delta CRL Distribution Point) |
| 2035 | identifies how delta CRL information is obtained. It is an iterable, |
| 2036 | containing one or more :class:`DistributionPoint` instances. |
| 2037 | |
| 2038 | :param list distribution_points: A list of :class:`DistributionPoint` |
| 2039 | instances. |
| 2040 | |
| 2041 | .. attribute:: oid |
| 2042 | |
| 2043 | :type: :class:`ObjectIdentifier` |
| 2044 | |
| 2045 | Returns |
| 2046 | :attr:`~cryptography.x509.oid.ExtensionOID.FRESHEST_CRL`. |
| 2047 | |
Paul Kehrer | 47c32ba | 2015-10-28 09:12:07 +0900 | [diff] [blame] | 2048 | .. class:: CRLDistributionPoints(distribution_points) |
Paul Kehrer | 5a48552 | 2015-05-06 00:29:12 -0500 | [diff] [blame] | 2049 | |
| 2050 | .. versionadded:: 0.9 |
| 2051 | |
| 2052 | The CRL distribution points extension identifies how CRL information is |
| 2053 | obtained. It is an iterable, containing one or more |
| 2054 | :class:`DistributionPoint` instances. |
| 2055 | |
Paul Kehrer | 1cb9e55 | 2015-10-28 09:37:29 +0900 | [diff] [blame] | 2056 | :param list distribution_points: A list of :class:`DistributionPoint` |
| 2057 | instances. |
Paul Kehrer | 47c32ba | 2015-10-28 09:12:07 +0900 | [diff] [blame] | 2058 | |
Paul Kehrer | 822f3d3 | 2015-08-06 11:47:32 +0100 | [diff] [blame] | 2059 | .. attribute:: oid |
| 2060 | |
| 2061 | .. versionadded:: 1.0 |
| 2062 | |
| 2063 | :type: :class:`ObjectIdentifier` |
| 2064 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2065 | Returns |
| 2066 | :attr:`~cryptography.x509.oid.ExtensionOID.CRL_DISTRIBUTION_POINTS`. |
Paul Kehrer | 822f3d3 | 2015-08-06 11:47:32 +0100 | [diff] [blame] | 2067 | |
Paul Kehrer | 47c32ba | 2015-10-28 09:12:07 +0900 | [diff] [blame] | 2068 | .. class:: DistributionPoint(full_name, relative_name, reasons, crl_issuer) |
Paul Kehrer | 5a48552 | 2015-05-06 00:29:12 -0500 | [diff] [blame] | 2069 | |
| 2070 | .. versionadded:: 0.9 |
| 2071 | |
Paul Kehrer | 4e8dacd | 2015-05-09 10:38:23 -0500 | [diff] [blame] | 2072 | .. attribute:: full_name |
Paul Kehrer | 5a48552 | 2015-05-06 00:29:12 -0500 | [diff] [blame] | 2073 | |
Paul Kehrer | 4e8dacd | 2015-05-09 10:38:23 -0500 | [diff] [blame] | 2074 | :type: list of :class:`GeneralName` instances or None |
Paul Kehrer | 5a48552 | 2015-05-06 00:29:12 -0500 | [diff] [blame] | 2075 | |
Paul Kehrer | f2c072b | 2015-05-09 17:04:28 -0500 | [diff] [blame] | 2076 | This field describes methods to retrieve the CRL. At most one of |
| 2077 | ``full_name`` or ``relative_name`` will be non-None. |
Paul Kehrer | 4e8dacd | 2015-05-09 10:38:23 -0500 | [diff] [blame] | 2078 | |
| 2079 | .. attribute:: relative_name |
| 2080 | |
Fraser Tweedale | 02467dd | 2016-11-07 15:54:04 +1000 | [diff] [blame] | 2081 | :type: :class:`RelativeDistinguishedName` or None |
Paul Kehrer | 4e8dacd | 2015-05-09 10:38:23 -0500 | [diff] [blame] | 2082 | |
| 2083 | This field describes methods to retrieve the CRL relative to the CRL |
Paul Kehrer | f2c072b | 2015-05-09 17:04:28 -0500 | [diff] [blame] | 2084 | issuer. At most one of ``full_name`` or ``relative_name`` will be |
| 2085 | non-None. |
Paul Kehrer | 5a48552 | 2015-05-06 00:29:12 -0500 | [diff] [blame] | 2086 | |
Fraser Tweedale | 02467dd | 2016-11-07 15:54:04 +1000 | [diff] [blame] | 2087 | .. versionchanged:: 1.6 |
| 2088 | Changed from :class:`Name` to :class:`RelativeDistinguishedName`. |
| 2089 | |
Paul Kehrer | 5a48552 | 2015-05-06 00:29:12 -0500 | [diff] [blame] | 2090 | .. attribute:: crl_issuer |
| 2091 | |
| 2092 | :type: list of :class:`GeneralName` instances or None |
| 2093 | |
| 2094 | Information about the issuer of the CRL. |
| 2095 | |
| 2096 | .. attribute:: reasons |
| 2097 | |
Paul Kehrer | 3fd0260 | 2015-05-09 19:46:13 -0500 | [diff] [blame] | 2098 | :type: frozenset of :class:`ReasonFlags` or None |
Paul Kehrer | 5a48552 | 2015-05-06 00:29:12 -0500 | [diff] [blame] | 2099 | |
| 2100 | The reasons a given distribution point may be used for when performing |
| 2101 | revocation checks. |
| 2102 | |
| 2103 | .. class:: ReasonFlags |
| 2104 | |
| 2105 | .. versionadded:: 0.9 |
| 2106 | |
Paul Kehrer | 4e8dacd | 2015-05-09 10:38:23 -0500 | [diff] [blame] | 2107 | An enumeration for CRL reasons. |
| 2108 | |
| 2109 | .. attribute:: unspecified |
| 2110 | |
| 2111 | It is unspecified why the certificate was revoked. This reason cannot |
| 2112 | be used as a reason flag in a :class:`DistributionPoint`. |
Paul Kehrer | 5a48552 | 2015-05-06 00:29:12 -0500 | [diff] [blame] | 2113 | |
| 2114 | .. attribute:: key_compromise |
| 2115 | |
Paul Kehrer | 4e8dacd | 2015-05-09 10:38:23 -0500 | [diff] [blame] | 2116 | This reason indicates that the private key was compromised. |
Paul Kehrer | 5a48552 | 2015-05-06 00:29:12 -0500 | [diff] [blame] | 2117 | |
| 2118 | .. attribute:: ca_compromise |
| 2119 | |
Paul Kehrer | 4e8dacd | 2015-05-09 10:38:23 -0500 | [diff] [blame] | 2120 | This reason indicates that the CA issuing the certificate was |
| 2121 | compromised. |
Paul Kehrer | 5a48552 | 2015-05-06 00:29:12 -0500 | [diff] [blame] | 2122 | |
| 2123 | .. attribute:: affiliation_changed |
| 2124 | |
Paul Kehrer | 4e8dacd | 2015-05-09 10:38:23 -0500 | [diff] [blame] | 2125 | This reason indicates that the subject's name or other information has |
| 2126 | changed. |
Paul Kehrer | 5a48552 | 2015-05-06 00:29:12 -0500 | [diff] [blame] | 2127 | |
| 2128 | .. attribute:: superseded |
| 2129 | |
Paul Kehrer | 4e8dacd | 2015-05-09 10:38:23 -0500 | [diff] [blame] | 2130 | This reason indicates that a certificate has been superseded. |
Paul Kehrer | 5a48552 | 2015-05-06 00:29:12 -0500 | [diff] [blame] | 2131 | |
| 2132 | .. attribute:: cessation_of_operation |
| 2133 | |
Paul Kehrer | 4e8dacd | 2015-05-09 10:38:23 -0500 | [diff] [blame] | 2134 | This reason indicates that the certificate is no longer required. |
Paul Kehrer | 5a48552 | 2015-05-06 00:29:12 -0500 | [diff] [blame] | 2135 | |
| 2136 | .. attribute:: certificate_hold |
| 2137 | |
Paul Kehrer | 4e8dacd | 2015-05-09 10:38:23 -0500 | [diff] [blame] | 2138 | This reason indicates that the certificate is on hold. |
Paul Kehrer | 5a48552 | 2015-05-06 00:29:12 -0500 | [diff] [blame] | 2139 | |
| 2140 | .. attribute:: privilege_withdrawn |
| 2141 | |
Paul Kehrer | 4e8dacd | 2015-05-09 10:38:23 -0500 | [diff] [blame] | 2142 | This reason indicates that the privilege granted by this certificate |
| 2143 | have been withdrawn. |
Paul Kehrer | 5a48552 | 2015-05-06 00:29:12 -0500 | [diff] [blame] | 2144 | |
| 2145 | .. attribute:: aa_compromise |
| 2146 | |
Paul Kehrer | 4e8dacd | 2015-05-09 10:38:23 -0500 | [diff] [blame] | 2147 | When an attribute authority has been compromised. |
| 2148 | |
| 2149 | .. attribute:: remove_from_crl |
| 2150 | |
| 2151 | This reason indicates that the certificate was on hold and should be |
| 2152 | removed from the CRL. This reason cannot be used as a reason flag |
| 2153 | in a :class:`DistributionPoint`. |
Paul Kehrer | 5a48552 | 2015-05-06 00:29:12 -0500 | [diff] [blame] | 2154 | |
Paul Kehrer | 47c32ba | 2015-10-28 09:12:07 +0900 | [diff] [blame] | 2155 | .. class:: InhibitAnyPolicy(skip_certs) |
Paul Kehrer | 16fae76 | 2015-05-01 23:14:20 -0500 | [diff] [blame] | 2156 | |
| 2157 | .. versionadded:: 1.0 |
| 2158 | |
| 2159 | The inhibit ``anyPolicy`` extension indicates that the special OID |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2160 | :attr:`~cryptography.x509.oid.CertificatePoliciesOID.ANY_POLICY`, is not |
| 2161 | considered an explicit match for other :class:`CertificatePolicies` except |
| 2162 | when it appears in an intermediate self-issued CA certificate. The value |
| 2163 | indicates the number of additional non-self-issued certificates that may |
| 2164 | appear in the path before |
| 2165 | :attr:`~cryptography.x509.oid.CertificatePoliciesOID.ANY_POLICY` is no |
| 2166 | longer permitted. For example, a value of one indicates that |
| 2167 | :attr:`~cryptography.x509.oid.CertificatePoliciesOID.ANY_POLICY` may be |
| 2168 | processed in certificates issued by the subject of this certificate, but |
| 2169 | not in additional certificates in the path. |
Paul Kehrer | 16fae76 | 2015-05-01 23:14:20 -0500 | [diff] [blame] | 2170 | |
Paul Kehrer | 822f3d3 | 2015-08-06 11:47:32 +0100 | [diff] [blame] | 2171 | .. attribute:: oid |
| 2172 | |
| 2173 | .. versionadded:: 1.0 |
| 2174 | |
| 2175 | :type: :class:`ObjectIdentifier` |
| 2176 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2177 | Returns |
| 2178 | :attr:`~cryptography.x509.oid.ExtensionOID.INHIBIT_ANY_POLICY`. |
Paul Kehrer | 822f3d3 | 2015-08-06 11:47:32 +0100 | [diff] [blame] | 2179 | |
Paul Kehrer | 16fae76 | 2015-05-01 23:14:20 -0500 | [diff] [blame] | 2180 | .. attribute:: skip_certs |
| 2181 | |
| 2182 | :type: int |
| 2183 | |
Paul Kehrer | 7e8fe9d | 2015-05-18 09:53:47 -0700 | [diff] [blame] | 2184 | .. class:: PolicyConstraints |
| 2185 | |
| 2186 | .. versionadded:: 1.3 |
| 2187 | |
Paul Kehrer | 648c0fb | 2016-02-26 16:10:36 -0600 | [diff] [blame] | 2188 | The policy constraints extension is used to inhibit policy mapping or |
| 2189 | require that each certificate in a chain contain an acceptable policy |
Paul Kehrer | 7e8fe9d | 2015-05-18 09:53:47 -0700 | [diff] [blame] | 2190 | identifier. For more information about the use of this extension see |
| 2191 | :rfc:`5280`. |
| 2192 | |
Paul Kehrer | 159b3b5 | 2016-02-26 08:27:22 -0600 | [diff] [blame] | 2193 | .. attribute:: oid |
| 2194 | |
| 2195 | :type: :class:`ObjectIdentifier` |
| 2196 | |
| 2197 | Returns :attr:`~cryptography.x509.oid.ExtensionOID.POLICY_CONSTRAINTS`. |
| 2198 | |
Paul Kehrer | 7e8fe9d | 2015-05-18 09:53:47 -0700 | [diff] [blame] | 2199 | .. attribute:: require_explicit_policy |
| 2200 | |
| 2201 | :type: int or None |
| 2202 | |
Paul Kehrer | 648c0fb | 2016-02-26 16:10:36 -0600 | [diff] [blame] | 2203 | If this field is not None, the value indicates the number of additional |
| 2204 | certificates that may appear in the chain before an explicit policy is |
Paul Kehrer | 7e8fe9d | 2015-05-18 09:53:47 -0700 | [diff] [blame] | 2205 | required for the entire path. When an explicit policy is required, it |
Paul Kehrer | 648c0fb | 2016-02-26 16:10:36 -0600 | [diff] [blame] | 2206 | is necessary for all certificates in the chain to contain an acceptable |
Paul Kehrer | 7e8fe9d | 2015-05-18 09:53:47 -0700 | [diff] [blame] | 2207 | policy identifier in the certificate policies extension. An |
| 2208 | acceptable policy identifier is the identifier of a policy required |
| 2209 | by the user of the certification path or the identifier of a policy |
| 2210 | that has been declared equivalent through policy mapping. |
| 2211 | |
| 2212 | .. attribute:: inhibit_policy_mapping |
| 2213 | |
| 2214 | :type: int or None |
| 2215 | |
Paul Kehrer | 648c0fb | 2016-02-26 16:10:36 -0600 | [diff] [blame] | 2216 | If this field is not None, the value indicates the number of additional |
| 2217 | certificates that may appear in the chain before policy mapping is no |
Paul Kehrer | 7e8fe9d | 2015-05-18 09:53:47 -0700 | [diff] [blame] | 2218 | longer permitted. For example, a value of one indicates that policy |
| 2219 | mapping may be processed in certificates issued by the subject of this |
Paul Kehrer | 648c0fb | 2016-02-26 16:10:36 -0600 | [diff] [blame] | 2220 | certificate, but not in additional certificates in the chain. |
Paul Kehrer | 7e8fe9d | 2015-05-18 09:53:47 -0700 | [diff] [blame] | 2221 | |
Paul Kehrer | 3b95cd7 | 2015-12-22 21:40:20 -0600 | [diff] [blame] | 2222 | .. class:: CRLNumber(crl_number) |
| 2223 | |
| 2224 | .. versionadded:: 1.2 |
| 2225 | |
Paul Kehrer | e32b994 | 2015-12-22 22:26:53 -0600 | [diff] [blame] | 2226 | The CRL number is a CRL extension that conveys a monotonically increasing |
| 2227 | sequence number for a given CRL scope and CRL issuer. This extension allows |
| 2228 | users to easily determine when a particular CRL supersedes another CRL. |
| 2229 | :rfc:`5280` requires that this extension be present in conforming CRLs. |
Paul Kehrer | 3b95cd7 | 2015-12-22 21:40:20 -0600 | [diff] [blame] | 2230 | |
| 2231 | .. attribute:: oid |
| 2232 | |
| 2233 | :type: :class:`ObjectIdentifier` |
| 2234 | |
| 2235 | Returns |
| 2236 | :attr:`~cryptography.x509.oid.ExtensionOID.CRL_NUMBER`. |
| 2237 | |
| 2238 | .. attribute:: crl_number |
| 2239 | |
| 2240 | :type: int |
| 2241 | |
Paul Kehrer | 14fd697 | 2015-12-30 10:58:25 -0600 | [diff] [blame] | 2242 | .. class:: UnrecognizedExtension |
| 2243 | |
| 2244 | .. versionadded:: 1.2 |
| 2245 | |
Alex Gaynor | d08ddd5 | 2017-05-20 09:01:54 -0700 | [diff] [blame] | 2246 | A generic extension class used to hold the raw value of extensions that |
| 2247 | ``cryptography`` does not know how to parse. |
Paul Kehrer | 14fd697 | 2015-12-30 10:58:25 -0600 | [diff] [blame] | 2248 | |
| 2249 | .. attribute:: oid |
| 2250 | |
| 2251 | :type: :class:`ObjectIdentifier` |
| 2252 | |
| 2253 | Returns the OID associated with this extension. |
| 2254 | |
| 2255 | .. attribute:: value |
| 2256 | |
| 2257 | :type: byte |
| 2258 | |
| 2259 | Returns the DER encoded bytes payload of the extension. |
| 2260 | |
Paul Kehrer | 47c32ba | 2015-10-28 09:12:07 +0900 | [diff] [blame] | 2261 | .. class:: CertificatePolicies(policies) |
Paul Kehrer | 0d21092 | 2015-04-28 17:31:07 -0500 | [diff] [blame] | 2262 | |
| 2263 | .. versionadded:: 0.9 |
| 2264 | |
Paul Kehrer | 2e87974 | 2015-05-02 23:09:56 -0500 | [diff] [blame] | 2265 | The certificate policies extension is an iterable, containing one or more |
| 2266 | :class:`PolicyInformation` instances. |
Paul Kehrer | 0d21092 | 2015-04-28 17:31:07 -0500 | [diff] [blame] | 2267 | |
Paul Kehrer | 1cb9e55 | 2015-10-28 09:37:29 +0900 | [diff] [blame] | 2268 | :param list policies: A list of :class:`PolicyInformation` instances. |
Paul Kehrer | 47c32ba | 2015-10-28 09:12:07 +0900 | [diff] [blame] | 2269 | |
Paul Kehrer | 822f3d3 | 2015-08-06 11:47:32 +0100 | [diff] [blame] | 2270 | .. attribute:: oid |
| 2271 | |
| 2272 | .. versionadded:: 1.0 |
| 2273 | |
| 2274 | :type: :class:`ObjectIdentifier` |
| 2275 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2276 | Returns |
| 2277 | :attr:`~cryptography.x509.oid.ExtensionOID.CERTIFICATE_POLICIES`. |
Paul Kehrer | 822f3d3 | 2015-08-06 11:47:32 +0100 | [diff] [blame] | 2278 | |
Paul Kehrer | 0d21092 | 2015-04-28 17:31:07 -0500 | [diff] [blame] | 2279 | Certificate Policies Classes |
| 2280 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 2281 | |
| 2282 | These classes may be present within a :class:`CertificatePolicies` instance. |
| 2283 | |
Paul Kehrer | 47c32ba | 2015-10-28 09:12:07 +0900 | [diff] [blame] | 2284 | .. class:: PolicyInformation(policy_identifier, policy_qualifiers) |
Paul Kehrer | 0d21092 | 2015-04-28 17:31:07 -0500 | [diff] [blame] | 2285 | |
| 2286 | .. versionadded:: 0.9 |
| 2287 | |
| 2288 | Contains a policy identifier and an optional list of qualifiers. |
| 2289 | |
| 2290 | .. attribute:: policy_identifier |
| 2291 | |
| 2292 | :type: :class:`ObjectIdentifier` |
| 2293 | |
| 2294 | .. attribute:: policy_qualifiers |
| 2295 | |
| 2296 | :type: list |
| 2297 | |
Paul Kehrer | ba35b3b | 2015-05-10 13:07:59 -0500 | [diff] [blame] | 2298 | A list consisting of :term:`text` and/or :class:`UserNotice` objects. |
Paul Kehrer | 3f8ddeb | 2015-05-11 00:25:36 -0500 | [diff] [blame] | 2299 | If the value is text it is a pointer to the practice statement |
| 2300 | published by the certificate authority. If it is a user notice it is |
| 2301 | meant for display to the relying party when the certificate is |
| 2302 | used. |
Paul Kehrer | 2e87974 | 2015-05-02 23:09:56 -0500 | [diff] [blame] | 2303 | |
Paul Kehrer | 47c32ba | 2015-10-28 09:12:07 +0900 | [diff] [blame] | 2304 | .. class:: UserNotice(notice_reference, explicit_text) |
Paul Kehrer | 0d21092 | 2015-04-28 17:31:07 -0500 | [diff] [blame] | 2305 | |
| 2306 | .. versionadded:: 0.9 |
| 2307 | |
Paul Kehrer | 2e87974 | 2015-05-02 23:09:56 -0500 | [diff] [blame] | 2308 | User notices are intended for display to a relying party when a certificate |
| 2309 | is used. In practice, few if any UIs expose this data and it is a rarely |
| 2310 | encoded component. |
| 2311 | |
Paul Kehrer | 0d21092 | 2015-04-28 17:31:07 -0500 | [diff] [blame] | 2312 | .. attribute:: notice_reference |
| 2313 | |
| 2314 | :type: :class:`NoticeReference` or None |
| 2315 | |
Paul Kehrer | 2e87974 | 2015-05-02 23:09:56 -0500 | [diff] [blame] | 2316 | The notice reference field names an organization and identifies, |
| 2317 | by number, a particular statement prepared by that organization. |
| 2318 | |
Paul Kehrer | 0d21092 | 2015-04-28 17:31:07 -0500 | [diff] [blame] | 2319 | .. attribute:: explicit_text |
| 2320 | |
Paul Kehrer | 2e87974 | 2015-05-02 23:09:56 -0500 | [diff] [blame] | 2321 | This field includes an arbitrary textual statement directly in the |
| 2322 | certificate. |
| 2323 | |
Paul Kehrer | 0d21092 | 2015-04-28 17:31:07 -0500 | [diff] [blame] | 2324 | :type: :term:`text` |
| 2325 | |
Paul Kehrer | 47c32ba | 2015-10-28 09:12:07 +0900 | [diff] [blame] | 2326 | .. class:: NoticeReference(organization, notice_numbers) |
Paul Kehrer | 0d21092 | 2015-04-28 17:31:07 -0500 | [diff] [blame] | 2327 | |
Paul Kehrer | 2e87974 | 2015-05-02 23:09:56 -0500 | [diff] [blame] | 2328 | Notice reference can name an organization and provide information about |
| 2329 | notices related to the certificate. For example, it might identify the |
| 2330 | organization name and notice number 1. Application software could |
| 2331 | have a notice file containing the current set of notices for the named |
| 2332 | organization; the application would then extract the notice text from the |
| 2333 | file and display it. In practice this is rarely seen. |
| 2334 | |
Paul Kehrer | 0d21092 | 2015-04-28 17:31:07 -0500 | [diff] [blame] | 2335 | .. versionadded:: 0.9 |
| 2336 | |
| 2337 | .. attribute:: organization |
| 2338 | |
Paul Kehrer | 66c6170 | 2015-05-12 16:39:18 -0500 | [diff] [blame] | 2339 | :type: :term:`text` |
Paul Kehrer | 0d21092 | 2015-04-28 17:31:07 -0500 | [diff] [blame] | 2340 | |
Paul Kehrer | 3f8ddeb | 2015-05-11 00:25:36 -0500 | [diff] [blame] | 2341 | .. attribute:: notice_numbers |
Paul Kehrer | 0d21092 | 2015-04-28 17:31:07 -0500 | [diff] [blame] | 2342 | |
Paul Kehrer | 66c6170 | 2015-05-12 16:39:18 -0500 | [diff] [blame] | 2343 | :type: list |
Paul Kehrer | 0d21092 | 2015-04-28 17:31:07 -0500 | [diff] [blame] | 2344 | |
Paul Kehrer | 66c6170 | 2015-05-12 16:39:18 -0500 | [diff] [blame] | 2345 | A list of integers. |
Paul Kehrer | 0d21092 | 2015-04-28 17:31:07 -0500 | [diff] [blame] | 2346 | |
Paul Kehrer | e5f152b | 2015-12-25 23:55:47 -0600 | [diff] [blame] | 2347 | .. _crl_entry_extensions: |
| 2348 | |
Paul Kehrer | 49bb756 | 2015-12-25 16:17:40 -0600 | [diff] [blame] | 2349 | CRL Entry Extensions |
| 2350 | ~~~~~~~~~~~~~~~~~~~~ |
| 2351 | |
| 2352 | These extensions are only valid within a :class:`RevokedCertificate` object. |
| 2353 | |
| 2354 | .. class:: CertificateIssuer(general_names) |
| 2355 | |
| 2356 | .. versionadded:: 1.2 |
| 2357 | |
| 2358 | The certificate issuer is an extension that is only valid inside |
| 2359 | :class:`~cryptography.x509.RevokedCertificate` objects. If the |
| 2360 | ``indirectCRL`` property of the parent CRL's IssuingDistributionPoint |
| 2361 | extension is set, then this extension identifies the certificate issuer |
| 2362 | associated with the revoked certificate. The object is iterable to get |
| 2363 | every element. |
| 2364 | |
| 2365 | :param list general_names: A list of :class:`GeneralName` instances. |
| 2366 | |
| 2367 | .. attribute:: oid |
| 2368 | |
| 2369 | :type: :class:`ObjectIdentifier` |
| 2370 | |
| 2371 | Returns |
| 2372 | :attr:`~cryptography.x509.oid.CRLEntryExtensionOID.CERTIFICATE_ISSUER`. |
| 2373 | |
| 2374 | .. method:: get_values_for_type(type) |
| 2375 | |
| 2376 | :param type: A :class:`GeneralName` instance. This is one of the |
| 2377 | :ref:`general name classes <general_name_classes>`. |
| 2378 | |
| 2379 | :returns: A list of values extracted from the matched general names. |
| 2380 | The type of the returned values depends on the :class:`GeneralName`. |
| 2381 | |
Paul Kehrer | 7058ece | 2015-12-25 22:28:29 -0600 | [diff] [blame] | 2382 | .. class:: CRLReason(reason) |
| 2383 | |
| 2384 | .. versionadded:: 1.2 |
| 2385 | |
| 2386 | CRL reason (also known as ``reasonCode``) is an extension that is only |
| 2387 | valid inside :class:`~cryptography.x509.RevokedCertificate` objects. It |
| 2388 | identifies a reason for the certificate revocation. |
| 2389 | |
Paul Kehrer | ce4d084 | 2017-09-20 22:14:26 +0800 | [diff] [blame] | 2390 | :param reason: An element from :class:`~cryptography.x509.ReasonFlags`. |
Paul Kehrer | 7058ece | 2015-12-25 22:28:29 -0600 | [diff] [blame] | 2391 | |
| 2392 | .. attribute:: oid |
| 2393 | |
| 2394 | :type: :class:`ObjectIdentifier` |
| 2395 | |
| 2396 | Returns |
| 2397 | :attr:`~cryptography.x509.oid.CRLEntryExtensionOID.CRL_REASON`. |
| 2398 | |
| 2399 | .. attribute:: reason |
| 2400 | |
| 2401 | :type: An element from :class:`~cryptography.x509.ReasonFlags` |
| 2402 | |
Paul Kehrer | 23c0bbc | 2015-12-25 22:35:19 -0600 | [diff] [blame] | 2403 | .. class:: InvalidityDate(invalidity_date) |
| 2404 | |
| 2405 | .. versionadded:: 1.2 |
| 2406 | |
| 2407 | Invalidity date is an extension that is only valid inside |
| 2408 | :class:`~cryptography.x509.RevokedCertificate` objects. It provides |
| 2409 | the date on which it is known or suspected that the private key was |
| 2410 | compromised or that the certificate otherwise became invalid. |
| 2411 | This date may be earlier than the revocation date in the CRL entry, |
| 2412 | which is the date at which the CA processed the revocation. |
| 2413 | |
| 2414 | :param invalidity_date: The :class:`datetime.datetime` when it is known |
| 2415 | or suspected that the private key was compromised. |
| 2416 | |
| 2417 | .. attribute:: oid |
| 2418 | |
| 2419 | :type: :class:`ObjectIdentifier` |
| 2420 | |
| 2421 | Returns |
| 2422 | :attr:`~cryptography.x509.oid.CRLEntryExtensionOID.INVALIDITY_DATE`. |
| 2423 | |
| 2424 | .. attribute:: invalidity_date |
| 2425 | |
| 2426 | :type: :class:`datetime.datetime` |
| 2427 | |
Paul Kehrer | 49bb756 | 2015-12-25 16:17:40 -0600 | [diff] [blame] | 2428 | |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 2429 | Object Identifiers |
| 2430 | ~~~~~~~~~~~~~~~~~~ |
| 2431 | |
Paul Kehrer | 4bb4649 | 2015-02-07 16:59:14 -0600 | [diff] [blame] | 2432 | X.509 elements are frequently identified by :class:`ObjectIdentifier` |
| 2433 | instances. The following common OIDs are available as constants. |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 2434 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2435 | .. currentmodule:: cryptography.x509.oid |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 2436 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2437 | .. class:: NameOID |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 2438 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2439 | These OIDs are typically seen in X.509 names. |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 2440 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2441 | .. versionadded:: 1.0 |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 2442 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2443 | .. attribute:: COMMON_NAME |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 2444 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2445 | Corresponds to the dotted string ``"2.5.4.3"``. Historically the domain |
| 2446 | name would be encoded here for server certificates. :rfc:`2818` |
| 2447 | deprecates this practice and names of that type should now be located |
| 2448 | in a :class:`~cryptography.x509.SubjectAlternativeName` extension. |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 2449 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2450 | .. attribute:: COUNTRY_NAME |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 2451 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2452 | Corresponds to the dotted string ``"2.5.4.6"``. |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 2453 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2454 | .. attribute:: LOCALITY_NAME |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 2455 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2456 | Corresponds to the dotted string ``"2.5.4.7"``. |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 2457 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2458 | .. attribute:: STATE_OR_PROVINCE_NAME |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 2459 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2460 | Corresponds to the dotted string ``"2.5.4.8"``. |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 2461 | |
Paul Kehrer | c3b8ff6 | 2016-11-11 17:38:59 -0800 | [diff] [blame] | 2462 | .. attribute:: STREET_ADDRESS |
| 2463 | |
| 2464 | .. versionadded:: 1.6 |
| 2465 | |
| 2466 | Corresponds to the dotted string ``"2.5.4.9"``. |
| 2467 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2468 | .. attribute:: ORGANIZATION_NAME |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 2469 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2470 | Corresponds to the dotted string ``"2.5.4.10"``. |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 2471 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2472 | .. attribute:: ORGANIZATIONAL_UNIT_NAME |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 2473 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2474 | Corresponds to the dotted string ``"2.5.4.11"``. |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 2475 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2476 | .. attribute:: SERIAL_NUMBER |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 2477 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2478 | Corresponds to the dotted string ``"2.5.4.5"``. This is distinct from |
| 2479 | the serial number of the certificate itself (which can be obtained with |
Chelsea Winfree | e295f3a | 2016-06-02 21:15:54 -0700 | [diff] [blame] | 2480 | :func:`~cryptography.x509.Certificate.serial_number`). |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 2481 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2482 | .. attribute:: SURNAME |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 2483 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2484 | Corresponds to the dotted string ``"2.5.4.4"``. |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 2485 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2486 | .. attribute:: GIVEN_NAME |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 2487 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2488 | Corresponds to the dotted string ``"2.5.4.42"``. |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 2489 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2490 | .. attribute:: TITLE |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 2491 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2492 | Corresponds to the dotted string ``"2.5.4.12"``. |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 2493 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2494 | .. attribute:: GENERATION_QUALIFIER |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 2495 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2496 | Corresponds to the dotted string ``"2.5.4.44"``. |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 2497 | |
Paul Kehrer | c7ab931 | 2016-11-12 05:00:42 -0800 | [diff] [blame] | 2498 | .. attribute:: X500_UNIQUE_IDENTIFIER |
Paul Kehrer | c3b8ff6 | 2016-11-11 17:38:59 -0800 | [diff] [blame] | 2499 | |
| 2500 | .. versionadded:: 1.6 |
| 2501 | |
| 2502 | Corresponds to the dotted string ``"2.5.4.45"``. |
| 2503 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2504 | .. attribute:: DN_QUALIFIER |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 2505 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2506 | Corresponds to the dotted string ``"2.5.4.46"``. This specifies |
| 2507 | disambiguating information to add to the relative distinguished name of an |
| 2508 | entry. See :rfc:`2256`. |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 2509 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2510 | .. attribute:: PSEUDONYM |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 2511 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2512 | Corresponds to the dotted string ``"2.5.4.65"``. |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 2513 | |
Paul Kehrer | 36d5cd6 | 2016-11-19 22:05:26 +0800 | [diff] [blame] | 2514 | .. attribute:: USER_ID |
| 2515 | |
| 2516 | .. versionadded:: 1.6 |
| 2517 | |
| 2518 | Corresponds to the dotted string ``"0.9.2342.19200300.100.1.1"``. |
| 2519 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2520 | .. attribute:: DOMAIN_COMPONENT |
Paul Kehrer | 858b9b7 | 2015-02-05 09:50:31 -0600 | [diff] [blame] | 2521 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2522 | Corresponds to the dotted string ``"0.9.2342.19200300.100.1.25"``. A string |
| 2523 | holding one component of a domain name. See :rfc:`4519`. |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 2524 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2525 | .. attribute:: EMAIL_ADDRESS |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 2526 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2527 | Corresponds to the dotted string ``"1.2.840.113549.1.9.1"``. |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 2528 | |
Alex Gaynor | 1d3f2bf | 2015-12-19 12:15:09 -0500 | [diff] [blame] | 2529 | .. attribute:: JURISDICTION_COUNTRY_NAME |
| 2530 | |
| 2531 | Corresponds to the dotted string ``"1.3.6.1.4.1.311.60.2.1.3"``. |
| 2532 | |
Alex Gaynor | 45e507f | 2015-12-19 13:44:23 -0500 | [diff] [blame] | 2533 | .. attribute:: JURISDICTION_LOCALITY_NAME |
| 2534 | |
| 2535 | Corresponds to the dotted string ``"1.3.6.1.4.1.311.60.2.1.1"``. |
| 2536 | |
| 2537 | .. attribute:: JURISDICTION_STATE_OR_PROVINCE_NAME |
| 2538 | |
| 2539 | Corresponds to the dotted string ``"1.3.6.1.4.1.311.60.2.1.2"``. |
| 2540 | |
Alex Gaynor | a2293c8 | 2015-12-19 20:49:15 -0500 | [diff] [blame] | 2541 | .. attribute:: BUSINESS_CATEGORY |
| 2542 | |
| 2543 | Corresponds to the dotted string ``"2.5.4.15"``. |
| 2544 | |
Paul Kehrer | 36d5cd6 | 2016-11-19 22:05:26 +0800 | [diff] [blame] | 2545 | .. attribute:: POSTAL_ADDRESS |
| 2546 | |
| 2547 | .. versionadded:: 1.6 |
| 2548 | |
| 2549 | Corresponds to the dotted string ``"2.5.4.16"``. |
| 2550 | |
| 2551 | .. attribute:: POSTAL_CODE |
| 2552 | |
| 2553 | .. versionadded:: 1.6 |
| 2554 | |
| 2555 | Corresponds to the dotted string ``"2.5.4.17"``. |
| 2556 | |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 2557 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2558 | .. class:: SignatureAlgorithmOID |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 2559 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2560 | .. versionadded:: 1.0 |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 2561 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2562 | .. attribute:: RSA_WITH_MD5 |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 2563 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2564 | Corresponds to the dotted string ``"1.2.840.113549.1.1.4"``. This is |
| 2565 | an MD5 digest signed by an RSA key. |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 2566 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2567 | .. attribute:: RSA_WITH_SHA1 |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 2568 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2569 | Corresponds to the dotted string ``"1.2.840.113549.1.1.5"``. This is |
| 2570 | a SHA1 digest signed by an RSA key. |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 2571 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2572 | .. attribute:: RSA_WITH_SHA224 |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 2573 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2574 | Corresponds to the dotted string ``"1.2.840.113549.1.1.14"``. This is |
| 2575 | a SHA224 digest signed by an RSA key. |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 2576 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2577 | .. attribute:: RSA_WITH_SHA256 |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 2578 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2579 | Corresponds to the dotted string ``"1.2.840.113549.1.1.11"``. This is |
| 2580 | a SHA256 digest signed by an RSA key. |
Alex Gaynor | 3aadabf | 2015-06-23 22:06:21 -0400 | [diff] [blame] | 2581 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2582 | .. attribute:: RSA_WITH_SHA384 |
Alex Gaynor | 3aadabf | 2015-06-23 22:06:21 -0400 | [diff] [blame] | 2583 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2584 | Corresponds to the dotted string ``"1.2.840.113549.1.1.12"``. This is |
| 2585 | a SHA384 digest signed by an RSA key. |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 2586 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2587 | .. attribute:: RSA_WITH_SHA512 |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 2588 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2589 | Corresponds to the dotted string ``"1.2.840.113549.1.1.13"``. This is |
| 2590 | a SHA512 digest signed by an RSA key. |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 2591 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2592 | .. attribute:: ECDSA_WITH_SHA1 |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 2593 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2594 | Corresponds to the dotted string ``"1.2.840.10045.4.1"``. This is a SHA1 |
| 2595 | digest signed by an ECDSA key. |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 2596 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2597 | .. attribute:: ECDSA_WITH_SHA224 |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 2598 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2599 | Corresponds to the dotted string ``"1.2.840.10045.4.3.1"``. This is |
| 2600 | a SHA224 digest signed by an ECDSA key. |
| 2601 | |
| 2602 | .. attribute:: ECDSA_WITH_SHA256 |
| 2603 | |
| 2604 | Corresponds to the dotted string ``"1.2.840.10045.4.3.2"``. This is |
| 2605 | a SHA256 digest signed by an ECDSA key. |
| 2606 | |
| 2607 | .. attribute:: ECDSA_WITH_SHA384 |
| 2608 | |
| 2609 | Corresponds to the dotted string ``"1.2.840.10045.4.3.3"``. This is |
| 2610 | a SHA384 digest signed by an ECDSA key. |
| 2611 | |
| 2612 | .. attribute:: ECDSA_WITH_SHA512 |
| 2613 | |
| 2614 | Corresponds to the dotted string ``"1.2.840.10045.4.3.4"``. This is |
| 2615 | a SHA512 digest signed by an ECDSA key. |
| 2616 | |
| 2617 | .. attribute:: DSA_WITH_SHA1 |
| 2618 | |
| 2619 | Corresponds to the dotted string ``"1.2.840.10040.4.3"``. This is |
| 2620 | a SHA1 digest signed by a DSA key. |
| 2621 | |
| 2622 | .. attribute:: DSA_WITH_SHA224 |
| 2623 | |
| 2624 | Corresponds to the dotted string ``"2.16.840.1.101.3.4.3.1"``. This is |
| 2625 | a SHA224 digest signed by a DSA key. |
| 2626 | |
| 2627 | .. attribute:: DSA_WITH_SHA256 |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 2628 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2629 | Corresponds to the dotted string ``"2.16.840.1.101.3.4.3.2"``. This is |
| 2630 | a SHA256 digest signed by a DSA key. |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 2631 | |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 2632 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2633 | .. class:: ExtendedKeyUsageOID |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 2634 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2635 | .. versionadded:: 1.0 |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 2636 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2637 | .. attribute:: SERVER_AUTH |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 2638 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2639 | Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.1"``. This is used |
| 2640 | to denote that a certificate may be used for TLS web server |
| 2641 | authentication. |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 2642 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2643 | .. attribute:: CLIENT_AUTH |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 2644 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2645 | Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.2"``. This is used |
| 2646 | to denote that a certificate may be used for TLS web client |
| 2647 | authentication. |
Paul Kehrer | ffa2a15 | 2015-03-31 08:18:25 -0500 | [diff] [blame] | 2648 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2649 | .. attribute:: CODE_SIGNING |
Paul Kehrer | e1513fa | 2015-03-30 23:08:17 -0500 | [diff] [blame] | 2650 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2651 | Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.3"``. This is used |
| 2652 | to denote that a certificate may be used for code signing. |
Paul Kehrer | e1513fa | 2015-03-30 23:08:17 -0500 | [diff] [blame] | 2653 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2654 | .. attribute:: EMAIL_PROTECTION |
Paul Kehrer | e1513fa | 2015-03-30 23:08:17 -0500 | [diff] [blame] | 2655 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2656 | Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.4"``. This is used |
| 2657 | to denote that a certificate may be used for email protection. |
Paul Kehrer | e1513fa | 2015-03-30 23:08:17 -0500 | [diff] [blame] | 2658 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2659 | .. attribute:: TIME_STAMPING |
Paul Kehrer | e1513fa | 2015-03-30 23:08:17 -0500 | [diff] [blame] | 2660 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2661 | Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.8"``. This is used |
| 2662 | to denote that a certificate may be used for time stamping. |
Paul Kehrer | e1513fa | 2015-03-30 23:08:17 -0500 | [diff] [blame] | 2663 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2664 | .. attribute:: OCSP_SIGNING |
Paul Kehrer | e1513fa | 2015-03-30 23:08:17 -0500 | [diff] [blame] | 2665 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2666 | Corresponds to the dotted string ``"1.3.6.1.5.5.7.3.9"``. This is used |
| 2667 | to denote that a certificate may be used for signing OCSP responses. |
Paul Kehrer | e1513fa | 2015-03-30 23:08:17 -0500 | [diff] [blame] | 2668 | |
Alex Gaynor | b7912ee | 2017-07-03 10:07:02 -0400 | [diff] [blame] | 2669 | .. attribute:: ANY_EXTENDED_KEY_USAGE |
| 2670 | |
| 2671 | .. versionadded:: 2.0 |
| 2672 | |
| 2673 | Corresponds to the dotted string ``"2.5.29.37.0"``. This is used to |
| 2674 | denote that a certificate may be used for _any_ purposes. |
| 2675 | |
Paul Kehrer | e1513fa | 2015-03-30 23:08:17 -0500 | [diff] [blame] | 2676 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2677 | .. class:: AuthorityInformationAccessOID |
Paul Kehrer | e1513fa | 2015-03-30 23:08:17 -0500 | [diff] [blame] | 2678 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2679 | .. versionadded:: 1.0 |
Paul Kehrer | e1513fa | 2015-03-30 23:08:17 -0500 | [diff] [blame] | 2680 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2681 | .. attribute:: OCSP |
Paul Kehrer | e1513fa | 2015-03-30 23:08:17 -0500 | [diff] [blame] | 2682 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2683 | Corresponds to the dotted string ``"1.3.6.1.5.5.7.48.1"``. Used as the |
| 2684 | identifier for OCSP data in |
| 2685 | :class:`~cryptography.x509.AccessDescription` objects. |
Paul Kehrer | e1513fa | 2015-03-30 23:08:17 -0500 | [diff] [blame] | 2686 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2687 | .. attribute:: CA_ISSUERS |
Paul Kehrer | 3e6d558 | 2015-05-02 21:57:56 -0500 | [diff] [blame] | 2688 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2689 | Corresponds to the dotted string ``"1.3.6.1.5.5.7.48.2"``. Used as the |
| 2690 | identifier for CA issuer data in |
| 2691 | :class:`~cryptography.x509.AccessDescription` objects. |
Paul Kehrer | 3e6d558 | 2015-05-02 21:57:56 -0500 | [diff] [blame] | 2692 | |
Paul Kehrer | 3e6d558 | 2015-05-02 21:57:56 -0500 | [diff] [blame] | 2693 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2694 | .. class:: CertificatePoliciesOID |
Paul Kehrer | 3e6d558 | 2015-05-02 21:57:56 -0500 | [diff] [blame] | 2695 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2696 | .. versionadded:: 1.0 |
Paul Kehrer | 3e6d558 | 2015-05-02 21:57:56 -0500 | [diff] [blame] | 2697 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2698 | .. attribute:: CPS_QUALIFIER |
Paul Kehrer | 2e87974 | 2015-05-02 23:09:56 -0500 | [diff] [blame] | 2699 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2700 | 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] | 2701 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2702 | .. attribute:: CPS_USER_NOTICE |
Paul Kehrer | 2e87974 | 2015-05-02 23:09:56 -0500 | [diff] [blame] | 2703 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2704 | 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] | 2705 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2706 | .. attribute:: ANY_POLICY |
Paul Kehrer | 2e87974 | 2015-05-02 23:09:56 -0500 | [diff] [blame] | 2707 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2708 | Corresponds to the dotted string ``"2.5.29.32.0"``. |
Paul Kehrer | 16fae76 | 2015-05-01 23:14:20 -0500 | [diff] [blame] | 2709 | |
Paul Kehrer | 16fae76 | 2015-05-01 23:14:20 -0500 | [diff] [blame] | 2710 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2711 | .. class:: ExtensionOID |
Paul Kehrer | 5553d57 | 2015-03-23 21:08:01 -0500 | [diff] [blame] | 2712 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2713 | .. versionadded:: 1.0 |
Paul Kehrer | 2bb9464 | 2015-03-21 09:54:17 -0500 | [diff] [blame] | 2714 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2715 | .. attribute:: BASIC_CONSTRAINTS |
Paul Kehrer | 2bb9464 | 2015-03-21 09:54:17 -0500 | [diff] [blame] | 2716 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2717 | Corresponds to the dotted string ``"2.5.29.19"``. The identifier for the |
| 2718 | :class:`~cryptography.x509.BasicConstraints` extension type. |
Paul Kehrer | 2bb9464 | 2015-03-21 09:54:17 -0500 | [diff] [blame] | 2719 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2720 | .. attribute:: KEY_USAGE |
Paul Kehrer | cecbbba | 2015-03-30 14:58:38 -0500 | [diff] [blame] | 2721 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2722 | Corresponds to the dotted string ``"2.5.29.15"``. The identifier for the |
| 2723 | :class:`~cryptography.x509.KeyUsage` extension type. |
Paul Kehrer | cecbbba | 2015-03-30 14:58:38 -0500 | [diff] [blame] | 2724 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2725 | .. attribute:: SUBJECT_ALTERNATIVE_NAME |
Paul Kehrer | d4f632e | 2015-05-12 08:25:42 -0500 | [diff] [blame] | 2726 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2727 | Corresponds to the dotted string ``"2.5.29.17"``. The identifier for the |
| 2728 | :class:`~cryptography.x509.SubjectAlternativeName` extension type. |
Paul Kehrer | d4f632e | 2015-05-12 08:25:42 -0500 | [diff] [blame] | 2729 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2730 | .. attribute:: ISSUER_ALTERNATIVE_NAME |
Paul Kehrer | 99125c9 | 2015-06-07 18:37:10 -0500 | [diff] [blame] | 2731 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2732 | Corresponds to the dotted string ``"2.5.29.18"``. The identifier for the |
| 2733 | :class:`~cryptography.x509.IssuerAlternativeName` extension type. |
Paul Kehrer | 99125c9 | 2015-06-07 18:37:10 -0500 | [diff] [blame] | 2734 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2735 | .. attribute:: SUBJECT_KEY_IDENTIFIER |
Paul Kehrer | d4f632e | 2015-05-12 08:25:42 -0500 | [diff] [blame] | 2736 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2737 | Corresponds to the dotted string ``"2.5.29.14"``. The identifier for the |
| 2738 | :class:`~cryptography.x509.SubjectKeyIdentifier` extension type. |
Paul Kehrer | d4f632e | 2015-05-12 08:25:42 -0500 | [diff] [blame] | 2739 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2740 | .. attribute:: NAME_CONSTRAINTS |
Paul Kehrer | e0017be | 2015-05-17 20:39:40 -0600 | [diff] [blame] | 2741 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2742 | Corresponds to the dotted string ``"2.5.29.30"``. The identifier for the |
| 2743 | :class:`~cryptography.x509.NameConstraints` extension type. |
Paul Kehrer | e0017be | 2015-05-17 20:39:40 -0600 | [diff] [blame] | 2744 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2745 | .. attribute:: CRL_DISTRIBUTION_POINTS |
Paul Kehrer | d4f632e | 2015-05-12 08:25:42 -0500 | [diff] [blame] | 2746 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2747 | Corresponds to the dotted string ``"2.5.29.31"``. The identifier for the |
| 2748 | :class:`~cryptography.x509.CRLDistributionPoints` extension type. |
Paul Kehrer | d4f632e | 2015-05-12 08:25:42 -0500 | [diff] [blame] | 2749 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2750 | .. attribute:: CERTIFICATE_POLICIES |
Paul Kehrer | d4f632e | 2015-05-12 08:25:42 -0500 | [diff] [blame] | 2751 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2752 | Corresponds to the dotted string ``"2.5.29.32"``. The identifier for the |
| 2753 | :class:`~cryptography.x509.CertificatePolicies` extension type. |
Paul Kehrer | d4f632e | 2015-05-12 08:25:42 -0500 | [diff] [blame] | 2754 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2755 | .. attribute:: AUTHORITY_KEY_IDENTIFIER |
Paul Kehrer | d4f632e | 2015-05-12 08:25:42 -0500 | [diff] [blame] | 2756 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2757 | Corresponds to the dotted string ``"2.5.29.35"``. The identifier for the |
| 2758 | :class:`~cryptography.x509.AuthorityKeyIdentifier` extension type. |
Paul Kehrer | d4f632e | 2015-05-12 08:25:42 -0500 | [diff] [blame] | 2759 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2760 | .. attribute:: EXTENDED_KEY_USAGE |
Paul Kehrer | d4f632e | 2015-05-12 08:25:42 -0500 | [diff] [blame] | 2761 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2762 | Corresponds to the dotted string ``"2.5.29.37"``. The identifier for the |
| 2763 | :class:`~cryptography.x509.ExtendedKeyUsage` extension type. |
Paul Kehrer | d4f632e | 2015-05-12 08:25:42 -0500 | [diff] [blame] | 2764 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2765 | .. attribute:: AUTHORITY_INFORMATION_ACCESS |
Paul Kehrer | d4f632e | 2015-05-12 08:25:42 -0500 | [diff] [blame] | 2766 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2767 | Corresponds to the dotted string ``"1.3.6.1.5.5.7.1.1"``. The identifier |
| 2768 | for the :class:`~cryptography.x509.AuthorityInformationAccess` extension |
| 2769 | type. |
Paul Kehrer | 56da2a5 | 2015-02-11 23:35:07 -0600 | [diff] [blame] | 2770 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2771 | .. attribute:: INHIBIT_ANY_POLICY |
Paul Kehrer | b33de93 | 2015-08-06 23:41:05 +0100 | [diff] [blame] | 2772 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2773 | Corresponds to the dotted string ``"2.5.29.54"``. The identifier |
| 2774 | for the :class:`~cryptography.x509.InhibitAnyPolicy` extension type. |
Paul Kehrer | b33de93 | 2015-08-06 23:41:05 +0100 | [diff] [blame] | 2775 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2776 | .. attribute:: OCSP_NO_CHECK |
Paul Kehrer | 4a1038e | 2015-05-18 10:28:31 -0700 | [diff] [blame] | 2777 | |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2778 | Corresponds to the dotted string ``"1.3.6.1.5.5.7.48.1.5"``. The |
| 2779 | identifier for the :class:`~cryptography.x509.OCSPNoCheck` extension |
| 2780 | type. |
Paul Kehrer | 4a1038e | 2015-05-18 10:28:31 -0700 | [diff] [blame] | 2781 | |
Paul Kehrer | 5d66966 | 2017-09-11 09:16:34 +0800 | [diff] [blame] | 2782 | .. attribute:: TLS_FEATURE |
| 2783 | |
| 2784 | Corresponds to the dotted string ``"1.3.6.1.5.5.7.1.24"``. The |
| 2785 | identifier for the :class:`~cryptography.x509.TLSFeature` extension |
| 2786 | type. |
| 2787 | |
Paul Kehrer | 51f39cb | 2015-12-21 21:17:39 -0600 | [diff] [blame] | 2788 | .. attribute:: CRL_NUMBER |
| 2789 | |
| 2790 | Corresponds to the dotted string ``"2.5.29.20"``. The identifier for |
| 2791 | the ``CRLNumber`` extension type. This extension only has meaning |
| 2792 | for certificate revocation lists. |
| 2793 | |
Paul Kehrer | 5e3cc98 | 2017-09-22 21:29:36 +0800 | [diff] [blame] | 2794 | .. attribute:: DELTA_CRL_INDICATOR |
| 2795 | |
| 2796 | .. versionadded:: 2.1 |
| 2797 | |
| 2798 | Corresponds to the dotted string ``"2.5.29.27"``. The identifier for |
| 2799 | the ``DeltaCRLIndicator`` extension type. This extension only has |
| 2800 | meaning for certificate revocation lists. |
| 2801 | |
Alex Gaynor | 9bab0ed | 2017-03-20 09:50:52 -0400 | [diff] [blame] | 2802 | .. attribute:: PRECERT_SIGNED_CERTIFICATE_TIMESTAMPS |
| 2803 | |
| 2804 | .. versionadded:: 1.9 |
| 2805 | |
| 2806 | Corresponds to the dotted string ``"1.3.6.1.4.1.11129.2.4.2"``. |
| 2807 | |
Paul Kehrer | 7e8fe9d | 2015-05-18 09:53:47 -0700 | [diff] [blame] | 2808 | .. attribute:: POLICY_CONSTRAINTS |
| 2809 | |
| 2810 | Corresponds to the dotted string ``"2.5.29.36"``. The identifier for the |
Paul Kehrer | 20f0df5 | 2016-02-26 08:37:13 -0600 | [diff] [blame] | 2811 | :class:`~cryptography.x509.PolicyConstraints` extension type. |
Paul Kehrer | 7e8fe9d | 2015-05-18 09:53:47 -0700 | [diff] [blame] | 2812 | |
Paul Kehrer | b76bcf8 | 2017-09-24 08:44:12 +0800 | [diff] [blame^] | 2813 | .. attribute:: FRESHEST_CRL |
| 2814 | |
| 2815 | Corresponds to the dotted string ``"2.5.29.46"``. The identifier for the |
| 2816 | :class:`~cryptography.x509.FreshestCRL` extension type. |
| 2817 | |
Paul Kehrer | 7e8fe9d | 2015-05-18 09:53:47 -0700 | [diff] [blame] | 2818 | |
Paul Kehrer | c6242dc | 2015-12-25 16:36:46 -0600 | [diff] [blame] | 2819 | .. class:: CRLEntryExtensionOID |
| 2820 | |
| 2821 | .. versionadded:: 1.2 |
| 2822 | |
| 2823 | .. attribute:: CERTIFICATE_ISSUER |
| 2824 | |
| 2825 | Corresponds to the dotted string ``"2.5.29.29"``. |
| 2826 | |
| 2827 | .. attribute:: CRL_REASON |
| 2828 | |
| 2829 | Corresponds to the dotted string ``"2.5.29.21"``. |
| 2830 | |
| 2831 | .. attribute:: INVALIDITY_DATE |
| 2832 | |
| 2833 | Corresponds to the dotted string ``"2.5.29.24"``. |
| 2834 | |
Paul Kehrer | 8b89bcc | 2016-09-03 11:31:43 -0500 | [diff] [blame] | 2835 | Helper Functions |
| 2836 | ~~~~~~~~~~~~~~~~ |
| 2837 | .. currentmodule:: cryptography.x509 |
| 2838 | |
| 2839 | .. function:: random_serial_number() |
| 2840 | |
| 2841 | .. versionadded:: 1.6 |
| 2842 | |
| 2843 | Generates a random serial number suitable for use when constructing |
| 2844 | certificates. |
| 2845 | |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 2846 | Exceptions |
| 2847 | ~~~~~~~~~~ |
Paul Kehrer | e27f658 | 2015-08-10 18:33:38 -0500 | [diff] [blame] | 2848 | .. currentmodule:: cryptography.x509 |
Paul Kehrer | 912d3fb | 2015-01-29 11:19:22 -0600 | [diff] [blame] | 2849 | |
Paul Kehrer | e76cd27 | 2014-12-14 19:00:51 -0600 | [diff] [blame] | 2850 | .. class:: InvalidVersion |
Paul Kehrer | a68fd33 | 2014-11-27 07:08:40 -1000 | [diff] [blame] | 2851 | |
| 2852 | 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] | 2853 | |
Paul Kehrer | d5cccf7 | 2014-12-15 17:20:33 -0600 | [diff] [blame] | 2854 | .. attribute:: parsed_version |
| 2855 | |
Paul Kehrer | bbffc40 | 2014-12-17 13:33:55 -0600 | [diff] [blame] | 2856 | :type: int |
| 2857 | |
| 2858 | Returns the raw version that was parsed from the certificate. |
Paul Kehrer | d5cccf7 | 2014-12-15 17:20:33 -0600 | [diff] [blame] | 2859 | |
Paul Kehrer | fbb7ac8 | 2015-03-16 19:26:29 -0500 | [diff] [blame] | 2860 | .. class:: DuplicateExtension |
| 2861 | |
| 2862 | This is raised when more than one X.509 extension of the same type is |
| 2863 | found within a certificate. |
| 2864 | |
| 2865 | .. attribute:: oid |
| 2866 | |
| 2867 | :type: :class:`ObjectIdentifier` |
| 2868 | |
| 2869 | Returns the OID. |
| 2870 | |
Paul Kehrer | fa56a23 | 2015-03-17 13:14:03 -0500 | [diff] [blame] | 2871 | .. class:: ExtensionNotFound |
| 2872 | |
| 2873 | This is raised when calling :meth:`Extensions.get_extension_for_oid` with |
| 2874 | an extension OID that is not present in the certificate. |
| 2875 | |
| 2876 | .. attribute:: oid |
| 2877 | |
| 2878 | :type: :class:`ObjectIdentifier` |
| 2879 | |
| 2880 | Returns the OID. |
| 2881 | |
Paul Kehrer | 9089c91 | 2015-04-20 22:15:20 -0500 | [diff] [blame] | 2882 | .. class:: UnsupportedGeneralNameType |
| 2883 | |
| 2884 | This is raised when a certificate contains an unsupported general name |
| 2885 | type in an extension. |
| 2886 | |
Paul Kehrer | bed0735 | 2015-04-21 08:31:10 -0500 | [diff] [blame] | 2887 | .. attribute:: type |
| 2888 | |
Paul Kehrer | 0a621bf | 2015-04-22 09:22:56 -0500 | [diff] [blame] | 2889 | :type: int |
| 2890 | |
| 2891 | The integer value of the unsupported type. The complete list of |
| 2892 | types can be found in `RFC 5280 section 4.2.1.6`_. |
Paul Kehrer | bed0735 | 2015-04-21 08:31:10 -0500 | [diff] [blame] | 2893 | |
Paul Kehrer | 016e08a | 2014-11-26 09:41:18 -1000 | [diff] [blame] | 2894 | |
Paul Kehrer | c7c9a43 | 2015-04-19 09:20:13 -0500 | [diff] [blame] | 2895 | .. _`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] | 2896 | .. _`RFC 5280 section 4.2.1.6`: https://tools.ietf.org/html/rfc5280#section-4.2.1.6 |
Paul Kehrer | 8b89bcc | 2016-09-03 11:31:43 -0500 | [diff] [blame] | 2897 | .. _`CABForum Guidelines`: https://cabforum.org/baseline-requirements-documents/ |