OCSP_REQUEST_NEW(3ossl)
okay so bestie, gather round β this is OCSP_REQUEST_NEW(3ossl), straight out of the OpenSSL manual, section 3, and we are about to make OCSP requests feel less like a vibe check from a cryptographer and more like a group chat you actually understand π
β¨
π NAME π
All the OCSP request functions, together, in one place β 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. That's the whole squad π«Ά
πΈ 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 π¦
Okay so here's what each little icon does π
OCSP_REQUEST_new()β allocates and hands you back a fresh, emptyOCSP_REQUESTstructure. Brand new, zero thoughts, head empty β¨OCSP_REQUEST_free()β frees up the request structurereq. And listen: if the argument isNULL, literally nothing happens. Nothing. It's a no-op. Very chill of it, honestly πOCSP_request_add0_id()β adds the certificate IDcidtoreq, and returns theOCSP_ONEREQstructure it just added, so your application can pile on additional extensions to the request. BUT β and this is the important part, bestie, do not skip it β theidparameter MUST NOT be freed up after the operation. It lives there now. You do not get to free it. πOCSP_request_sign()β signs the OCSP requestrequsing the certificatesigner, the private keykey, the digestdgst, and additional certificatescerts. And if the flags optionOCSP_NOCERTSis set, then no certificates will be included in the request. Periodt πOCSP_request_add1_cert()β adds the certificatecertto the requestreq. Heads up though: the application is responsible for freeing upcertafter use. That's on you, not on it π«‘OCSP_request_onereq_count()β returns the total number ofOCSP_ONEREQstructures inreq. Counting era π’OCSP_request_onereq_get0()β returns an internal pointer to theOCSP_ONEREQcontained inreqat indexi. And the index valueiruns from0toOCSP_request_onereq_count(req) - 1. Respect the range, or else π
π RETURN VALUES π
OCSP_REQUEST_new()β returns an emptyOCSP_REQUESTstructure, orNULLif an error occurred πOCSP_request_add0_id()β returns theOCSP_ONEREQstructure containingcid, orNULLif an error occurred. Slay when it works, sad when it doesn't πOCSP_request_sign()andOCSP_request_add1_cert()β return1for success and0for failure. Simple. Binary. Iconic π₯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 π«
π§ NOTES π§
An OCSP request structure contains one or more OCSP_ONEREQ structures, corresponding to each certificate. It's giving "one entry per bestie" energy, and honestly? We love that for it π
Also, OCSP_request_onereq_count() and OCSP_request_onereq_get0() are mainly used by OCSP responders. So if you're the responder in this situation, these two are your main characters π
π EXAMPLES π
So say you wanna create an OCSP_REQUEST structure for the certificate cert with issuer issuer β here's the whole glow-up, step by step:
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);
Look at that. Beautiful. Chef's kiss π€ β and don't forget the OCSP_REQUEST_free(req) at the end, bestie, we do NOT leak in this house π
π SEE ALSO π
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)
(Read them, iykyk π)
π 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.0, dated 2026-09-25, and yes the manual name is OCSP_REQUEST_NEW(3ossl) in case you forgot already ππ go forth and make those OCSP requests, you've got this β¨
π¦ where this page comes from
- opensuse-leap 16.0: openssl-3-doc 3.5.0-160000.11.1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms