blob: 72227f072f328d5b6788e64e11062513cd1727a7 [file] [log] [blame]
Paul Kehrer732cf642018-08-15 18:04:28 -05001OCSP
2====
3
4.. currentmodule:: cryptography.x509.ocsp
5
6.. testsetup::
7
8 der_ocsp_req = (
9 b"0V0T0R0P0N0\t\x06\x05+\x0e\x03\x02\x1a\x05\x00\x04\x148\xcaF\x8c"
10 b"\x07D\x8d\xf4\x81\x96\xc7mmLpQ\x9e`\xa7\xbd\x04\x14yu\xbb\x84:\xcb"
11 b",\xdez\t\xbe1\x1bC\xbc\x1c*MSX\x02\x15\x00\x98\xd9\xe5\xc0\xb4\xc3"
12 b"sU-\xf7|]\x0f\x1e\xb5\x12\x8eIE\xf9"
13 )
14
15OCSP (Online Certificate Status Protocol) is a method of checking the
16revocation status of certificates. It is specified in :rfc:`6960`, as well
17as other obsoleted RFCs.
18
19
20Loading Requests
21~~~~~~~~~~~~~~~~
22
23.. function:: load_der_ocsp_request(data)
24
25 .. versionadded:: 2.4
26
27 Deserialize an OCSP request from DER encoded data.
28
29 :param bytes data: The DER encoded OCSP request data.
30
31 :returns: An instance of :class:`~cryptography.x509.ocsp.OCSPRequest`.
32
33 .. doctest::
34
35 >>> from cryptography.x509 import ocsp
36 >>> ocsp_req = ocsp.load_der_ocsp_request(der_ocsp_req)
37 >>> for request in ocsp_req:
38 ... print(request.serial_number)
39 872625873161273451176241581705670534707360122361
40
41
42Interfaces
43~~~~~~~~~~
44
45.. class:: OCSPRequest
46
47 .. versionadded:: 2.4
48
49 An ``OCSPRequest`` is an iterable containing one or more
50 :class:`~cryptography.x509.ocsp.Request` objects.
51
52 .. method:: public_bytes(encoding)
53
54 :param encoding: The encoding to use. Only
55 :attr:`~cryptography.hazmat.primitives.serialization.Encoding.DER`
56 is supported.
57
58 :return bytes: The serialized OCSP request.
59
60.. class:: Request
61
62 .. versionadded:: 2.4
63
64 A ``Request`` contains several attributes that create a unique identifier
65 for a certificate whose status is being checked. It may also contain
66 additional extensions (currently unsupported).
67
68 .. attribute:: issuer_key_hash
69
70 :type: bytes
71
72 The hash of the certificate issuer's key. The hash algorithm used
73 is defined by the ``hash_algorithm`` property.
74
75 .. attribute:: issuer_name_hash
76
77 :type: bytes
78
79 The hash of the certificate issuer's name. The hash algorithm used
80 is defined by the ``hash_algorithm`` property.
81
82 .. attribute:: hash_algorithm
83
84 :type: An instance of a
85 :class:`~cryptography.hazmat.primitives.hashes.Hash`
86
87 The algorithm used to generate the ``issuer_key_hash`` and
88 ``issuer_name_hash``.
89
90 .. attribute:: serial_number
91
92 :type: int
93
94 The serial number of the certificate to check.