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