ERR_GET_LIB(3SSL)

πŸ’– ERR_GET_LIB(3SSL) β€” girl help, what does this error code even MEAN πŸ’–

okay bestie, pull up a chair, we're reading ERR_GET_LIB(3SSL) from the OpenSSL manual and honestly?? it's giving detective work πŸ”βœ¨


🌸 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 whole vibe here is that the error code you get back from ERR_get_error() is literally two things squished into one: a library number and a reason code. and ERR_GET_LIB() and ERR_GET_REASON() are the little tools that pull those two apart πŸ”₯

ERR_FATAL_ERROR() tells you whether a given error code is a fatal error. that's it, that's the job πŸ’€

the library number describes where the error happened. the reason code is the info about what went wrong. iconic division of labor, no notes πŸ‘‘

every sub-library of OpenSSL has its own unique library number, and the reason code is unique within each sub-library. buuut β€” and this is important, bestie β€” different libraries may totally use the same value to signal different reasons. so don't get cute and compare bare reason codes across libraries, okay? πŸ™ˆ

ERR_R_... reason codes like ERR_R_MALLOC_FAILURE are globally unique though. that's the good stuff. but when you're checking for sub-library specific reason codes, be sure to also compare the library number. periodt πŸ’―

also just so you know: ERR_GET_LIB(), ERR_GET_REASON(), and ERR_FATAL_ERROR() are macros.

🌈 RETURN VALUES 🌈

they return the library number, the reason code, and whether the error is fatal, respectively β€” in that order, matching the three of them πŸŽ€

and starting with OpenSSL 3.0.0, the function code is always set to zero. yes girl, always zero. that's not a typo, that's just the lore now ⭐

πŸ¦‹ NOTES πŸ¦‹

bestie. listen. do not 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. and even then, new failure codes may still appear at any time. so like, build your logic on the documented contract, not on the vibes of one specific number πŸ™

πŸ’œ 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. rest in peace king πŸ’€βœ¨

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 4.0.3, dated 2026-09-29 β€” ERR_GET_LIB(3SSL), slay, go forth and debug responsibly πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from