OCSP_RESP_FIND_STATUS(3)
okay bestie, welcome to the OCSP_RESP_FIND_STATUS(3) page from the Library Functions Manual β it's giving OCSP response utility functions and honestly it's a whole squad. π
π NAME π
The whole squad on this page is: OCSP_SINGLERESP_new, OCSP_SINGLERESP_free, OCSP_CERTSTATUS_new, OCSP_CERTSTATUS_free, OCSP_REVOKEDINFO_new, OCSP_REVOKEDINFO_free, OCSP_resp_find_status, OCSP_cert_status_str, OCSP_resp_count, OCSP_resp_get0, OCSP_resp_find, OCSP_SINGLERESP_get0_id, OCSP_single_get0_status, OCSP_check_validity, and OCSP_basic_verify β and the official vibe is OCSP response utility functions. periodt. β¨
πΈ SYNOPSIS πΈ
library βlibcryptoβ #include <openssl/ocsp.h>
OCSP_SINGLERESP *
OCSP_SINGLERESP_new(void);
void
OCSP_SINGLERESP_free(OCSP_SINGLERESP *single);
OCSP_CERTSTATUS *
OCSP_CERTSTATUS_new(void);
void
OCSP_CERTSTATUS_free(OCSP_CERTSTATUS *certstatus);
OCSP_REVOKEDINFO *
OCSP_REVOKEDINFO_new(void);
void
OCSP_REVOKEDINFO_free(OCSP_REVOKEDINFO *revokedinfo);
int
OCSP_resp_find_status(OCSP_BASICRESP *bs, OCSP_CERTID *id, int *status,
int *reason, ASN1_GENERALIZEDTIME **revtime,
ASN1_GENERALIZEDTIME **thisupd, ASN1_GENERALIZEDTIME **nextupd);
const char *
OCSP_cert_status_str(long status);
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);
const OCSP_CERTID *
OCSP_SINGLERESP_get0_id(const OCSP_SINGLERESP *single);
int
OCSP_single_get0_status(OCSP_SINGLERESP *single, int *reason,
ASN1_GENERALIZEDTIME **revtime, ASN1_GENERALIZEDTIME **thisupd,
ASN1_GENERALIZEDTIME **nextupd);
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_SINGLERESP_new()β allocates and initializes an emptyOCSP_SINGLERESPobject, representing an ASN.1SingleResponsestructure defined in RFC 6960. Each such object can store the server's answer regarding the validity of one individual certificate. Such objects are used inside theOCSP_RESPDATAofOCSP_BASICRESPobjects, which are described inOCSP_BASICRESP_new(3).OCSP_SINGLERESP_free()freessingle. πOCSP_CERTSTATUS_new()β allocates and initializes an emptyOCSP_CERTSTATUSobject, representing an ASN.1CertStatusstructure defined in RFC 6960. Such an object is used insideOCSP_SINGLERESP.OCSP_CERTSTATUS_free()freescertstatus. β¨OCSP_REVOKEDINFO_new()β allocates and initializes an emptyOCSP_REVOKEDINFOobject, representing an ASN.1RevokedInfostructure defined in RFC 6960. Such an object is used insideOCSP_CERTSTATUS.OCSP_REVOKEDINFO_free()freesrevokedinfo. πOCSP_resp_find_status()β searchesbsfor an OCSP response forid. If it is 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_REVOKED, orV_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_cert_status_str()β converts one of the status codes retrieved byOCSP_resp_find_status()to a string consisting of one word. no cap. πOCSP_resp_count()β returns the number ofOCSP_SINGLERESPstructures inbs. π§OCSP_resp_get0()β returns theOCSP_SINGLERESPstructure inbscorresponding to indexidx, whereidxruns from 0 toOCSP_resp_count(bs) - 1. πOCSP_resp_find()β searchesbsforidand returns the index of the first matching entry afterlastor starting from the beginning iflastis-1. βOCSP_single_get0_status()β extracts the fields ofsinglein*reason,*revtime,*thisupd, and*nextupd. πOCSP_check_validity()β checks the validity ofthisupdandnextupdvalues which will be typically obtained fromOCSP_resp_find_status()orOCSP_single_get0_status(). Ifsecis non-zero, it indicates how many seconds leeway should be allowed in the check. Ifmaxsecis positive, it indicates the maximum age ofthisupdin seconds. π
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 non-zero 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. π
OCSP_basic_verify() 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. The function first tries to find the signer certificate of the response in certs. It also searches the certificates the responder may have included in bs unless the flags contain OCSP_NOINTERN. It fails if the signer certificate cannot be found. Next, the function checks the signature of bs and fails on error unless the flags contain OCSP_NOSIGS. Then the function already returns success if the flags contain OCSP_NOVERIFY or if the signer certificate was found in certs and the flags contain OCSP_TRUSTOTHER. Otherwise the function continues by validating the signer certificate. To this end, all certificates in certs and in bs are considered as untrusted certificates for the construction of the validation path for the signer certificate unless the OCSP_NOCHAIN flag is set. After successful path validation, the function returns success if the OCSP_NOCHECKS flag is set. Otherwise it verifies that the signer certificate meets the OCSP issuer criteria including potential delegation. If this does not succeed and the flags do not contain OCSP_NOEXPLICIT, the function checks for explicit trust for OCSP signing in the root CA certificate. π
π RETURN VALUES π
OCSP_SINGLERESP_new(),OCSP_CERTSTATUS_new(), andOCSP_REVOKEDINFO_new()return a pointer to an emptyOCSP_SINGLERESP,OCSP_CERTSTATUS, orOCSP_REVOKEDINFOobject, respectively, orNULLif an error occurred. πΈOCSP_resp_find_status()returns1ifidis found inbsor0otherwise. β¨OCSP_cert_status_str()returns a pointer to a static string. πOCSP_resp_count()returns the total number ofOCSP_SINGLERESPfields inbs. π¦OCSP_resp_get0()returns a pointer to anOCSP_SINGLERESPstructure orNULLifidxis out of range. πOCSP_resp_find()returns the index ofidinbs(which may be0) or-1ifidwas not found. π₯OCSP_SINGLERESP_get0_id()returns an internal pointer to the certificate ID object used bysingle; the returned pointer should not be freed by the caller. πOCSP_single_get0_status()returns the status ofsingleor-1if an error occurred. βOCSP_basic_verify()returns1on success,0on error, or-1on fatal error such asmallocfailure. π
π«Ά SEE ALSO π«Ά
OCSP_cert_to_id(3), OCSP_CRLID_new(3), OCSP_request_add1_nonce(3), OCSP_REQUEST_new(3), OCSP_response_status(3), OCSP_sendreq_new(3)
π STANDARDS π
RFC 6960: X.509 Internet Public Key Infrastructure Online Certificate Status Protocol, section 4.2: Response Syntax
π§ HISTORY π§
OCSP_SINGLERESP_new(), OCSP_SINGLERESP_free(), OCSP_CERTSTATUS_new(), OCSP_CERTSTATUS_free(), OCSP_REVOKEDINFO_new(), OCSP_REVOKEDINFO_free(), OCSP_resp_find_status(), OCSP_cert_status_str(), OCSP_resp_count(), OCSP_resp_get0(), OCSP_resp_find(), OCSP_single_get0_status(), and OCSP_check_validity() first appeared in OpenSSL 0.9.7 and have been available since OpenBSD 3.2. π
OCSP_SINGLERESP_get0_id() first appeared in OpenSSL 1.1.0 and has been available since OpenBSD 6.3. π¦
mwah π source/version: Debian β date: June 8, 2025 β manual: OCSP_RESP_FIND_STATUS(3) β¨
π¦ where this page comes from
- alpine 3.24: libressl-doc 4.3.1-r0 Β· custom
- arch rolling: libressl 4.4.0-1 Β· ISC AND custom:OpenSSL
- Copyright (c) 2016, 2018, 2019 Ingo Schwarze <schwarze@openbsd.org>
- Copyright (c) 2014, 2018 The OpenSSL Project. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms