ERR_ERROR_STRING(3ossl)
β¨ NAME β¨
ERR_error_string, ERR_error_string_n, ERR_lib_error_string, ERR_func_error_string, ERR_reason_error_string β bestie, these give you a human-readable error message π (this is from the OpenSSL manual, 3ossl, and it's the whole glow-up guide to turning ugly error codes into stuff you can actually read).
πΈ SYNOPSIS πΈ
#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_reason_error_string(unsigned long e);
Deprecated in OpenSSL 3.0 (yes, it's giving "retired icon" π):
const char *ERR_func_error_string(unsigned long e);
π¦ DESCRIPTION π¦
So ERR_error_string() takes your error code e, makes a human-readable string out of it, and drops it right into buf. And like⦠buf must be at least 256 bytes long, no negotiation. If buf is NULL, the error string gets parked in a static buffer instead.
Not me having to say this: this function is not thread-safe and it does zero checks on the size of your buffer. Literally none. Use ERR_error_string_n() instead, bestie, please π
ERR_error_string_n() is the upgraded, more considerate version of ERR_error_string(). It writes at most len characters (and yes, the terminating 0 counts, she's included in the budget) and just truncates the string if it doesn't fit. But heads up: for ERR_error_string_n(), buf MUST NOT be NULL. Like, NULL is not the vibe here π«
The string comes out in this exact format:
error:[error code]:[library name]::[reason string]
Where error code is an 8 digit hexadecimal number, and library name and reason string are ASCII text. Periodt β¨
ERR_lib_error_string() and ERR_reason_error_string() hand you the library name and the reason string respectively. Simple, clean, iconic.
And if there's no text string registered for a given error code? The error string just contains the numeric code. She still shows up, just raw π
Oh also β ERR_print_errors(3) is the one you want if you need to print all the error codes currently chillin' in the queue π
π RETURN VALUES π
ERR_error_string()β returns a pointer to a static buffer containing the string ifbuf == NULL; otherwise it returnsbuf. Easy.ERR_lib_error_string()andERR_reason_error_string()β return the strings, andNULLif none is registered for the error code πERR_func_error_string()β returnsNULL. That's it. That's the whole answer π
π SEE ALSO π
(slay, go read those next π«Ά)
β HISTORY β
ERR_func_error_string() became deprecated in OpenSSL 3.0. She had her era, we respect it π
π COPYRIGHT π
Copyright 2000-2017 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>.
okay that's the whole thing, ily, go forth and read your error strings π§ββοΈπ
3.5.0 Β· 2026-09-25 Β· ERR_ERROR_STRING(3ossl) β mwah, signing off π
π¦ where this page comes from
- opensuse-leap 16.0: openssl-3-doc 3.5.0-160000.11.1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms