ERR_ERROR_STRING(3)

πŸ“¦ version 4.4.0, in alpine 3.24, arch rolling

πŸ’– ERR_ERROR_STRING(3) πŸ’–

okay bestie, so this is from the Library Functions Manual β€” it's all about grabbing human-readable OpenSSL error messages and making sense of those cursed error codes πŸ’…


✨ NAME ✨

So like, the whole squad is here: ERR_error_string, ERR_error_string_n, ERR_lib_error_string, ERR_func_error_string, and ERR_reason_error_string β€” they all exist to obtain human-readable OpenSSL error messages 🫢


🌸 SYNOPSIS 🌸

library β€œlibcrypto” #include <openssl/err.h>

char *
ERR_error_string(unsigned long e, char *buf);

void
ERR_error_string_n(unsigned long e, char *buf, size_t len);

const char *
ERR_lib_error_string(unsigned long e);

const char *
ERR_func_error_string(unsigned long e);

const char *
ERR_reason_error_string(unsigned long e);

πŸŽ€ DESCRIPTION πŸŽ€

okay so ERR_error_string() generates a human-readable string representing the error code e and places it in buf. and like, buf must be at least 256 bytes long, no cap. if buf is NULL, the error string gets placed in a static buffer instead. but bestie… ⚠️ this function is not thread-safe and does no checks on the size of the buffer. so literally use ERR_error_string_n() instead, i'm begging πŸ₯Ί

ERR_error_string_n() is the glow-up variant of ERR_error_string() that writes at most len characters (including the terminating NUL) and truncates the string if necessary. for ERR_error_string_n(), buf may not be NULL, periodt.

the string will have this format, iconic:

error:[error code]:[library name]:[function name]:[reason string]

the error code is an 8-digit hexadecimal number ✨ the library name, the function name, and the reason string are ASCII text.

ERR_lib_error_string(), ERR_func_error_string(), and ERR_reason_error_string() return the library name, the function name, and the reason string, respectively πŸ’–

the OpenSSL error strings should be loaded by calling ERR_load_crypto_strings(3) or, for SSL applications, SSL_load_error_strings(3) first. if there is no text string registered for the given error code, the error string will contain the numeric code. lowkey tragic but that's the vibe check 🌈

ERR_print_errors(3) can be used to print all error codes currently in the queue β€” super handy, iykyk πŸ¦‹


πŸ‘‘ RETURN VALUES πŸ‘‘

ERR_error_string() returns a pointer to a static buffer containing the string if buf is NULL, or buf otherwise. slay.

ERR_lib_error_string(), ERR_func_error_string(), and ERR_reason_error_string() return the strings, or NULL if none is registered for the error code ✨


πŸ’… SEE ALSO πŸ’…

ERR(3), ERR_get_error(3), ERR_load_crypto_strings(3), ERR_print_errors(3), SSL_load_error_strings(3)


πŸ¦‹ HISTORY πŸ¦‹

ERR_error_string(), ERR_lib_error_string(), ERR_func_error_string(), and ERR_reason_error_string() first appeared in SSLeay 0.4.4 and have been available since OpenBSD 2.4 β€” literal icons of longevity πŸ’–

ERR_error_string_n() first appeared in OpenSSL 0.9.6 and has been available since OpenBSD 2.9 🌸


okay that's the whole page bestie, you're gonna do amazing with these error strings, fr fr 🫢

Debian 🌈 June 8, 2025 🌈 ERR_ERROR_STRING(3) β€” mwah, go slay those error codes πŸ’…βœ¨

πŸ“¦ where this page comes from