Blame doc/man3/OCSP_resp_find_status.pod

Packit c4476c
=pod
Packit c4476c
Packit c4476c
=head1 NAME
Packit c4476c
Packit c4476c
OCSP_resp_get0_certs,
Packit c4476c
OCSP_resp_get0_signer,
Packit c4476c
OCSP_resp_get0_id,
Packit c4476c
OCSP_resp_get1_id,
Packit c4476c
OCSP_resp_get0_produced_at,
Packit c4476c
OCSP_resp_get0_signature,
Packit c4476c
OCSP_resp_get0_tbs_sigalg,
Packit c4476c
OCSP_resp_get0_respdata,
Packit c4476c
OCSP_resp_find_status, OCSP_resp_count, OCSP_resp_get0, OCSP_resp_find,
Packit c4476c
OCSP_single_get0_status, OCSP_check_validity,
Packit c4476c
OCSP_basic_verify
Packit c4476c
- OCSP response utility functions
Packit c4476c
Packit c4476c
=head1 SYNOPSIS
Packit c4476c
Packit c4476c
 #include <openssl/ocsp.h>
Packit c4476c
Packit c4476c
 int OCSP_resp_find_status(OCSP_BASICRESP *bs, OCSP_CERTID *id, int *status,
Packit c4476c
                           int *reason,
Packit c4476c
                           ASN1_GENERALIZEDTIME **revtime,
Packit c4476c
                           ASN1_GENERALIZEDTIME **thisupd,
Packit c4476c
                           ASN1_GENERALIZEDTIME **nextupd);
Packit c4476c
Packit c4476c
 int OCSP_resp_count(OCSP_BASICRESP *bs);
Packit c4476c
 OCSP_SINGLERESP *OCSP_resp_get0(OCSP_BASICRESP *bs, int idx);
Packit c4476c
 int OCSP_resp_find(OCSP_BASICRESP *bs, OCSP_CERTID *id, int last);
Packit c4476c
 int OCSP_single_get0_status(OCSP_SINGLERESP *single, int *reason,
Packit c4476c
                             ASN1_GENERALIZEDTIME **revtime,
Packit c4476c
                             ASN1_GENERALIZEDTIME **thisupd,
Packit c4476c
                             ASN1_GENERALIZEDTIME **nextupd);
Packit c4476c
Packit c4476c
 const ASN1_GENERALIZEDTIME *OCSP_resp_get0_produced_at(
Packit c4476c
                             const OCSP_BASICRESP* single);
Packit c4476c
Packit c4476c
 const ASN1_OCTET_STRING *OCSP_resp_get0_signature(const OCSP_BASICRESP *bs);
Packit c4476c
 const X509_ALGOR *OCSP_resp_get0_tbs_sigalg(const OCSP_BASICRESP *bs);
Packit c4476c
 const OCSP_RESPDATA *OCSP_resp_get0_respdata(const OCSP_BASICRESP *bs);
Packit c4476c
 const STACK_OF(X509) *OCSP_resp_get0_certs(const OCSP_BASICRESP *bs);
Packit c4476c
Packit c4476c
 int OCSP_resp_get0_signer(OCSP_BASICRESP *bs, X509 **signer,
Packit c4476c
                           STACK_OF(X509) *extra_certs);
Packit c4476c
Packit c4476c
 int OCSP_resp_get0_id(const OCSP_BASICRESP *bs,
Packit c4476c
                       const ASN1_OCTET_STRING **pid,
Packit c4476c
                       const X509_NAME **pname);
Packit c4476c
 int OCSP_resp_get1_id(const OCSP_BASICRESP *bs,
Packit c4476c
                       ASN1_OCTET_STRING **pid,
Packit c4476c
                       X509_NAME **pname);
Packit c4476c
Packit c4476c
 int OCSP_check_validity(ASN1_GENERALIZEDTIME *thisupd,
Packit c4476c
                         ASN1_GENERALIZEDTIME *nextupd,
Packit c4476c
                         long sec, long maxsec);
Packit c4476c
Packit c4476c
 int OCSP_basic_verify(OCSP_BASICRESP *bs, STACK_OF(X509) *certs,
Packit c4476c
                      X509_STORE *st, unsigned long flags);
Packit c4476c
Packit c4476c
=head1 DESCRIPTION
Packit c4476c
Packit c4476c
OCSP_resp_find_status() searches B<bs> for an OCSP response for B<id>. If it is
Packit c4476c
successful the fields of the response are returned in B<*status>, B<*reason>,
Packit c4476c
B<*revtime>, B<*thisupd> and B<*nextupd>.  The B<*status> value will be one of
Packit c4476c
B<V_OCSP_CERTSTATUS_GOOD>, B<V_OCSP_CERTSTATUS_REVOKED> or
Packit c4476c
B<V_OCSP_CERTSTATUS_UNKNOWN>. The B<*reason> and B<*revtime> fields are only
Packit c4476c
set if the status is B<V_OCSP_CERTSTATUS_REVOKED>. If set the B<*reason> field
Packit c4476c
will be set to the revocation reason which will be one of
Packit c4476c
B<OCSP_REVOKED_STATUS_NOSTATUS>, B<OCSP_REVOKED_STATUS_UNSPECIFIED>,
Packit c4476c
B<OCSP_REVOKED_STATUS_KEYCOMPROMISE>, B<OCSP_REVOKED_STATUS_CACOMPROMISE>,
Packit c4476c
B<OCSP_REVOKED_STATUS_AFFILIATIONCHANGED>, B<OCSP_REVOKED_STATUS_SUPERSEDED>,
Packit c4476c
B<OCSP_REVOKED_STATUS_CESSATIONOFOPERATION>,
Packit c4476c
B<OCSP_REVOKED_STATUS_CERTIFICATEHOLD> or B<OCSP_REVOKED_STATUS_REMOVEFROMCRL>.
Packit c4476c
Packit c4476c
OCSP_resp_count() returns the number of B<OCSP_SINGLERESP> structures in B<bs>.
Packit c4476c
Packit c4476c
OCSP_resp_get0() returns the B<OCSP_SINGLERESP> structure in B<bs>
Packit c4476c
corresponding to index B<idx>. Where B<idx> runs from 0 to
Packit c4476c
OCSP_resp_count(bs) - 1.
Packit c4476c
Packit c4476c
OCSP_resp_find() searches B<bs> for B<id> and returns the index of the first
Packit c4476c
matching entry after B<last> or starting from the beginning if B<last> is -1.
Packit c4476c
Packit c4476c
OCSP_single_get0_status() extracts the fields of B<single> in B<*reason>,
Packit c4476c
B<*revtime>, B<*thisupd> and B<*nextupd>.
Packit c4476c
Packit c4476c
OCSP_resp_get0_produced_at() extracts the B<producedAt> field from the
Packit c4476c
single response B<bs>.
Packit c4476c
Packit c4476c
OCSP_resp_get0_signature() returns the signature from B<bs>.
Packit c4476c
Packit c4476c
OCSP_resp_get0_tbs_sigalg() returns the B<signatureAlgorithm> from B<bs>.
Packit c4476c
Packit c4476c
OCSP_resp_get0_respdata() returns the B<tbsResponseData> from B<bs>.
Packit c4476c
Packit c4476c
OCSP_resp_get0_certs() returns any certificates included in B<bs>.
Packit c4476c
Packit c4476c
OCSP_resp_get0_signer() attempts to retrieve the certificate that directly
Packit c4476c
signed B<bs>.  The OCSP protocol does not require that this certificate
Packit c4476c
is included in the B<certs> field of the response, so additional certificates
Packit c4476c
can be supplied in B<extra_certs> if the certificates that may have
Packit c4476c
signed the response are known via some out-of-band mechanism.
Packit c4476c
Packit c4476c
OCSP_resp_get0_id() gets the responder id of B<bs>. If the responder ID is
Packit c4476c
a name then <*pname> is set to the name and B<*pid> is set to NULL. If the
Packit c4476c
responder ID is by key ID then B<*pid> is set to the key ID and B<*pname>
Packit c4476c
is set to NULL. OCSP_resp_get1_id() leaves ownership of B<*pid> and B<*pname>
Packit c4476c
with the caller, who is responsible for freeing them. Both functions return 1
Packit c4476c
in case of success and 0 in case of failure. If OCSP_resp_get1_id() returns 0,
Packit c4476c
no freeing of the results is necessary.
Packit c4476c
Packit c4476c
OCSP_check_validity() checks the validity of B<thisupd> and B<nextupd> values
Packit c4476c
which will be typically obtained from OCSP_resp_find_status() or
Packit c4476c
OCSP_single_get0_status(). If B<sec> is non-zero it indicates how many seconds
Packit c4476c
leeway should be allowed in the check. If B<maxsec> is positive it indicates
Packit c4476c
the maximum age of B<thisupd> in seconds.
Packit c4476c
Packit c4476c
OCSP_basic_verify() checks that the basic response message B<bs> is correctly
Packit c4476c
signed and that the signer certificate can be validated. It takes B<st> as
Packit c4476c
the trusted store and B<certs> as a set of untrusted intermediate certificates.
Packit c4476c
The function first tries to find the signer certificate of the response
Packit c4476c
in <certs>. It also searches the certificates the responder may have included
Packit c4476c
in B<bs> unless the B<flags> contain B<OCSP_NOINTERN>.
Packit c4476c
It fails if the signer certificate cannot be found.
Packit c4476c
Next, the function checks the signature of B<bs> and fails on error
Packit c4476c
unless the B<flags> contain B<OCSP_NOSIGS>. Then the function already returns
Packit c4476c
success if the B<flags> contain B<OCSP_NOVERIFY> or if the signer certificate
Packit c4476c
was found in B<certs> and the B<flags> contain B<OCSP_TRUSTOTHER>.
Packit c4476c
Otherwise the function continues by validating the signer certificate.
Packit c4476c
To this end, all certificates in B<cert> and in B<bs> are considered as
Packit c4476c
untrusted certificates for the construction of the validation path for the
Packit c4476c
signer certificate unless the B<OCSP_NOCHAIN> flag is set. After successful path
Packit c4476c
validation the function returns success if the B<OCSP_NOCHECKS> flag is set.
Packit c4476c
Otherwise it verifies that the signer certificate meets the OCSP issuer
Packit c4476c
criteria including potential delegation. If this does not succeed and the
Packit c4476c
B<flags> do not contain B<OCSP_NOEXPLICIT> the function checks for explicit
Packit c4476c
trust for OCSP signing in the root CA certificate.
Packit c4476c
Packit c4476c
=head1 RETURN VALUES
Packit c4476c
Packit c4476c
OCSP_resp_find_status() returns 1 if B<id> is found in B<bs> and 0 otherwise.
Packit c4476c
Packit c4476c
OCSP_resp_count() returns the total number of B<OCSP_SINGLERESP> fields in
Packit c4476c
B<bs>.
Packit c4476c
Packit c4476c
OCSP_resp_get0() returns a pointer to an B<OCSP_SINGLERESP> structure or
Packit c4476c
B<NULL> if B<idx> is out of range.
Packit c4476c
Packit c4476c
OCSP_resp_find() returns the index of B<id> in B<bs> (which may be 0) or -1 if
Packit c4476c
B<id> was not found.
Packit c4476c
Packit c4476c
OCSP_single_get0_status() returns the status of B<single> or -1 if an error
Packit c4476c
occurred.
Packit c4476c
Packit c4476c
OCSP_resp_get0_signer() returns 1 if the signing certificate was located,
Packit c4476c
or 0 on error.
Packit c4476c
Packit c4476c
OCSP_basic_verify() returns 1 on success, 0 on error, or -1 on fatal error such
Packit c4476c
as malloc failure.
Packit c4476c
Packit c4476c
=head1 NOTES
Packit c4476c
Packit c4476c
Applications will typically call OCSP_resp_find_status() using the certificate
Packit c4476c
ID of interest and then check its validity using OCSP_check_validity(). They
Packit c4476c
can then take appropriate action based on the status of the certificate.
Packit c4476c
Packit c4476c
An OCSP response for a certificate contains B<thisUpdate> and B<nextUpdate>
Packit c4476c
fields. Normally the current time should be between these two values. To
Packit c4476c
account for clock skew the B<maxsec> field can be set to non-zero in
Packit c4476c
OCSP_check_validity(). Some responders do not set the B<nextUpdate> field, this
Packit c4476c
would otherwise mean an ancient response would be considered valid: the
Packit c4476c
B<maxsec> parameter to OCSP_check_validity() can be used to limit the permitted
Packit c4476c
age of responses.
Packit c4476c
Packit c4476c
The values written to B<*revtime>, B<*thisupd> and B<*nextupd> by
Packit c4476c
OCSP_resp_find_status() and OCSP_single_get0_status() are internal pointers
Packit c4476c
which B<MUST NOT> be freed up by the calling application. Any or all of these
Packit c4476c
parameters can be set to NULL if their value is not required.
Packit c4476c
Packit c4476c
=head1 SEE ALSO
Packit c4476c
Packit c4476c
L<crypto(7)>,
Packit c4476c
L<OCSP_cert_to_id(3)>,
Packit c4476c
L<OCSP_request_add1_nonce(3)>,
Packit c4476c
L<OCSP_REQUEST_new(3)>,
Packit c4476c
L<OCSP_response_status(3)>,
Packit c4476c
L<OCSP_sendreq_new(3)>
Packit c4476c
Packit c4476c
=head1 COPYRIGHT
Packit c4476c
Packit c4476c
Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved.
Packit c4476c
Packit c4476c
Licensed under the OpenSSL license (the "License").  You may not use
Packit c4476c
this file except in compliance with the License.  You can obtain a copy
Packit c4476c
in the file LICENSE in the source distribution or at
Packit c4476c
L<https://www.openssl.org/source/license.html>.
Packit c4476c
Packit c4476c
=cut