OCSP_REQUEST_NEW(3ossl)

πŸ“¦
version 15.1 Β· 2 versions
, in freebsd 15.1

πŸ’… 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, empty OCSP_REQUEST structure. Nothing in it yet, it's giving blank canvas energy 🎨
  • OCSP_REQUEST_free() β€” frees up the request structure req. And if the argument is NULL? Nothing happens. No drama, no nothing. It just lets it go πŸ’€
  • OCSP_request_add0_id() β€” adds the certificate ID cid to req. It gives you back the OCSP_ONEREQ structure that got added, so your application can go ahead and tack on extra extensions to the request. ⚠️ IMPORTANT: the id parameter 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 request req using the certificate signer, the private key key, the digest dgst, and additional certificates certs. And if the flags option OCSP_NOCERTS is set? Then no certificates get included in the request at all. Zero. None. 🚫
  • OCSP_request_add1_cert() β€” adds certificate cert to the request req. Heads up though: the application is responsible for freeing up cert after use. That's on you, bestie 🫢
  • OCSP_request_onereq_count() β€” returns the total number of OCSP_ONEREQ structures in req. Simple. Iconic.
  • OCSP_request_onereq_get0() β€” returns an internal pointer to the OCSP_ONEREQ inside req at index i. And the index value i runs from 0 to OCSP_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 empty OCSP_REQUEST structure, or NULL if an error occurred.
  • OCSP_request_add0_id() β†’ returns the OCSP_ONEREQ structure containing cid, or NULL if an error occurred.
  • OCSP_request_sign() and OCSP_request_add1_cert() β†’ return 1 for success and 0 for failure. That's the classic yes/no binary, slay.
  • OCSP_request_onereq_count() β†’ returns the total number of OCSP_ONEREQ structures in req, and -1 on error.
  • OCSP_request_onereq_get0() β†’ returns a pointer to an OCSP_ONEREQ structure, or NULL if 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:


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