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