OCSP_REQUEST_NEW(3ossl)
π OCSP_REQUEST_NEW π
okay so bestie, this is the OpenSSL manual page for OCSP_REQUEST_NEW(3ossl) β yes the manual name goes right there, we're not copying the header line, we're folding it in like a cute lil' sticker. It's all the OCSP request functions, together, in one place. Grab a snack, we're going in π
πΈ 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,
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 β¨
So here's the whole vibe check on each one, bestie π
OCSP_REQUEST_new()β literally just allocates and hands you back a fresh, emptyOCSP_REQUESTstructure. Nothing in it yet, it's giving blank canvas energy π¨OCSP_REQUEST_free()β frees up the request structurereq. And if the argument isNULL? Nothing happens. No drama, no nothing. It just lets it go πOCSP_request_add0_id()β adds the certificate IDcidtoreq. It gives you back theOCSP_ONEREQstructure that got added, so your application can go ahead and tack on extra extensions to the request. β οΈ IMPORTANT: theidparameter MUST NOT be freed up after the operation. Like, do not touch it. That's the rule. No cap.OCSP_request_sign()β signs the OCSP requestrequsing the certificatesigner, the private keykey, the digestdgst, and additional certificatescerts. And if theflagsoptionOCSP_NOCERTSis set? Then no certificates get included in the request at all. Zero. None. π«OCSP_request_add1_cert()β adds certificatecertto the requestreq. Heads up though: the application is responsible for freeing upcertafter use. That's on you, bestie π«ΆOCSP_request_onereq_count()β returns the total number ofOCSP_ONEREQstructures inreq. Simple. Iconic.OCSP_request_onereq_get0()β returns an internal pointer to theOCSP_ONEREQinsidereqat indexi. And the index valueiruns from0toOCSP_request_onereq_count(req) - 1. Classic zero-indexing, we love to see it β¨
π RETURN VALUES π
Okay this part matters, don't skip it π
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. That's the classic yes/no binary, slay.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 or range. (yeah, "out or range" β that's literally what the page says, I'm not fixing it, I don't make the rules π)
π¦ NOTES π¦
An OCSP request structure contains one or more OCSP_ONEREQ structures, and there's one corresponding to each certificate. One per cert. That's the whole system π§
Also β OCSP_request_onereq_count() and OCSP_request_onereq_get0() are mainly used by OCSP responders. So if you're not building a responder, these two are lowkey just vibing in the background for you.
π EXAMPLES π
Okay so here's how you create an OCSP_REQUEST structure for certificate cert with issuer issuer. Copy it exactly, no edits, I beg of you π
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 that last line? Clean up after yourself. Free the request. Be a responsible main character π
β SEE ALSO β
Go read these next, bestie, they're all part of the same friend group:
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-2024 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 version 3.5.6, dated 2026-04-07 β go forth and OCSP responsibly π β¨
π¦ 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