ERR_PUT_ERROR(3)
π ERR_PUT_ERROR(3) β like, the OpenSSL error-recording girlie
okay so bestie, gather round, because this one's from the Library Functions Manual and it's all about how OpenSSL writes down its little oopsies β¨
β¨ NAME β¨
ERR_put_error β record an OpenSSL error π (yes that's literally it, that's the whole job)
πΈ SYNOPSIS πΈ
first up, you gotta be linked against the library βlibcryptoβ and pull in the header like so:
#include <openssl/err.h>
and then the function herself, in all her glory:
void
ERR_put_error(int lib, int func, int reason, const char *file,
int line);
π¦ DESCRIPTION π¦
so ERR_put_error() adds an error code to the thread's error queue β like dropping a little note in the group chat that says "hey, something went sideways" π
what it's signaling is: the error with reason code reason happened in function func, of library lib, on line number line of file. that's the whole vibe check β lib, func, reason, file, line, boom, recorded π
ngl, this function is usually called by a macro, not by you directly. you're not really supposed to be hand-writing these calls, bestie.
ERR_load_strings(3) is your girl for registering error strings, so your application can actually generate human-readable error messages for the error code. because raw codes are giving cryptic, and readable strings are giving iconic π«Ά
π the XXXerr(f, r) macro situation
okay so every sub-library has its own specific macro, XXXerr(f, r), and it's the one used to report errors. here's the breakdown:
- first argument β a function code,
XXX_F_* - second argument β a reason code,
XXX_R_*
function codes are derived from the function names, whereas reason codes consist of textual error descriptions. cute, right? π
for example, the function ssl23_read() reports a "handshake failure" like this:
SSLerr(SSL_F_SSL23_READ, SSL_R_SSL_HANDSHAKE_FAILURE);
slay. that's it. that's the whole report π₯
π§ the naming rules (yes there are rules)
function and reason codes should consist of upper case characters, numbers and underscores only. no cap, that's the format, don't fight it π
the error file generation script translates function codes into function names by looking in the header files for an appropriate function name. and if none is found? it just uses the capitalized form β like "SSL23_READ" in the example above. lowkey clever π
also! the trailing section of a reason code (the part after the "_R_") gets translated into lower case, and the underscores get changed to spaces. so it actually reads like english at the end. obsessed π
π the cross-library cameo
although a library will normally report errors using its own specific XXXerr() macro, another library's macro can be used. plot twist!
this is normally only done when a library wants to include ASN.1 code, which must use the ASN1err() macro. that's the one exception, iykyk π
π SEE ALSO π
go read those next, bestie, they're the supporting cast π
β HISTORY β
ERR_put_error() first appeared in SSLeay 0.4.4 and has been available since OpenBSD 2.4. she's been booked and busy for literal decades, main character energy fr fr π
and that's the page!! this cutie came to you from Debian, dated June 8, 2025 β mwah, go forth and record your errors responsibly π β¨π
π¦ 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) 2000, 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