OCSP_REQUEST_NEW(3SSL)
π OCSP_REQUEST_NEW π β it's giving OpenSSL manual energy β¨
okay bestie, sit down, hydrate, because today we're learning about OCSP request functions from <openssl/ocsp.h> β yes, the whole little family: OCSP_REQUEST_new, OCSP_REQUEST_free, OCSP_request_add0_id, OCSP_request_sign, OCSP_request_add1_cert, OCSP_request_onereq_count and OCSP_request_onereq_get0. this is the 3SSL manual page, so bring your β¨certificate-validatingβ¨ self. π
πΈ SYNOPSIS πΈ
#include <openssl/ocsp.h>
OCSP_REQUEST *OCSP_REQUEST_new(void);
void OCSP_REQUEST_free(OCSP_REQUEST *req);
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,
const 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);
like, look at those signatures. iconic. no notes. π«Ά
β¨ DESCRIPTION β¨
okay so here's the tea on every single one of these functions, no skips, we are not leaving anyone out:
OCSP_REQUEST_new()β allocates and hands you back a shiny emptyOCSP_REQUESTstructure. blank slate, main character debut. π¦OCSP_REQUEST_free()β frees up the request structurereq. and if the argument isNULL? literally nothing happens, it just vibes. no crash, no drama. πOCSP_request_add0_id()β adds the certificate IDcidtoreq. it returns theOCSP_ONEREQstructure that got added, so your application can go ahead and slap additional extensions onto the request. BUT β and this is the important part bestie β the id parameter MUST NOT be freed up after the operation. do not touch it. it's not yours anymore. π«OCSP_request_sign()β signs the OCSP requestrequsing the certificate signer, the private key key, the digest dgst, and additional certificates certs. and if the flags optionOCSP_NOCERTSis set, then no certificates will be included in the request. zero. zilch. not a one. πOCSP_request_add1_cert()β adds the certificate cert to the requestreq. note: the application is responsible for freeing up cert after use. that's on you, girl. you brought it, you clean it up. π§ΉOCSP_request_onereq_count()β returns the total number ofOCSP_ONEREQstructures inreq. it's literally just counting. slay. π’OCSP_request_onereq_get0()β returns an internal pointer to theOCSP_ONEREQcontained inreqat indexi. and the index valueiruns from0toOCSP_request_onereq_count(req) - 1. off-by-one girls, this one's for you. β οΈ
π₯ RETURN VALUES π₯
here's what you get back, per function, no surprises:
OCSP_REQUEST_new()returns an emptyOCSP_REQUESTstructure β orNULLif an error occurred. πOCSP_request_add0_id()returns theOCSP_ONEREQstructure containingcidβ orNULLif an error occurred.OCSP_request_sign()andOCSP_request_add1_cert()return1for success and0for failure. yes bestie,1is good here, we know, C is like that. πOCSP_request_onereq_count()returns the total number ofOCSP_ONEREQstructures inreqβ and-1on error.OCSP_request_onereq_get0()returns a pointer to anOCSP_ONEREQstructure β orNULLif the index value is out of range. (the manpage says "out or range", we're gonna assume it means out of range, love that for us π)
π NOTES π
- an OCSP request structure contains one or more
OCSP_ONEREQstructures, corresponding to each certificate. one req per cert, cute little squad. π OCSP_request_onereq_count()andOCSP_request_onereq_get0()are mainly used by OCSP responders. so if you're not building a responder, these are lowkey background characters for you. iykyk. β¨
π EXAMPLES π
say you wanna create an OCSP_REQUEST structure for certificate cert with issuer issuer. here's the whole glow-up, verbatim:
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 cid is never freed separately? that's that add0 contract we talked about. obsessed with consistency. π«Ά
π¦ SEE ALSO π¦
go read these next, bestie, they're all in the group chat:
crypto(7)OCSP_cert_to_id(3)OCSP_request_add1_nonce(3)OCSP_resp_find_status(3)OCSP_response_status(3)OCSP_sendreq_new(3)
π COPYRIGHT π
Copyright 2015-2026 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 whole page, bestie!! this was OCSP_REQUEST_NEW(3SSL) from OpenSSL 4.0.3, dated 2026-09-29 β go forth and request your OCSP statuses responsibly πβ¨π no cap, you ate this one. bye!! π πΈ
π¦ where this page comes from
- ubuntu stonking: libssl-doc 4.0.3-1ubuntu1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms