ERR_GET_LIB(3ossl)
π NAME π
Okay bestie, welcome to the ERR_GET_LIB(3ossl) page! This is all about pulling info out of OpenSSL error codes: ERR_GET_LIB, ERR_GET_REASON, and ERR_FATAL_ERROR β get information from error codes. β¨
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 ERR_get_error() hands you an error code, and that code is literally made of two parts: a library number and a reason code. ERR_GET_LIB() and ERR_GET_REASON() are the little extractor tools for those parts. π«Ά
ERR_FATAL_ERROR() tells you whether a given error code is a fatal error. π
The library number is the βwhere did this happenβ part, and the reason code is the βwhat went wrongβ part. Every sub-library of OpenSSL has a unique library number; the reason code is unique within each sub-library. Important: different libraries may use the same value to signal different reasons. So donβt assume a reason code means the same thing across libraries, okay? π
ERR_R_... reason codes like ERR_R_MALLOC_FAILURE are globally unique. But when youβre checking for sub-library specific reason codes, be sure to also compare the library number. No cap. π₯
Also: ERR_GET_LIB(), ERR_GET_REASON(), and ERR_FATAL_ERROR() are macros. β¨
π RETURN VALUES π
Respectively, you get the library number, the reason code, and whether the error is fatal. And starting with OpenSSL 3.0.0, the function code is always set to zero. Periodt. π
β οΈ NOTES β οΈ
Bestie, please donβt make control flow decisions based on specific error codes. Error codes are subject to change at any time β even in patch releases of OpenSSL. π A particular error code can only be considered meaningful for control flow decisions if it is explicitly documented as such. New failure codes may still appear at any time.
π SEE ALSO π
π°οΈ HISTORY π°οΈ
ERR_GET_LIB()andERR_GET_REASON()are available in all versions of OpenSSL. πERR_GET_FUNC()was removed in OpenSSL 3.0. π
Β©οΈ 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>.
This iconic little page is from OpenSSL 3.5.6, dated 2026-04-07. Bye bestie, go slay those error codes π
β¨
π¦ where this page comes from
- freebsd 15.1: base 15.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms