]> git.ipfire.org Git - thirdparty/openssl.git/blame - doc/man3/OCSP_resp_find_status.pod
add getter for tbsResponseData and signatureAlgorithm on OCSP_BASICRESP
[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 9OCSP_resp_get0_produced_at,
20c36721
PK
10OCSP_resp_get0_tbs_sigalg,
11OCSP_resp_get0_respdata,
c952780c 12OCSP_resp_find_status, OCSP_resp_count, OCSP_resp_get0, OCSP_resp_find,
b8c32081
DO
13OCSP_single_get0_status, OCSP_check_validity,
14OCSP_basic_verify
c952780c 15- OCSP response utility functions
797a89a1
DSH
16
17=head1 SYNOPSIS
18
19 #include <openssl/ocsp.h>
20
21 int OCSP_resp_find_status(OCSP_BASICRESP *bs, OCSP_CERTID *id, int *status,
22 int *reason,
23 ASN1_GENERALIZEDTIME **revtime,
24 ASN1_GENERALIZEDTIME **thisupd,
25 ASN1_GENERALIZEDTIME **nextupd);
26
27 int OCSP_resp_count(OCSP_BASICRESP *bs);
28 OCSP_SINGLERESP *OCSP_resp_get0(OCSP_BASICRESP *bs, int idx);
29 int OCSP_resp_find(OCSP_BASICRESP *bs, OCSP_CERTID *id, int last);
30 int OCSP_single_get0_status(OCSP_SINGLERESP *single, int *reason,
31 ASN1_GENERALIZEDTIME **revtime,
32 ASN1_GENERALIZEDTIME **thisupd,
33 ASN1_GENERALIZEDTIME **nextupd);
34
79613ea8
MC
35 const ASN1_GENERALIZEDTIME *OCSP_resp_get0_produced_at(
36 const OCSP_BASICRESP* single);
213f60bf 37
20c36721
PK
38 const X509_ALGOR *OCSP_resp_get0_tbs_sigalg(const OCSP_BASICRESP *bs);
39 const OCSP_RESPDATA *OCSP_resp_get0_respdata(const OCSP_BASICRESP *bs);
02fb7cfe
DSH
40 const STACK_OF(X509) *OCSP_resp_get0_certs(const OCSP_BASICRESP *bs);
41
b741fcd2 42 int OCSP_resp_get0_signer(OCSP_BASICRESP *bs, X509 **signer,
ce5886dd
BK
43 STACK_OF(X509) *extra_certs);
44
02fb7cfe
DSH
45 int OCSP_resp_get0_id(const OCSP_BASICRESP *bs,
46 const ASN1_OCTET_STRING **pid,
47 const X509_NAME **pname);
db17e43d
SS
48 int OCSP_resp_get1_id(const OCSP_BASICRESP *bs,
49 ASN1_OCTET_STRING **pid,
50 X509_NAME **pname);
02fb7cfe 51
797a89a1
DSH
52 int OCSP_check_validity(ASN1_GENERALIZEDTIME *thisupd,
53 ASN1_GENERALIZEDTIME *nextupd,
54 long sec, long maxsec);
55
b8c32081
DO
56 int OCSP_basic_verify(OCSP_BASICRESP *bs, STACK_OF(X509) *certs,
57 X509_STORE *st, unsigned long flags);
58
797a89a1
DSH
59=head1 DESCRIPTION
60
61OCSP_resp_find_status() searches B<bs> for an OCSP response for B<id>. If it is
62successful the fields of the response are returned in B<*status>, B<*reason>,
63B<*revtime>, B<*thisupd> and B<*nextupd>. The B<*status> value will be one of
64B<V_OCSP_CERTSTATUS_GOOD>, B<V_OCSP_CERTSTATUS_REVOKED> or
65B<V_OCSP_CERTSTATUS_UNKNOWN>. The B<*reason> and B<*revtime> fields are only
66set if the status is B<V_OCSP_CERTSTATUS_REVOKED>. If set the B<*reason> field
67will be set to the revocation reason which will be one of
68B<OCSP_REVOKED_STATUS_NOSTATUS>, B<OCSP_REVOKED_STATUS_UNSPECIFIED>,
69B<OCSP_REVOKED_STATUS_KEYCOMPROMISE>, B<OCSP_REVOKED_STATUS_CACOMPROMISE>,
70B<OCSP_REVOKED_STATUS_AFFILIATIONCHANGED>, B<OCSP_REVOKED_STATUS_SUPERSEDED>,
71B<OCSP_REVOKED_STATUS_CESSATIONOFOPERATION>,
72B<OCSP_REVOKED_STATUS_CERTIFICATEHOLD> or B<OCSP_REVOKED_STATUS_REMOVEFROMCRL>.
73
74OCSP_resp_count() returns the number of B<OCSP_SINGLERESP> structures in B<bs>.
75
76OCSP_resp_get0() returns the B<OCSP_SINGLERESP> structure in B<bs>
77corresponding to index B<idx>. Where B<idx> runs from 0 to
78OCSP_resp_count(bs) - 1.
79
80OCSP_resp_find() searches B<bs> for B<id> and returns the index of the first
81matching entry after B<last> or starting from the beginning if B<last> is -1.
82
83OCSP_single_get0_status() extracts the fields of B<single> in B<*reason>,
84B<*revtime>, B<*thisupd> and B<*nextupd>.
85
213f60bf
RS
86OCSP_resp_get0_produced_at() extracts the B<producedAt> field from the
87single response B<bs>.
88
20c36721
PK
89OCSP_resp_get0_tbs_sigalg() returns the B<signatureAlgorithm> from B<bs>.
90
91OCSP_resp_get0_respdata() returns the B<tbsResponseData> from B<bs>.
92
02fb7cfe
DSH
93OCSP_resp_get0_certs() returns any certificates included in B<bs>.
94
eb48052e 95OCSP_resp_get0_signer() attempts to retrieve the certificate that directly
ce5886dd
BK
96signed B<bs>. The OCSP protocol does not require that this certificate
97is included in the B<certs> field of the response, so additional certificates
98can be supplied in B<extra_certs> if the certificates that may have
99signed the response are known via some out-of-band mechanism.
100
101OCSP_resp_get0_id() gets the responder id of B<bs>. If the responder ID is
02fb7cfe
DSH
102a name then <*pname> is set to the name and B<*pid> is set to NULL. If the
103responder ID is by key ID then B<*pid> is set to the key ID and B<*pname>
db17e43d
SS
104is set to NULL. OCSP_resp_get1_id() leaves ownership of B<*pid> and B<*pname>
105with the caller, who is responsible for freeing them. Both functions return 1
106in case of success and 0 in case of failure. If OCSP_resp_get1_id() returns 0,
107no freeing of the results is necessary.
02fb7cfe 108
797a89a1
DSH
109OCSP_check_validity() checks the validity of B<thisupd> and B<nextupd> values
110which will be typically obtained from OCSP_resp_find_status() or
111OCSP_single_get0_status(). If B<sec> is non-zero it indicates how many seconds
112leeway should be allowed in the check. If B<maxsec> is positive it indicates
113the maximum age of B<thisupd> in seconds.
114
b8c32081
DO
115OCSP_basic_verify() checks that the basic response message B<bs> is correctly
116signed and that the signer certificate can be validated. It takes B<st> as
117the trusted store and B<certs> as a set of untrusted intermediate certificates.
118The function first tries to find the signer certificate of the response
119in <certs>. It also searches the certificates the responder may have included
120in B<bs> unless the B<flags> contain B<OCSP_NOINTERN>.
121It fails if the signer certificate cannot be found.
122Next, the function checks the signature of B<bs> and fails on error
123unless the B<flags> contain B<OCSP_NOSIGS>. Then the function already returns
124success if the B<flags> contain B<OCSP_NOVERIFY> or if the signer certificate
125was found in B<certs> and the B<flags> contain B<OCSP_TRUSTOTHER>.
126Otherwise the function continues by validating the signer certificate.
127To this end, all certificates in B<cert> and in B<bs> are considered as
128untrusted certificates for the construction of the validation path for the
129signer certificate unless the B<OCSP_NOCHAIN> flag is set. After successful path
130validation the function returns success if the B<OCSP_NOCHECKS> flag is set.
131Otherwise it verifies that the signer certificate meets the OCSP issuer
132criteria including potential delegation. If this does not succeed and the
133B<flags> do not contain B<OCSP_NOEXPLICIT> the function checks for explicit
134trust for OCSP signing in the root CA certificate.
135
797a89a1
DSH
136=head1 RETURN VALUES
137
138OCSP_resp_find_status() returns 1 if B<id> is found in B<bs> and 0 otherwise.
139
140OCSP_resp_count() returns the total number of B<OCSP_SINGLERESP> fields in
141B<bs>.
142
143OCSP_resp_get0() returns a pointer to an B<OCSP_SINGLERESP> structure or
144B<NULL> if B<idx> is out of range.
145
146OCSP_resp_find() returns the index of B<id> in B<bs> (which may be 0) or -1 if
147B<id> was not found.
148
149OCSP_single_get0_status() returns the status of B<single> or -1 if an error
150occurred.
151
ce5886dd
BK
152OCSP_resp_get0_signer() returns 1 if the signing certificate was located,
153or 0 on error.
154
b8c32081
DO
155OCSP_basic_verify() returns 1 on success, 0 on error, or -1 on fatal error such
156as malloc failure.
157
797a89a1
DSH
158=head1 NOTES
159
160Applications will typically call OCSP_resp_find_status() using the certificate
161ID of interest and then check its validity using OCSP_check_validity(). They
162can then take appropriate action based on the status of the certificate.
163
164An OCSP response for a certificate contains B<thisUpdate> and B<nextUpdate>
165fields. Normally the current time should be between these two values. To
166account for clock skew the B<maxsec> field can be set to non-zero in
167OCSP_check_validity(). Some responders do not set the B<nextUpdate> field, this
168would otherwise mean an ancient response would be considered valid: the
169B<maxsec> parameter to OCSP_check_validity() can be used to limit the permitted
170age of responses.
171
172The values written to B<*revtime>, B<*thisupd> and B<*nextupd> by
173OCSP_resp_find_status() and OCSP_single_get0_status() are internal pointers
174which B<MUST NOT> be freed up by the calling application. Any or all of these
175parameters can be set to NULL if their value is not required.
176
177=head1 SEE ALSO
178
b97fdb57 179L<crypto(7)>,
9b86974e
RS
180L<OCSP_cert_to_id(3)>,
181L<OCSP_request_add1_nonce(3)>,
182L<OCSP_REQUEST_new(3)>,
183L<OCSP_response_status(3)>,
184L<OCSP_sendreq_new(3)>
797a89a1 185
e2f92610
RS
186=head1 COPYRIGHT
187
188Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
189
190Licensed under the OpenSSL license (the "License"). You may not use
191this file except in compliance with the License. You can obtain a copy
192in the file LICENSE in the source distribution or at
193L<https://www.openssl.org/source/license.html>.
194
195=cut