2dcd318f547806c823b1b504f369bd332c3067c8
[openssl.git] / doc / crypto / OCSP_resp_find_status.pod
1 =pod
2
3 =head1 NAME
4
5 OCSP_resp_get0_certs,
6 OCSP_resp_get0_id,
7 OCSP_resp_get0_produced_at,
8 OCSP_resp_find_status, OCSP_resp_count, OCSP_resp_get0, OCSP_resp_find,
9 OCSP_single_get0_status, OCSP_check_validity
10 - OCSP response utility functions
11
12 =head1 SYNOPSIS
13
14  #include <openssl/ocsp.h>
15
16  int OCSP_resp_find_status(OCSP_BASICRESP *bs, OCSP_CERTID *id, int *status,
17                            int *reason,
18                            ASN1_GENERALIZEDTIME **revtime,
19                            ASN1_GENERALIZEDTIME **thisupd,
20                            ASN1_GENERALIZEDTIME **nextupd);
21
22  int OCSP_resp_count(OCSP_BASICRESP *bs);
23  OCSP_SINGLERESP *OCSP_resp_get0(OCSP_BASICRESP *bs, int idx);
24  int OCSP_resp_find(OCSP_BASICRESP *bs, OCSP_CERTID *id, int last);
25  int OCSP_single_get0_status(OCSP_SINGLERESP *single, int *reason,
26                              ASN1_GENERALIZEDTIME **revtime,
27                              ASN1_GENERALIZEDTIME **thisupd,
28                              ASN1_GENERALIZEDTIME **nextupd);
29
30  ASN1_GENERALIZEDTIME *OCSP_resp_get0_produced_at(OCSP_BASICRESP* single);
31
32  const STACK_OF(X509) *OCSP_resp_get0_certs(const OCSP_BASICRESP *bs);
33
34  int OCSP_resp_get0_id(const OCSP_BASICRESP *bs,
35                        const ASN1_OCTET_STRING **pid,
36                        const X509_NAME **pname);
37
38  int OCSP_check_validity(ASN1_GENERALIZEDTIME *thisupd,
39                          ASN1_GENERALIZEDTIME *nextupd,
40                          long sec, long maxsec);
41
42 =head1 DESCRIPTION
43
44 OCSP_resp_find_status() searches B<bs> for an OCSP response for B<id>. If it is
45 successful the fields of the response are returned in B<*status>, B<*reason>,
46 B<*revtime>, B<*thisupd> and B<*nextupd>.  The B<*status> value will be one of
47 B<V_OCSP_CERTSTATUS_GOOD>, B<V_OCSP_CERTSTATUS_REVOKED> or
48 B<V_OCSP_CERTSTATUS_UNKNOWN>. The B<*reason> and B<*revtime> fields are only
49 set if the status is B<V_OCSP_CERTSTATUS_REVOKED>. If set the B<*reason> field
50 will be set to the revocation reason which will be one of
51 B<OCSP_REVOKED_STATUS_NOSTATUS>, B<OCSP_REVOKED_STATUS_UNSPECIFIED>,
52 B<OCSP_REVOKED_STATUS_KEYCOMPROMISE>, B<OCSP_REVOKED_STATUS_CACOMPROMISE>,
53 B<OCSP_REVOKED_STATUS_AFFILIATIONCHANGED>, B<OCSP_REVOKED_STATUS_SUPERSEDED>,
54 B<OCSP_REVOKED_STATUS_CESSATIONOFOPERATION>,
55 B<OCSP_REVOKED_STATUS_CERTIFICATEHOLD> or B<OCSP_REVOKED_STATUS_REMOVEFROMCRL>.
56
57 OCSP_resp_count() returns the number of B<OCSP_SINGLERESP> structures in B<bs>.
58
59 OCSP_resp_get0() returns the B<OCSP_SINGLERESP> structure in B<bs>
60 corresponding to index B<idx>. Where B<idx> runs from 0 to
61 OCSP_resp_count(bs) - 1.
62
63 OCSP_resp_find() searches B<bs> for B<id> and returns the index of the first
64 matching entry after B<last> or starting from the beginning if B<last> is -1.
65
66 OCSP_single_get0_status() extracts the fields of B<single> in B<*reason>,
67 B<*revtime>, B<*thisupd> and B<*nextupd>.
68
69 OCSP_resp_get0_produced_at() extracts the B<producedAt> field from the
70 single response B<bs>.
71
72 OCSP_resp_get0_certs() returns any certificates included in B<bs>.
73
74 OCSP_resp_get0_id() gets the responder id of <bs>. If the responder ID is
75 a name then <*pname> is set to the name and B<*pid> is set to NULL. If the
76 responder ID is by key ID then B<*pid> is set to the key ID and B<*pname>
77 is set to NULL.
78
79 OCSP_check_validity() checks the validity of B<thisupd> and B<nextupd> values
80 which will be typically obtained from OCSP_resp_find_status() or
81 OCSP_single_get0_status(). If B<sec> is non-zero it indicates how many seconds
82 leeway should be allowed in the check. If B<maxsec> is positive it indicates
83 the maximum age of B<thisupd> in seconds.
84
85 =head1 RETURN VALUES
86
87 OCSP_resp_find_status() returns 1 if B<id> is found in B<bs> and 0 otherwise.
88
89 OCSP_resp_count() returns the total number of B<OCSP_SINGLERESP> fields in
90 B<bs>.
91
92 OCSP_resp_get0() returns a pointer to an B<OCSP_SINGLERESP> structure or
93 B<NULL> if B<idx> is out of range.
94
95 OCSP_resp_find() returns the index of B<id> in B<bs> (which may be 0) or -1 if
96 B<id> was not found.
97
98 OCSP_single_get0_status() returns the status of B<single> or -1 if an error
99 occurred.
100
101 =head1 NOTES
102
103 Applications will typically call OCSP_resp_find_status() using the certificate
104 ID of interest and then check its validity using OCSP_check_validity(). They
105 can then take appropriate action based on the status of the certificate.
106
107 An OCSP response for a certificate contains B<thisUpdate> and B<nextUpdate>
108 fields. Normally the current time should be between these two values. To
109 account for clock skew the B<maxsec> field can be set to non-zero in
110 OCSP_check_validity(). Some responders do not set the B<nextUpdate> field, this
111 would otherwise mean an ancient response would be considered valid: the
112 B<maxsec> parameter to OCSP_check_validity() can be used to limit the permitted
113 age of responses.
114
115 The values written to B<*revtime>, B<*thisupd> and B<*nextupd> by
116 OCSP_resp_find_status() and OCSP_single_get0_status() are internal pointers
117 which B<MUST NOT> be freed up by the calling application. Any or all of these
118 parameters can be set to NULL if their value is not required.
119
120 =head1 SEE ALSO
121
122 L<crypto(3)>,
123 L<OCSP_cert_to_id(3)>,
124 L<OCSP_request_add1_nonce(3)>,
125 L<OCSP_REQUEST_new(3)>,
126 L<OCSP_response_status(3)>,
127 L<OCSP_sendreq_new(3)>
128
129 =head1 COPYRIGHT
130
131 Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
132
133 Licensed under the OpenSSL license (the "License").  You may not use
134 this file except in compliance with the License.  You can obtain a copy
135 in the file LICENSE in the source distribution or at
136 L<https://www.openssl.org/source/license.html>.
137
138 =cut