ERR_ERROR_STRING(3SSL)

πŸ’– ERR_ERROR_STRING(3SSL) β€” bestie edition πŸ’–

okay so you're reading the OpenSSL manual page for turning those ugly error codes into something a human can actually read. this is the one. the glow-up page. the "wait what does that hex number MEAN" fixer. let's go πŸ¦‹


✨ NAME ✨

ERR_error_string, ERR_error_string_n, ERR_lib_error_string, ERR_func_error_string, ERR_reason_error_string β€” get yourself an actually-human-readable error message πŸ’…


✨ 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);

and now the sad one β€” deprecated in OpenSSL 3.0:

const char *ERR_func_error_string(unsigned long e);

✨ DESCRIPTION ✨

so ERR_error_string() takes that error code e and generates a human-readable string for it, and drops it right into buf. and bestie, listen β€” buf must be at least 256 bytes long. that's not a vibe suggestion, that's a rule. 😭

if buf is NULL, the error string goes into a static buffer instead. but here's the tea: this function is not thread-safe and it does no checks at all on the size of your buffer. none. zero. it's giving reckless. so please, for the love of everything, use ERR_error_string_n() instead πŸ™ˆ

ERR_error_string_n() is the safer variant of ERR_error_string() β€” it writes at most len characters (and yes, that count includes the terminating 0) and just truncates the string if it's too long. no drama. for ERR_error_string_n(), buf MUST NOT be NULL. like, actually must not. πŸ’€

the string comes out looking like this:

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 back the library name and the reason string respectively. cute, right? 🌸

and if there's no text string registered for the error code you threw at it? then the error string just contains the numeric code. no name, no reason, just numbers. it's giving mystery ✨

oh and also β€” ERR_print_errors(3) is the one you want if you wanna 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 if buf == NULL, and buf otherwise. yeah. that's the deal.

ERR_lib_error_string() and ERR_reason_error_string() return the strings β€” and NULL if nothing is registered for that error code.

ERR_func_error_string() returns NULL. that's it. that's the whole function. iconically useless now πŸ’€


✨ SEE ALSO ✨


✨ HISTORY ✨

ERR_func_error_string() became deprecated in OpenSSL 3.0. rip πŸͺ¦


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>.


and that's the whole page bestie, you ate it up 🫢 this was version 4.0.3, dated 2026-09-29, from the ERR_ERROR_STRING(3SSL) manual β€” go forth and read your error strings like a main character πŸ’–βœ¨πŸŒˆ

πŸ“¦ where this page comes from