---
name: "libressl-ERR"
section: "3"
platform: "linux"
package: "libressl"
version: "4.4.0-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/libressl-ERR"
---

# libressl-ERR(3)

OpenSSL error codes

## NAME

**ERR** – OpenSSL error codes

## SYNOPSIS

Crypto Library (libcrypto, -lcrypto)

**#include \<openssl/err.h\>**

## DESCRIPTION

When a call to the OpenSSL library fails, this is usually signaled by the return value, and an error code is stored in an error queue associated with the current thread. The **ERR** library provides functions to obtain these error codes and textual error messages. The ERR\_get\_error(3) manpage describes how to access error codes.

Error codes contain information about where the error occurred, and what went wrong. ERR\_GET\_LIB(3) describes how to extract this information. A method to obtain human-readable error messages is described in ERR\_error\_string(3).

ERR\_clear\_error(3) can be used to clear the error queue.

Note that ERR\_remove\_state(3) should be used to avoid memory leaks when threads are terminated.

## ADDING NEW ERROR CODES TO OPENSSL

See ERR\_put\_error(3) if you want to record error codes in the OpenSSL error system from within your application.

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.

When you are using new function or reason codes, run **make** **errors**. The necessary **#define**s will then automatically be added to the sub-library's header file.

### 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*.

## USING ERROR CODES IN EXTERNAL LIBRARIES

It is also possible to use OpenSSL's error code scheme in external libraries.

## 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.

Error strings are also stored in a hash table.

## SEE ALSO

[crypto(3)](/crypto/3.md), 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)
