OCSP_SENDREQ_NEW(3)
πΈ NAME πΈ
Hiii bestie, welcome to the OCSP_SENDREQ_NEW(3) page π β that's the one from the Library Functions Manual, and it's the whole squad of OCSP responder query functions, aka:
OCSP_sendreq_new, OCSP_sendreq_nbio, OCSP_REQ_CTX_free, OCSP_REQ_CTX_add1_header, OCSP_REQ_CTX_set1_req, OCSP_parse_url, and OCSP_sendreq_bio.
OCSP responder query functions. That's the vibe. No cap. β¨
π¦ SYNOPSIS π¦
So first things first, this is a library situation: library βlibcryptoβ, and you're gonna need #include <openssl/ocsp.h> before anything slays.
OCSP_REQ_CTX *
OCSP_sendreq_new(BIO *io, const char *path, OCSP_REQUEST *req,
int maxline);
int
OCSP_sendreq_nbio(OCSP_RESPONSE **presp, OCSP_REQ_CTX *rctx);
void
OCSP_REQ_CTX_free(OCSP_REQ_CTX *rctx);
int
OCSP_REQ_CTX_add1_header(OCSP_REQ_CTX *rctx, const char *name,
const char *value);
int
OCSP_REQ_CTX_set1_req(OCSP_REQ_CTX *rctx, OCSP_REQUEST *req);
int
OCSP_parse_url(const char *url, char **phost, char **pport,
char **ppath, int *pssl);
OCSP_RESPONSE *
OCSP_sendreq_bio(BIO *io, const char *path, OCSP_REQUEST *req);
π DESCRIPTION π
Okay so let's go function by function, because each one has main character energy and also a job to do.
OCSP_sendreq_new()β hands you back anOCSP_REQ_CTXstructure, built from the responderio, the URI pathpath, the OCSP requestreq, and a response-header maximum line length ofmaxline. Ifmaxlineis zero, a default value of 4k is used (so like, it's not gonna be weirdly small, don't stress π«Ά). And plot twist: the OCSP requestreqmay be set toNULLand provided later if required.- The arguments to
OCSP_sendreq_new()correspond to the components of the URI. For example, if the responder URI ishttp://ocsp.com/ocspreq, theBIOioshould be connected to hostocsp.comon port 80 andpathshould be set to"/ocspreq". It's giving "everything in its right place" π« OCSP_sendreq_nbio()β does non-blocking I/O on the OCSP request contextrctx. When the operation is complete, it returns the response in*presp. Now, ifOCSP_sendreq_nbio()indicates an operation should be retried, the correspondingBIOcan be examined to determine which operation (read or write) should be retried, and appropriate action can be taken β for example aselect(2)call on the underlying socket. Iconic retry behaviour, honestly.OCSP_REQ_CTX_free()β frees up the OCSP contextrctx. Cleanup queen π§Ήβ¨OCSP_REQ_CTX_add1_header()β adds headernamewith valuevalueto the contextrctx. The added headers are of the form"name: value"or just"name"ifvalueisNULL. You can callOCSP_REQ_CTX_add1_header()more than once to add multiple headers β stack 'em, bestie π
β οΈ But listen: it must be called before any calls toOCSP_sendreq_nbio(). And thereqparameter in the initial toOCSP_sendreq_new()call must be set toNULLif additional headers are set. Like, that's the rule, fr fr.
OCSP_REQ_CTX_set1_req()β sets the OCSP request inrctxtoreq. This function should be called after any calls toOCSP_REQ_CTX_add1_header(). Order matters, always has πOCSP_parse_url()β a utility function to parse a url of the formhttp[s]://host[:port][/path]and store pointers to newly allocated copies of the stringshost,port, andpathin*phost,*pport, and*ppath, respectively. By default,*ppathis set to"/"and*pportto"443"for https or"80"for http. For https,*psslis set to 1; otherwise, to 0. Newly allocated copies, okay? Somebody's gotta free those later πOCSP_sendreq_bio()β performs an OCSP request using the responderio, the URI pathpath, and the OCSP requestreq. It does not support retries and so cannot handle non-blocking I/O efficiently. It is retained for compatibility and its use in new applications is not recommended. So likeβ¦ it's a legacy icon, we respect it, we just don't build new stuff on it π
β RETURN VALUES β
Vibe check on what you actually get back:
OCSP_sendreq_new()returns a validOCSP_REQ_CTXstructure orNULLif an error occurred.OCSP_sendreq_nbio()returns1if the operation was completed successfully,-1if the operation should be retried, or0if an error occurred. Three whole moods πOCSP_REQ_CTX_add1_header(),OCSP_REQ_CTX_set1_req(), andOCSP_parse_url()return1for success or0for failure.OCSP_sendreq_bio()returns theOCSP_RESPONSEstructure sent by the responder orNULLif an error occurred.
π EXAMPLES π
Add a Host header for ocsp.com:
OCSP_REQ_CTX_add1_header(ctx, Host, ocsp.com );
Look at that. So simple. So elegant. We love a one-liner π
π SEE ALSO π
Go read these next, bestie, they're all connected:
OCSP_cert_to_id(3), OCSP_request_add1_nonce(3), OCSP_REQUEST_new(3), OCSP_resp_find_status(3), OCSP_response_status(3), X509_get1_ocsp(3)
iykyk π
π HISTORY π
Storytime, because these functions have lore:
OCSP_parse_url()andOCSP_sendreq_bio()first appeared in OpenSSL 0.9.7 and have been available since OpenBSD 3.2.OCSP_sendreq_new(),OCSP_sendreq_nbio(), andOCSP_REQ_CTX_free()first appeared in OpenSSL 0.9.8h and have been available since OpenBSD 4.5.OCSP_REQ_CTX_add1_header()andOCSP_REQ_CTX_set1_req()first appeared in OpenSSL 1.0.0 and have been available since OpenBSD 4.9.
Glow-up after glow-up, honestly π₯
π CAVEATS π
Read this part, it's important, don't skip it π
- These functions only perform a minimal HTTP query to a responder. If an application wishes to support more advanced features, it should use an alternative, more complete, HTTP library.
- Currently only HTTP POST queries to responders are supported. That's it. That's the whole menu.
So like, if you need more than the basics, go get a real HTTP library. This one's doing its little best and that's valid π«Ά
<div align="center">π</div>
Okay that's the whole page, bestie β you're officially an OCSP responder query expert π This gem came from Debian, dated June 8, 2025, and that's the OCSP_SENDREQ_NEW(3) tea. Slay, stay safe, and always set req to NULL before adding headers β¨π¦π
π¦ where this page comes from
- alpine 3.24: libressl-doc 4.3.1-r0 Β· custom
- arch rolling: libressl 4.4.0-1 Β· ISC AND custom:OpenSSL
- Copyright (c) 2018, 2019 Ingo Schwarze <schwarze@openbsd.org>
- Copyright (c) 2014, 2016 The OpenSSL Project. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms