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