OCSP_REQUEST_NEW(3)
π NAME π
okay so this page is all about the OCSP_REQUEST fam, in the libcrypto library (that's the manual we're in, bestie β Library Functions Manual, yes ma'am β¨). The whole squad:
OCSP_REQUEST_new, OCSP_REQUEST_free, OCSP_SIGNATURE_new, OCSP_SIGNATURE_free, OCSP_REQINFO_new, OCSP_REQINFO_free, OCSP_ONEREQ_new, OCSP_ONEREQ_free, OCSP_request_add0_id, OCSP_request_sign, OCSP_request_add1_cert, OCSP_request_onereq_count, OCSP_request_onereq_get0 β literally all the OCSP request functions, together, iconic behavior π
β¨ SYNOPSIS πΈ
like, first you gotta pull in the library and the header:
library βlibcryptoβ #include <openssl/ocsp.h>
then the whole cast π«Ά
OCSP_REQUEST *
OCSP_REQUEST_new(void);
void
OCSP_REQUEST_free(OCSP_REQUEST *req);
OCSP_SIGNATURE *
OCSP_SIGNATURE_new(void);
void
OCSP_SIGNATURE_free(OCSP_SIGNATURE *signature);
OCSP_REQINFO *
OCSP_REQINFO_new(void);
void
OCSP_REQINFO_free(OCSP_REQINFO *reqinfo);
OCSP_ONEREQ *
OCSP_ONEREQ_new(void);
void
OCSP_ONEREQ_free(OCSP_ONEREQ *onereq);
OCSP_ONEREQ *
OCSP_request_add0_id(OCSP_REQUEST *req, OCSP_CERTID *cid);
int
OCSP_request_sign(OCSP_REQUEST *req, X509 *signer, EVP_PKEY *key,
const EVP_MD *dgst, STACK_OF(X509) *certs, unsigned long flags);
int
OCSP_request_add1_cert(OCSP_REQUEST *req, X509 *cert);
int
OCSP_request_onereq_count(OCSP_REQUEST *req);
OCSP_ONEREQ *
OCSP_request_onereq_get0(OCSP_REQUEST *req, int i);
π¦ DESCRIPTION π
OCSP_REQUEST_new() allocates and initializes an empty OCSP_REQUEST object β and what even is that? it's the ASN.1 OCSPRequest structure from RFC 6960, periodt. OCSP_REQUEST_free() frees req. bye bestie π
OCSP_SIGNATURE_new() allocates and initializes an empty OCSP_SIGNATURE object, which represents an ASN.1 Signature structure from RFC 6960. And like, this one is used inside OCSP_REQUEST, so it's giving inner-circle energy. OCSP_SIGNATURE_free() frees signature.
OCSP_REQINFO_new() allocates and initializes an empty OCSP_REQINFO object β that's the ASN.1 TBSRequest structure per RFC 6960, and it also lives inside OCSP_REQUEST. What does it do tho? it asks about the validity of one or more certificates. little overachiever π§ OCSP_REQINFO_free() frees reqinfo.
OCSP_ONEREQ_new() allocates and initializes an empty OCSP_ONEREQ object, representing an ASN.1 Request structure from RFC 6960. These cuties live inside OCSP_REQINFO, and each one asks about the validity of a single certificate β one job, one certificate, very focused π
OCSP_ONEREQ_free() frees onereq.
OCSP_request_add0_id() adds certificate ID cid to req. It returns the OCSP_ONEREQ object it just added, so your app can tack on extra extensions to the request. and like β major heads up β the cid parameter must not be freed up after the operation. don't do it. not me catching you doing it π
OCSP_request_sign() signs the OCSP request req using certificate signer, private key key, digest dgst, and additional certificates certs. And if the flags option OCSP_NOCERTS is set, then no certificates will be included in the request. so clean β¨
OCSP_request_add1_cert() adds certificate cert to request req. The application is responsible for freeing up cert after use β that's on you, bestie, own it π«Ά
OCSP_request_onereq_count() returns the total number of OCSP_ONEREQ objects in req. counting queen π
OCSP_request_onereq_get0() returns an internal pointer to the OCSP_ONEREQ contained in req at index i. The index i runs from 0 to OCSP_request_onereq_count(req) - 1 β so like, do the math correctly or it's not gonna slay π
fr fr:OCSP_request_onereq_count()andOCSP_request_onereq_get0()are mainly used by OCSP responders. that's their whole thing, iykyk.
π RETURN VALUES β
okay so what comes back:
OCSP_REQUEST_new(),OCSP_SIGNATURE_new(),OCSP_REQINFO_new(), andOCSP_ONEREQ_new()return an emptyOCSP_REQUEST,OCSP_SIGNATURE,OCSP_REQINFO, orOCSP_ONEREQobject, respectively β orNULLif an error occurred. sad girl hours πOCSP_request_add0_id()returns theOCSP_ONEREQobject containingcid, orNULLif an error occurred.OCSP_request_sign()andOCSP_request_add1_cert()return1for success or0for failure. simple as that πOCSP_request_onereq_count()returns the total number ofOCSP_ONEREQobjects inreq.OCSP_request_onereq_get0()returns a pointer to anOCSP_ONEREQobject, orNULLif the index value is out of range. (told you the index mattered π―)
π EXAMPLES πΈ
okay bestie, let's actually create an OCSP_REQUEST object for certificate cert with issuer issuer β watch and learn:
OCSP_REQUEST *req;
OCSP_ID *cid;
req = OCSP_REQUEST_new();
if (req == NULL)
/* error */
cid = OCSP_cert_to_id(EVP_sha1(), cert, issuer);
if (cid == NULL)
/* error */
if (OCSP_REQUEST_add0_id(req, cid) == NULL)
/* error */
/* Do something with req, e.g. query responder */
OCSP_REQUEST_free(req);
see how the error comments are just /* error */? that's your cue to handle it, not ignore it π
π₯ SEE ALSO π
the whole friend group, go say hi: ACCESS_DESCRIPTION_new(3), crypto(3), d2i_OCSP_REQUEST(3), d2i_OCSP_RESPONSE(3), EVP_DigestInit(3), OCSP_cert_to_id(3), OCSP_CRLID_new(3), OCSP_request_add1_nonce(3), OCSP_resp_find_status(3), OCSP_response_status(3), OCSP_sendreq_new(3), OCSP_SERVICELOC_new(3), X509_ocspid_print(3) β collect them all β¨
π STANDARDS π
RFC 6960: X.509 Internet Public Key Infrastructure Online Certificate Status Protocol, section 4.1: Request Syntax. cite your sources, always π
π HISTORY π¦
These functions first appeared in OpenSSL 0.9.7 and have been available since OpenBSD 3.2. veterans of the game, honestly π
and that's the page, bestie! π«Ά this Debian build of the manual is dated June 8, 2025 β so go forth, sign those requests, and don't free that cid π
π¦ 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 Ingo Schwarze <schwarze@openbsd.org>
- Copyright (c) 2014, 2016 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