ERR_GET_LIB(3ossl)

πŸ“¦
version 15.1 Β· 3 versions
, in freebsd 15.1

πŸ’– 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() and ERR_GET_REASON() are available in all versions of OpenSSL. πŸ’–
  • ERR_GET_FUNC() was removed in OpenSSL 3.0. πŸ’€

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