| 1 |
.\" -*- mode: troff; coding: utf-8 -*- |
| 2 |
.\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45) |
| 3 |
.\" |
| 4 |
.\" Standard preamble: |
| 5 |
.\" ======================================================================== |
| 6 |
.de Sp \" Vertical space (when we can't use .PP) |
| 7 |
.if t .sp .5v |
| 8 |
.if n .sp |
| 9 |
.. |
| 10 |
.de Vb \" Begin verbatim text |
| 11 |
.ft CW |
| 12 |
.nf |
| 13 |
.ne \\$1 |
| 14 |
.. |
| 15 |
.de Ve \" End verbatim text |
| 16 |
.ft R |
| 17 |
.fi |
| 18 |
.. |
| 19 |
.\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. |
| 20 |
.ie n \{\ |
| 21 |
. ds C` "" |
| 22 |
. ds C' "" |
| 23 |
'br\} |
| 24 |
.el\{\ |
| 25 |
. ds C` |
| 26 |
. ds C' |
| 27 |
'br\} |
| 28 |
.\" |
| 29 |
.\" Escape single quotes in literal strings from groff's Unicode transform. |
| 30 |
.ie \n(.g .ds Aq \(aq |
| 31 |
.el .ds Aq ' |
| 32 |
.\" |
| 33 |
.\" If the F register is >0, we'll generate index entries on stderr for |
| 34 |
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index |
| 35 |
.\" entries marked with X<> in POD. Of course, you'll have to process the |
| 36 |
.\" output yourself in some meaningful fashion. |
| 37 |
.\" |
| 38 |
.\" Avoid warning from groff about undefined register 'F'. |
| 39 |
.de IX |
| 40 |
.. |
| 41 |
.nr rF 0 |
| 42 |
.if \n(.g .if rF .nr rF 1 |
| 43 |
.if (\n(rF:(\n(.g==0)) \{\ |
| 44 |
. if \nF \{\ |
| 45 |
. de IX |
| 46 |
. tm Index:\\$1\t\\n%\t"\\$2" |
| 47 |
.. |
| 48 |
. if !\nF==2 \{\ |
| 49 |
. nr % 0 |
| 50 |
. nr F 2 |
| 51 |
. \} |
| 52 |
. \} |
| 53 |
.\} |
| 54 |
.rr rF |
| 55 |
.\" ======================================================================== |
| 56 |
.\" |
| 57 |
.IX Title "ERR_PUT_ERROR 3SSL" |
| 58 |
.TH ERR_PUT_ERROR 3SSL 2026-04-07 3.6.2 OpenSSL |
| 59 |
.\" For nroff, turn off justification. Always turn off hyphenation; it makes |
| 60 |
.\" way too many mistakes in technical documents. |
| 61 |
.if n .ad l |
| 62 |
.nh |
| 63 |
.SH NAME |
| 64 |
ERR_raise, ERR_raise_data, |
| 65 |
ERR_put_error, ERR_add_error_data, ERR_add_error_vdata, |
| 66 |
ERR_add_error_txt, ERR_add_error_mem_bio |
| 67 |
\&\- record an error |
| 68 |
.SH SYNOPSIS |
| 69 |
.IX Header "SYNOPSIS" |
| 70 |
.Vb 1 |
| 71 |
\& #include <openssl/err.h> |
| 72 |
\& |
| 73 |
\& void ERR_raise(int lib, int reason); |
| 74 |
\& void ERR_raise_data(int lib, int reason, const char *fmt, ...); |
| 75 |
\& |
| 76 |
\& void ERR_add_error_data(int num, ...); |
| 77 |
\& void ERR_add_error_vdata(int num, va_list arg); |
| 78 |
\& void ERR_add_error_txt(const char *sep, const char *txt); |
| 79 |
\& void ERR_add_error_mem_bio(const char *sep, BIO *bio); |
| 80 |
.Ve |
| 81 |
.PP |
| 82 |
The following function has been deprecated since OpenSSL 3.0, and can be |
| 83 |
hidden entirely by defining \fBOPENSSL_API_COMPAT\fR with a suitable version value, |
| 84 |
see \fBopenssl_user_macros\fR\|(7): |
| 85 |
.PP |
| 86 |
.Vb 1 |
| 87 |
\& void ERR_put_error(int lib, int func, int reason, const char *file, int line); |
| 88 |
.Ve |
| 89 |
.SH DESCRIPTION |
| 90 |
.IX Header "DESCRIPTION" |
| 91 |
\&\fBERR_raise()\fR adds a new error to the thread's error queue. The |
| 92 |
error occurred in the library \fBlib\fR for the reason given by the |
| 93 |
\&\fBreason\fR code. Furthermore, the name of the file, the line, and name |
| 94 |
of the function where the error occurred is saved with the error |
| 95 |
record. |
| 96 |
.PP |
| 97 |
\&\fBERR_raise_data()\fR does the same thing as \fBERR_raise()\fR, but also lets the |
| 98 |
caller specify additional information as a format string \fBfmt\fR and an |
| 99 |
arbitrary number of values, which are processed with \fBBIO_snprintf\fR\|(3). |
| 100 |
.PP |
| 101 |
\&\fBERR_put_error()\fR adds an error code to the thread's error queue. It |
| 102 |
signals that the error of reason code \fBreason\fR occurred in function |
| 103 |
\&\fBfunc\fR of library \fBlib\fR, in line number \fBline\fR of \fBfile\fR. |
| 104 |
This function is usually called by a macro. |
| 105 |
.PP |
| 106 |
\&\fBERR_add_error_data()\fR associates the concatenation of its \fBnum\fR string |
| 107 |
arguments as additional data with the error code added last. |
| 108 |
\&\fBERR_add_error_vdata()\fR is similar except the argument is a \fBva_list\fR. |
| 109 |
Multiple calls to these functions append to the current top of the error queue. |
| 110 |
The total length of the string data per error is limited to 4096 characters. |
| 111 |
.PP |
| 112 |
\&\fBERR_add_error_txt()\fR appends the given text string as additional data to the |
| 113 |
last error queue entry, after inserting the optional separator string if it is |
| 114 |
not NULL and the top error entry does not yet have additional data. |
| 115 |
In case the separator is at the end of the text it is not appended to the data. |
| 116 |
The \fBsep\fR argument may be for instance "\en" to insert a line break when needed. |
| 117 |
If the associated data would become more than 4096 characters long |
| 118 |
(which is the limit given above) |
| 119 |
it is split over sufficiently many new copies of the last error queue entry. |
| 120 |
.PP |
| 121 |
\&\fBERR_add_error_mem_bio()\fR is the same as \fBERR_add_error_txt()\fR except that |
| 122 |
the text string is taken from the given memory BIO. |
| 123 |
It appends '\e0' to the BIO contents if not already NUL-terminated. |
| 124 |
.PP |
| 125 |
\&\fBERR_load_strings\fR\|(3) can be used to register |
| 126 |
error strings so that the application can a generate human-readable |
| 127 |
error messages for the error code. |
| 128 |
.SS "Reporting errors" |
| 129 |
.IX Subsection "Reporting errors" |
| 130 |
\fIOpenSSL library reports\fR |
| 131 |
.IX Subsection "OpenSSL library reports" |
| 132 |
.PP |
| 133 |
Each OpenSSL sub-library has library code \fBERR_LIB_XXX\fR and has its own set |
| 134 |
of reason codes \fBXXX_R_...\fR. These are both passed in combination to |
| 135 |
\&\fBERR_raise()\fR and \fBERR_raise_data()\fR, and the combination ultimately produces |
| 136 |
the correct error text for the reported error. |
| 137 |
.PP |
| 138 |
All these macros and the numbers they have as values are specific to |
| 139 |
OpenSSL's libraries. OpenSSL reason codes normally consist of textual error |
| 140 |
descriptions. For example, the function \fBssl3_read_bytes()\fR reports a |
| 141 |
"handshake failure" as follows: |
| 142 |
.PP |
| 143 |
.Vb 1 |
| 144 |
\& ERR_raise(ERR_LIB_SSL, SSL_R_SSL_HANDSHAKE_FAILURE); |
| 145 |
.Ve |
| 146 |
.PP |
| 147 |
There are two exceptions: |
| 148 |
.IP \fBERR_LIB_SYS\fR 4 |
| 149 |
.IX Item "ERR_LIB_SYS" |
| 150 |
This "library code" indicates that a system error is being reported. In |
| 151 |
this case, the reason code given to \fBERR_raise()\fR and \fBERR_raise_data()\fR \fImust\fR |
| 152 |
be \fBerrno\fR\|(3). |
| 153 |
.Sp |
| 154 |
.Vb 1 |
| 155 |
\& ERR_raise(ERR_LIB_SYS, errno); |
| 156 |
.Ve |
| 157 |
.IP \fBERR_R_XXX\fR 4 |
| 158 |
.IX Item "ERR_R_XXX" |
| 159 |
This set of error codes is considered global, and may be used in combination |
| 160 |
with any sub-library code. |
| 161 |
.Sp |
| 162 |
.Vb 1 |
| 163 |
\& ERR_raise(ERR_LIB_RSA, ERR_R_PASSED_INVALID_ARGUMENT); |
| 164 |
.Ve |
| 165 |
.PP |
| 166 |
\fIOther pieces of software\fR |
| 167 |
.IX Subsection "Other pieces of software" |
| 168 |
.PP |
| 169 |
Other pieces of software that may want to use OpenSSL's error reporting |
| 170 |
system, such as engines or applications, must normally get their own |
| 171 |
numbers. |
| 172 |
.IP \(bu 4 |
| 173 |
To get a "library" code, call \fBERR_get_next_error_library\fR\|(3); this gives |
| 174 |
the calling code a dynamic number, usable for the duration of the process. |
| 175 |
.IP \(bu 4 |
| 176 |
Reason codes for each such "library" are determined or generated by the |
| 177 |
authors of that code. They must be numbers in the range 1 to 524287 (in |
| 178 |
other words, they must be nonzero unsigned 18 bit integers). |
| 179 |
.PP |
| 180 |
The exceptions mentioned in "OpenSSL library reports" above are valid for |
| 181 |
other pieces of software, i.e. they may use \fBERR_LIB_SYS\fR to report system |
| 182 |
errors: |
| 183 |
.PP |
| 184 |
.Vb 1 |
| 185 |
\& ERR_raise(ERR_LIB_SYS, errno); |
| 186 |
.Ve |
| 187 |
.PP |
| 188 |
\&... and they may use \fBERR_R_XXX\fR macros together with their own "library" |
| 189 |
code. |
| 190 |
.PP |
| 191 |
.Vb 1 |
| 192 |
\& int app_lib_code = ERR_get_next_error_library(); |
| 193 |
\& |
| 194 |
\& /* ... */ |
| 195 |
\& |
| 196 |
\& ERR_raise(app_lib_code, ERR_R_PASSED_INVALID_ARGUMENT); |
| 197 |
.Ve |
| 198 |
.SH "RETURN VALUES" |
| 199 |
.IX Header "RETURN VALUES" |
| 200 |
\&\fBERR_raise()\fR, \fBERR_raise_data()\fR, \fBERR_put_error()\fR, |
| 201 |
\&\fBERR_add_error_data()\fR, \fBERR_add_error_vdata()\fR |
| 202 |
\&\fBERR_add_error_txt()\fR, and \fBERR_add_error_mem_bio()\fR |
| 203 |
return no values. |
| 204 |
.SH NOTES |
| 205 |
.IX Header "NOTES" |
| 206 |
\&\fBERR_raise()\fR, \fBERR_raise()\fR and \fBERR_put_error()\fR are implemented as macros. |
| 207 |
.SH "SEE ALSO" |
| 208 |
.IX Header "SEE ALSO" |
| 209 |
\&\fBERR_load_strings\fR\|(3), \fBERR_get_next_error_library\fR\|(3) |
| 210 |
.SH HISTORY |
| 211 |
.IX Header "HISTORY" |
| 212 |
ERR_raise, ERR_raise_data, \fBERR_add_error_txt()\fR and \fBERR_add_error_mem_bio()\fR |
| 213 |
were added in OpenSSL 3.0. |
| 214 |
.SH COPYRIGHT |
| 215 |
.IX Header "COPYRIGHT" |
| 216 |
Copyright 2000\-2020 The OpenSSL Project Authors. All Rights Reserved. |
| 217 |
.PP |
| 218 |
Licensed under the Apache License 2.0 (the "License"). You may not use |
| 219 |
this file except in compliance with the License. You can obtain a copy |
| 220 |
in the file LICENSE in the source distribution or at |
| 221 |
<https://www.openssl.org/source/license.html>. |