OCSP_RESP_FIND_STATUS(3ossl)
okay so bestie, welcome to OCSP_RESP_FIND_STATUS(3ossl) β the OpenSSL manual page that's literally all about poking around OCSP responses and checking if their vibes (and signatures) are valid β¨. Grab a strawberry π, because this is a whole squad of functions and we're going through every single one.
β¨ NAME β¨
The whole OCSP response utility crew is:
OCSP_resp_find_statusOCSP_resp_countOCSP_resp_get0OCSP_resp_findOCSP_single_get0_statusOCSP_resp_get0_produced_atOCSP_resp_get0_signatureOCSP_resp_get0_tbs_sigalgOCSP_resp_get0_respdataOCSP_resp_get0_certsOCSP_resp_get0_signerOCSP_resp_get0_idOCSP_resp_get1_idOCSP_check_validityOCSP_basic_verify
Together they're the OCSP response utility functions. Periodt.
π SYNOPSIS π
Copy-paste the exact signatures, no cap:
#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 π
Okay so here's the tea on every single one:
OCSP_resp_find_status()β searchesbsfor an OCSP response forid. If it's successful, the fields of the response are returned in*status,*reason,*revtime,*thisupdand*nextupd. The*statusvalue will be one ofV_OCSP_CERTSTATUS_GOOD,V_OCSP_CERTSTATUS_REVOKEDorV_OCSP_CERTSTATUS_UNKNOWN. The*reasonand*revtimefields are only set if the status isV_OCSP_CERTSTATUS_REVOKED. If set, the*reasonfield will be set to the revocation reason, which will be one ofOCSP_REVOKED_STATUS_NOSTATUS,OCSP_REVOKED_STATUS_UNSPECIFIED,OCSP_REVOKED_STATUS_KEYCOMPROMISE,OCSP_REVOKED_STATUS_CACOMPROMISE,OCSP_REVOKED_STATUS_AFFILIATIONCHANGED,OCSP_REVOKED_STATUS_SUPERSEDED,OCSP_REVOKED_STATUS_CESSATIONOFOPERATION,OCSP_REVOKED_STATUS_CERTIFICATEHOLDorOCSP_REVOKED_STATUS_REMOVEFROMCRL.OCSP_resp_count()β returns the number ofOCSP_SINGLERESPstructures inbs.OCSP_resp_get0()β returns theOCSP_SINGLERESPstructure inbscorresponding to indexidx, whereidxruns from0toOCSP_resp_count(bs) - 1.OCSP_resp_find()β searchesbsforidand returns the index of the first matching entry afterlast, or starting from the beginning iflastis-1.OCSP_single_get0_status()β extracts the fields ofsinglein*reason,*revtime,*thisupdand*nextupd.OCSP_resp_get0_produced_at()β extracts theproducedAtfield from the single responsebs.OCSP_resp_get0_signature()β returns the signature frombs.OCSP_resp_get0_tbs_sigalg()β returns thesignatureAlgorithmfrombs.OCSP_resp_get0_respdata()β returns thetbsResponseDatafrombs.OCSP_resp_get0_certs()β returns any certificates included inbs.OCSP_resp_get0_signer()β attempts to retrieve the certificate that directly signedbs. The OCSP protocol does not require that this certificate is included in thecertsfield of the response, so additional certificates can be supplied viaextra_certsif the certificates that may have signed the response are known via some out-of-band mechanism.OCSP_resp_get0_id()β gets the responder id ofbs. If the responder ID is a name then*pnameis set to the name and*pidis set toNULL. If the responder ID is by key ID then*pidis set to the key ID and*pnameis set toNULL.OCSP_resp_get1_id()β is the same asOCSP_resp_get0_id()but leaves ownership of*pidand*pnamewith the caller, who is responsible for freeing them unless the function returns0.OCSP_check_validity()β checks the validity of itsthisupdandnextupdarguments, which will typically be obtained fromOCSP_resp_find_status()orOCSP_single_get0_status(). Ifsecis nonzero it indicates how many seconds leeway should be allowed in the check. Ifmaxsecis positive it indicates the maximum age ofthisupdin seconds.OCSP_basic_verify()β checks that the basic response messagebsis correctly signed and that the signer certificate can be validated. It takesstas the trusted store andcertsas a set of untrusted intermediate certificates. The function first tries to find the signer certificate of the response incerts. It then searches the certificates the responder may have included inbsunlessflagscontainsOCSP_NOINTERN. It fails if the signer certificate cannot be found. Next, unlessflagscontainsOCSP_NOSIGS, the function checks the signature ofbsand fails on error. Then the function already returns success ifflagscontainsOCSP_NOVERIFYor if the signer certificate was found incertsandflagscontainsOCSP_TRUSTOTHER. Otherwise the function continues by validating the signer certificate. IfflagscontainsOCSP_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). IfflagscontainsOCSP_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 theid-pkix-ocsp-no-checkextension. After successful path validation the function returns success if theOCSP_NOCHECKSflag is set. Otherwise it verifies that the signer certificate meets the OCSP issuer criteria including potential delegation. If this does not succeed and theOCSP_NOEXPLICITflag is not set the function checks for explicit trust for OCSP signing in the root CA certificate.
π¦ RETURN VALUES π¦
Here's what each one hands back, bestie:
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.
π§ NOTES π§
Applications will typically call OCSP_resp_find_status() using the certificate ID of interest and then check its validity using OCSP_check_validity(). They can then take appropriate action based on the status of the certificate.
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(). Some responders do not set the nextUpdate field; 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.
The values written to *revtime, *thisupd and *nextupd by OCSP_resp_find_status() and OCSP_single_get0_status() are internal pointers which MUST NOT be freed up by the calling application. Any or all of these parameters can be set to NULL if their value is not required.
bestie please don't free those internal pointers β that's not slay, that's a crash waiting to happen π
π 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>.
okay that's the whole page bestie β this was OpenSSL 3.5.6, dated 2026-04-07, and the manual page is OCSP_RESP_FIND_STATUS(3ossl). Go check those signatures and slay πβ¨
π¦ where this page comes from
- freebsd 15.1: base 15.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms