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