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