ERR_GET_LIB(3ossl)
β¨ ERR_GET_LIB(3ossl) β the OpenSSL page where we decode error codes π
okay bestie, so this is ERR_GET_LIB(3ossl) from the OpenSSL manual, and it's genuinely so useful, no cap.
π NAME π
ERR_GET_LIB, ERR_GET_REASON, ERR_FATAL_ERROR β get information from error codes
πΈ SYNOPSIS πΈ
#include <openssl/err.h>
int ERR_GET_LIB(unsigned long e);
int ERR_GET_REASON(unsigned long e);
int ERR_FATAL_ERROR(unsigned long e);
π DESCRIPTION π
so like, the error code that comes back from ERR_get_error()? it's literally two things smooshed together: a library number and a reason code. that's it, that's the whole vibe. ERR_GET_LIB() and ERR_GET_REASON() are the little tools that pull those two pieces back out. π«Ά
and ERR_FATAL_ERROR()? it tells you whether a given error code is a fatal error. main character energy for real.
the library number is the where β where did this go wrong. the reason code is the what β the info about what actually went sideways. π₯
every sub-library inside OpenSSL has its own unique library number, and the reason code is unique within each sub-library. so basically: different libraries may use the exact same value to signal totally different reasons. do not get it twisted. π
now, the ERR_R_... reason codes β stuff like ERR_R_MALLOC_FAILURE β those ones are globally unique. but when you're checking for sub-library-specific reason codes, you gotta also compare the library number. both, bestie. both.
oh and important: ERR_GET_LIB(), ERR_GET_REASON(), and ERR_FATAL_ERROR() are macros. not functions. macros. okay love u bye.
β RETURN VALUES β
it returns the library number, the reason code, and whether the error is fatal β respectively, in that order, matching the three macros above. π«
and starting with OpenSSL 3.0.0, the function code is always set to zero. always. zero. iconic behaviour honestly.
π NOTES π
listen. applications should not make control flow decisions based on specific error codes. i'm so serious.
error codes are subject to change at any time β and yes, that includes patch releases of OpenSSL. like, even the "small" ones. π
a particular error code can only be considered meaningful for control flow decisions if it is explicitly documented as such. that's the bar. that's the whole bar. new failure codes may still appear at any time, so likeβ¦ be chill about it. π
π¦ SEE ALSO π¦
π HISTORY π
ERR_GET_LIB()andERR_GET_REASON()are available in all versions of OpenSSL. ogs fr fr.ERR_GET_FUNC()was removed in OpenSSL 3.0. gone. not coming back. π
π COPYRIGHT π
Copyright 2000-2023 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!! π this was OpenSSL 3.5.9, dated 2026-09-29, and it's ERR_GET_LIB(3ossl) β go forth and decode your error codes responsibly, mwah πβ¨
π¦ where this page comes from
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms