ERR(3)
π NAME π
ERR β OpenSSL error codes
okay bestie, welcome to the ERR(3) page from the Library Functions Manual β this is literally the group chat for OpenSSL error codes π
πΈ SYNOPSIS πΈ
library βlibcryptoβ #include <openssl/err.h>
β¨ DESCRIPTION β¨
so when a call to the OpenSSL library fails, itβs usually signaled by the return value π and an error code gets stored in an error queue thatβs associated with the current thread. The ERR library is the bestie that hands you functions to obtain those error codes and textual error messages. Wanna know how to access error codes? The ERR_get_error(3) manpage describes that.
Error codes are carrying the lore: they contain information about where the error occurred and what went wrong π ERR_GET_LIB(3) describes how to extract this information. And the method to obtain human-readable error messages? Thatβs described in ERR_error_string(3).
Need to clear the error queue? ERR_clear_error(3) can do that, no cap.
β οΈ note bestie: ERR_remove_state(3) should be used to avoid memory leaks when threads are terminated. Not me forgetting that one π
π οΈ ADDING NEW ERROR CODES TO OPENSSL π οΈ
if you want to record error codes in the OpenSSL error system from within your application, see ERR_put_error(3) β¨
The remainder of this section is of interest only if you want to add new error codes to OpenSSL or add error codes from external libraries. iykyk.
When you are using new function or reason codes, run make errors. The necessary #defines will then automatically be added to the sub-libraryβs header file. slay.
π§ Adding new libraries π§
When adding a new sub-library to OpenSSL, assign it a library number ERR_LIB_XXX, define a macro XXXerr() (both in <openssl/err.h>), add its name to ERR_str_libraries[] (in /usr/src/lib/libcrypto/err/err.c), and add ERR_load_XXX_strings() to the ERR_load_crypto_strings() function (in /usr/src/lib/libcrypto/err/err_all.c). Finally, add xxx_err.c to the Makefile. periodt π
π USING ERROR CODES IN EXTERNAL LIBRARIES π
It is also possible to use OpenSSLβs error code scheme in external libraries. yes bestie, go off π«Ά
π INTERNALS π
The error queues are stored in a hash table with one ERR_STATE entry for each PID. ERR_get_state() returns the current threadβs ERR_STATE. An ERR_STATE can hold up to ERR_NUM_ERRORS error codes. When more error codes are added, the old ones are overwritten, on the assumption that the most recent errors are most important. highkey makes sense.
Error strings are also stored in a hash table. iconic.
π SEE ALSO π
crypto(3)ERR_asprintf_error_data(3)ERR_clear_error(3)ERR_error_string(3)ERR_get_error(3)ERR_GET_LIB(3)ERR_load_crypto_strings(3)ERR_load_strings(3)ERR_print_errors(3)ERR_put_error(3)ERR_remove_state(3)ERR_set_mark(3)SSL_get_error(3)
cute sign-off: this page comes from Debian, dated June 8, 2025, and itβs ERR(3) β mwah π
π¦ where this page comes from
- alpine 3.24: libressl-doc 4.3.1-r0 Β· custom
- arch rolling: libressl 4.4.0-1 Β· ISC AND custom:OpenSSL
- Copyright (c) 2000, 2015 The OpenSSL Project. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms