OCSP_REQUEST_ADD1_NONCE(3SSL)
π OCSP_REQUEST_ADD1_NONCE π
okay bestie so this is the OCSP_request_add1_nonce(3SSL) page β yes it's a whole mouthful, we're calling it "the nonce squad" from here on out. It's OpenSSL, it's the OCSP nonce functions, and honestly? iconic behavior. Let's get into it π
β¨ NAME β¨
OCSP_request_add1_nonce, OCSP_basic_add1_nonce, OCSP_check_nonce, OCSP_copy_nonce β the OCSP nonce functions, aka the four besties who handle your nonce situation π
πΈ SYNOPSIS πΈ
#include <openssl/ocsp.h>
int OCSP_request_add1_nonce(OCSP_REQUEST *req, unsigned char *val, int len);
int OCSP_basic_add1_nonce(OCSP_BASICRESP *resp, unsigned char *val, int len);
int OCSP_copy_nonce(OCSP_BASICRESP *resp, OCSP_REQUEST *req);
int OCSP_check_nonce(OCSP_REQUEST *req, OCSP_BASICRESP *resp);
periodt. four functions, zero chill. copy-paste them exactly, do not freestyle the prototypes, i am begging π«Ά
π¦ DESCRIPTION π¦
so like. a nonce is a one-time random lil value and these functions are the way you handle it in OCSP world.
OCSP_request_add1_nonce()β adds a nonce of valuevaland lengthlento the OCSP requestreq. IfvalisNULL, a random nonce gets used instead (very slay of it). And iflenis zero or negative, a default length kicks in β currently16bytes. yes, sixteen. locked in πOCSP_basic_add1_nonce()β literally the same asOCSP_request_add1_nonce()except the vibe is different: it adds the nonce to an OCSP basic responserespinstead of a request.OCSP_check_nonce()β compares the nonce value inreqandresp. the moment of truth, the vibe check, if you will βOCSP_copy_nonce()β copies any nonce value present inreqover toresp. stealing from one and giving to the other, but make it cryptography.
π₯ RETURN VALUES π₯
OCSP_request_add1_nonce()andOCSP_basic_add1_nonce()β return1for success and0for failure. simple. binary. iconic.OCSP_copy_nonce()β returns1if a nonce was successfully copied,2if no nonce was present inreq, and0if an error occurred.OCSP_check_nonce()β returns the result of the nonce comparison betweenreqandresp. the return value is the result of the comparison, so read it carefully bestie, it's giving love-letter-decoding energy:- nonces are present and equal β
1 - nonces are absent β
2 - a nonce is present in the response only β
3 - nonces are present and unequal β
0 - the nonce is present in the request only β
-1
- nonces are present and equal β
π NOTES π
okay this is the part where i need you to actually pay attention, bestie. no scrolling.
- For most purposes the nonce value in a request is set to a random value, so the
valparameter inOCSP_request_add1_nonce()is usuallyNULL. let it cook, it knows what it's doing. - An OCSP nonce is typically added to an OCSP request to thwart replay attacks β you do this by checking the same nonce value appears in the response. security girlie behavior π
- Some responders may include a nonce in all responses even if one is not supplied. fine. quirky. we respect it.
- Some responders cache OCSP responses and do not sign each response, for performance reasons. as a result they do not support nonces. no nonce for you, sorry π₯²
- The return values of
OCSP_check_nonce()can be checked to cover each case:- A positive return value effectively indicates success: nonces are both present and match, both absent, or present in the response only. β
- A nonzero return additionally covers the case where the nonce is present in the request only β this will happen if the responder doesn't support nonces.
- A zero return value indicates present and mismatched nonces.
β οΈ a 0 return means present-and-mismatched nonces, and this should be treated as an error condition. not a vibe. not a false alarm. an actual error. do not ignore it, i will know π
π SEE ALSO π
crypto(7), OCSP_cert_to_id(3), OCSP_REQUEST_new(3), OCSP_resp_find_status(3), OCSP_response_status(3), OCSP_sendreq_new(3)
the whole friend group, go read them too π«Ά
π COPYRIGHT π
Copyright 2015-2020 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, no notes π written for 4.0.3, dated 2026-09-29 β go forth and nonce responsibly, mwah π
β¨
π¦ where this page comes from
- ubuntu stonking: libssl-doc 4.0.3-1ubuntu1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms