OCSP_RESP_FIND_STATUS(3ossl)
π
OCSP_resp_find_status β the OpenSSL 3ossl girlies' guide
okay so this is the 3ossl manual page for the OCSP response utility function squad, and honestly? it's giving "backstage pass to certificate status checking." let's get into it π
β¨ NAME β¨
The whole girl group is here β OCSP_resp_find_status, OCSP_resp_count, OCSP_resp_get0, OCSP_resp_find, OCSP_single_get0_status, OCSP_resp_get0_produced_at, OCSP_resp_get0_signature, OCSP_resp_get0_tbs_sigalg, OCSP_resp_get0_respdata, OCSP_resp_get0_certs, OCSP_resp_get0_signer, OCSP_resp_get0_id, OCSP_resp_get1_id, OCSP_check_validity, and OCSP_basic_verify β and they're all here doing OCSP response utility functions. iconic lineup, no skips π
πΈ SYNOPSIS πΈ
#include <openssl/ocsp.h>
int OCSP_resp_find_status(OCSP_BASICRESP *bs, OCSP_CERTID *id, int *status,
int *reason,
ASN1_GENERALIZEDTIME **revtime,
ASN1_GENERALIZEDTIME **thisupd,
ASN1_GENERALIZEDTIME **nextupd);
int OCSP_resp_count(OCSP_BASICRESP *bs);
OCSP_SINGLERESP *OCSP_resp_get0(OCSP_BASICRESP *bs, int idx);
int OCSP_resp_find(OCSP_BASICRESP *bs, OCSP_CERTID *id, int last);
int OCSP_single_get0_status(OCSP_SINGLERESP *single, int *reason,
ASN1_GENERALIZEDTIME **revtime,
ASN1_GENERALIZEDTIME **thisupd,
ASN1_GENERALIZEDTIME **nextupd);
const ASN1_GENERALIZEDTIME *OCSP_resp_get0_produced_at(
const OCSP_BASICRESP* single);
const ASN1_OCTET_STRING *OCSP_resp_get0_signature(const OCSP_BASICRESP *bs);
const X509_ALGOR *OCSP_resp_get0_tbs_sigalg(const OCSP_BASICRESP *bs);
const OCSP_RESPDATA *OCSP_resp_get0_respdata(const OCSP_BASICRESP *bs);
const STACK_OF(X509) *OCSP_resp_get0_certs(const OCSP_BASICRESP *bs);
int OCSP_resp_get0_signer(OCSP_BASICRESP *bs, X509 **signer,
STACK_OF(X509) *extra_certs);
int OCSP_resp_get0_id(const OCSP_BASICRESP *bs,
const ASN1_OCTET_STRING **pid,
const X509_NAME **pname);
int OCSP_resp_get1_id(const OCSP_BASICRESP *bs,
ASN1_OCTET_STRING **pid,
X509_NAME **pname);
int OCSP_check_validity(ASN1_GENERALIZEDTIME *thisupd,
ASN1_GENERALIZEDTIME *nextupd,
long sec, long maxsec);
int OCSP_basic_verify(OCSP_BASICRESP *bs, STACK_OF(X509) *certs,
X509_STORE *st, unsigned long flags);
π¦ DESCRIPTION π¦
OCSP_resp_find_status() goes digging through bs looking for an OCSP response for id. found it? slay β the fields of that response get dropped into *status, *reason, *revtime, *thisupd and *nextupd. the *status value is gonna be one of V_OCSP_CERTSTATUS_GOOD, V_OCSP_CERTSTATUS_REVOKED or V_OCSP_CERTSTATUS_UNKNOWN. heads up tho: *reason and *revtime only get set if the status is V_OCSP_CERTSTATUS_REVOKED. and if *reason is set, it's the revocation reason, which will be one of:
OCSP_REVOKED_STATUS_NOSTATUSOCSP_REVOKED_STATUS_UNSPECIFIEDOCSP_REVOKED_STATUS_KEYCOMPROMISEOCSP_REVOKED_STATUS_CACOMPROMISEOCSP_REVOKED_STATUS_AFFILIATIONCHANGEDOCSP_REVOKED_STATUS_SUPERSEDEDOCSP_REVOKED_STATUS_CESSATIONOFOPERATIONOCSP_REVOKED_STATUS_CERTIFICATEHOLDOCSP_REVOKED_STATUS_REMOVEFROMCRL
OCSP_resp_count() just tells you how many OCSP_SINGLERESP structures are living in bs. headcount, basically π
OCSP_resp_get0() hands you the OCSP_SINGLERESP structure in bs at index idx, where idx runs from 0 to OCSP_resp_count(bs) - 1. zero-indexed besties, you know the drill.
OCSP_resp_find() searches bs for id and gives you back the index of the first matching entry after last β or starting from the beginning if last is -1.
OCSP_single_get0_status() extracts the fields of single into *reason, *revtime, *thisupd and *nextupd.
OCSP_resp_get0_produced_at() extracts the producedAt field from the single response bs. timestamp tea β
OCSP_resp_get0_signature() returns the signature from bs.
OCSP_resp_get0_tbs_sigalg() returns the signatureAlgorithm from bs.
OCSP_resp_get0_respdata() returns the tbsResponseData from bs.
OCSP_resp_get0_certs() returns any certificates included in bs.
OCSP_resp_get0_signer() tries to retrieve the certificate that directly signed bs. plot twist: the OCSP protocol does not require that this certificate is included in the certs field of the response π so if you already know (via some out-of-band mechanism) which certificates might have signed the response, you can pass them in through extra_certs. very "bring your own proof" of it.
OCSP_resp_get0_id() gets the responder id of bs. if the responder ID is a name, then <*pname> is set to the name and *pid is set to NULL. if the responder ID is by key ID, then *pid is set to the key ID and *pname is set to NULL. one or the other, never both, we don't do ambiguity here β¨
OCSP_resp_get1_id() is the same as OCSP_resp_get0_id() but it leaves ownership of *pid and *pname with the caller β and you're responsible for freeing them unless the function returns 0. so like, you own it now, congrats, also don't forget to clean up π«Ά
OCSP_check_validity() checks the validity of its thisupd and nextupd arguments, which you'd typically get from OCSP_resp_find_status() or OCSP_single_get0_status(). if sec is nonzero it tells you how many seconds of leeway should be allowed in the check. if maxsec is positive it tells you the maximum age of thisupd, in seconds.
OCSP_basic_verify() is the big one β it checks that the basic response message bs is correctly signed and that the signer certificate can be validated. it takes st as the trusted store and certs as a set of untrusted intermediate certificates. here's the whole journey:
- First it tries to find the signer certificate of the response in
certs. - Then it searches the certificates the responder may have included in
bsβ unlessflagscontainsOCSP_NOINTERN. - It fails if the signer certificate cannot be found.
- Next, unless
flagscontainsOCSP_NOSIGS, the function checks the signature ofbsand fails on error. - Then the function already returns success if
flagscontainsOCSP_NOVERIFY, or if the signer certificate was found incertsandflagscontainsOCSP_TRUSTOTHER. - Otherwise the function continues by validating the signer certificate.
- If
flagscontainsOCSP_PARTIAL_CHAINit takes intermediate CA certificates instas trust anchors. for more details, see the description ofX509_V_FLAG_PARTIAL_CHAINin "VERIFICATION FLAGS" inX509_VERIFY_PARAM_set_flags(3). - If
flagscontainsOCSP_NOCHAINit ignores all certificates incertsand inbs; else it takes them as untrusted intermediate CA certificates and uses them for constructing the validation path for the signer certificate. - Certificate revocation status checks using CRLs is disabled during path validation if the signer certificate contains the
id-pkix-ocsp-no-checkextension. - After successful path validation the function returns success if the
OCSP_NOCHECKSflag is set. - Otherwise it verifies that the signer certificate meets the OCSP issuer criteria, including potential delegation.
- If this does not succeed and the
OCSP_NOEXPLICITflag is not set, the function checks for explicit trust for OCSP signing in the root CA certificate.
that's a whole saga, honestly π but it all makes sense, i promise.
π₯ RETURN VALUES π₯
OCSP_resp_find_status()returns1ifidis found inbsand0otherwise.OCSP_resp_count()returns the total number ofOCSP_SINGLERESPfields inbsor-1on error.OCSP_resp_get0()returns a pointer to anOCSP_SINGLERESPstructure orNULLon error, such asidxbeing out of range.OCSP_resp_find()returns the index ofidinbs(which may be0) or-1on error, such as whenidwas not found.OCSP_single_get0_status()returns the status ofsingleor-1if an error occurred.OCSP_resp_get0_produced_at()returns theproducedAtfield frombs.OCSP_resp_get0_signature()returns the signature frombs.OCSP_resp_get0_tbs_sigalg()returns thesignatureAlgorithmfield frombs.OCSP_resp_get0_respdata()returns thetbsResponseDatafield frombs.OCSP_resp_get0_certs()returns any certificates included inbs.OCSP_resp_get0_signer()returns1if the signing certificate was located, or0if not found or on error.OCSP_resp_get0_id()andOCSP_resp_get1_id()return1on success,0on failure.OCSP_check_validity()returns1ifthisupdandnextupdare valid time values and the current time +secis not beforethisupdand, ifmaxsec >= 0, the current time -maxsecis not pastnextupd. otherwise it returns0to indicate an error.OCSP_basic_verify()returns1on success,0on verification not successful, or-1on a fatal error such as malloc failure.
ngl, the-1onOCSP_basic_verify()is the "something actually broke" signal, not just "the answer was no." don't mix them up bestie π
π NOTES π
Applications will typically call OCSP_resp_find_status() with the certificate ID of interest, then check its validity using OCSP_check_validity(). after that they can take appropriate action based on the status of the certificate. the classic two-step π
An OCSP response for a certificate contains thisUpdate and nextUpdate fields. normally the current time should be between these two values. to account for clock skew, the maxsec field can be set to nonzero in OCSP_check_validity(). also real talk: some responders do not set the nextUpdate field, and this would otherwise mean an ancient response would be considered valid π β the maxsec parameter to OCSP_check_validity() can be used to limit the permitted age of responses. use it, protect yourself.
The values written to*revtime,*thisupdand*nextupdbyOCSP_resp_find_status()andOCSP_single_get0_status()are internal pointers which MUST NOT be freed up by the calling application. i cannot stress this enough β do not free them. any or all of these parameters can be set toNULLif their value is not required, which is honestly so convenient of them.
π SEE ALSO π
crypto(7), OCSP_cert_to_id(3), OCSP_request_add1_nonce(3), OCSP_REQUEST_new(3), OCSP_response_status(3), OCSP_sendreq_new(3), X509_VERIFY_PARAM_set_flags(3)
π COPYRIGHT π
Copyright 2015-2022 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.
and that's the page bestie! π this was OpenSSL 3.5.0, dated 2026-09-25 β OCSP_resp_find_status(3ossl), going out with a slay. π¦β¨
π¦ where this page comes from
- opensuse-leap 16.0: openssl-3-doc 3.5.0-160000.11.1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms