OCSP_REQUEST_NEW(3ossl)

✨ NAME ✨

okay so this is the OCSP_REQUEST_NEW(3ossl) page from the OpenSSL manual (section 3ossl, bestie, we love a section 3) and it's all about the OCSP request functions, which are:

OCSP_REQUEST_new, OCSP_REQUEST_free, OCSP_request_add0_id, OCSP_request_sign, OCSP_request_add1_cert, OCSP_request_onereq_count, OCSP_request_onereq_get0 β€” OCSP request functions πŸ’…


🌸 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 picture this: you're building an OCSP request, right? these are the little functions that make it happen. let's go one by one, no skipping, periodt. ✨

  • OCSP_REQUEST_new() β€” allocates and hands you back a brand new, totally empty OCSP_REQUEST structure. a blank canvas, main character energy. πŸŽ€
  • OCSP_REQUEST_free() β€” frees up the request structure req. and if the argument is NULL? nothing happens. she just shrugs and moves on. πŸ’…
  • OCSP_request_add0_id() β€” adds the certificate ID cid to req. it returns the OCSP_ONEREQ structure that got added, so your application can tack on extra extensions to the request if it wants to. > ⚠️ BIG ONE: the id parameter MUST NOT be freed up after the operation. like, do not. the structure owns it now, okay? 🫢
  • 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 will be included in the request. simple as that. πŸ”₯
  • OCSP_request_add1_cert() β€” adds certificate cert to request req. and heads up, bestie: the application is responsible for freeing up cert after use. that's on you, not on her. πŸ’€
  • OCSP_request_onereq_count() β€” returns the total number of OCSP_ONEREQ structures in req. it's giving census. 🌈
  • OCSP_request_onereq_get0() β€” returns an internal pointer to the OCSP_ONEREQ contained in req at index i. and the index value i runs from 0 to OCSP_request_onereq_count(req) - 1. zero-indexed, as all good things are. ⭐

πŸ’– RETURN VALUES πŸ’–

okay so here's what you get back from each one:

  • 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. classic. πŸŽ€
  • 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.

🌟 NOTES 🌟

an OCSP request structure contains one or more OCSP_ONEREQ structures, corresponding to each certificate. so like, one per cert. cute. 🧚

and OCSP_request_onereq_count() plus OCSP_request_onereq_get0() are mainly used by OCSP responders. iykyk. πŸ‘‘


πŸ“ EXAMPLES πŸ“

okay so here's how you create an OCSP_REQUEST structure 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);

ate that, honestly. πŸ’…


πŸ‘€ 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)


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 OpenSSL 3.5.9, dated 2026-09-29, and it's OCSP_REQUEST_NEW(3ossl) β€” go forth and build your requests, you absolute icon. πŸ‘‘βœ¨πŸ’–

πŸ“¦ where this page comes from