1 .\" $OpenBSD: ERR.3,v 1.5 2016/11/23 17:54:15 schwarze Exp $
2 .\" OpenSSL 186bb907 Apr 13 11:05:13 2015 -0700
4 .\" This file was written by Ulf Moeller <ulf@openssl.org> and
5 .\" Dr. Stephen Henson <steve@openssl.org>.
6 .\" Copyright (c) 2000, 2015 The OpenSSL Project. All rights reserved.
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\" notice, this list of conditions and the following disclaimer.
15 .\" 2. Redistributions in binary form must reproduce the above copyright
16 .\" notice, this list of conditions and the following disclaimer in
17 .\" the documentation and/or other materials provided with the
20 .\" 3. All advertising materials mentioning features or use of this
21 .\" software must display the following acknowledgment:
22 .\" "This product includes software developed by the OpenSSL Project
23 .\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
25 .\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26 .\" endorse or promote products derived from this software without
27 .\" prior written permission. For written permission, please contact
28 .\" openssl-core@openssl.org.
30 .\" 5. Products derived from this software may not be called "OpenSSL"
31 .\" nor may "OpenSSL" appear in their names without prior written
32 .\" permission of the OpenSSL Project.
34 .\" 6. Redistributions of any form whatsoever must retain the following
36 .\" "This product includes software developed by the OpenSSL Project
37 .\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
39 .\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40 .\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43 .\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 .\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 .\" OF THE POSSIBILITY OF SUCH DAMAGE.
52 .Dd $Mdocdate: November 23 2016 $
57 .Nd OpenSSL error codes
61 When a call to the OpenSSL library fails, this is usually signaled by
62 the return value, and an error code is stored in an error queue
63 associated with the current thread.
66 library provides functions to obtain these error codes and textual error
70 manpage describes how to access error codes.
72 Error codes contain information about where the error occurred, and what
75 describes how to extract this information.
76 A method to obtain human-readable error messages is described in
77 .Xr ERR_error_string 3 .
80 can be used to clear the error queue.
83 .Xr ERR_remove_state 3
84 should be used to avoid memory leaks when threads are terminated.
85 .Sh ADDING NEW ERROR CODES TO OPENSSL
88 if you want to record error codes in the OpenSSL error system from
89 within your application.
91 The remainder of this section is of interest only if you want to add new
92 error codes to OpenSSL or add error codes from external libraries.
94 When you are using new function or reason codes, run
98 will then automatically be added to the sub-library's header file.
99 .Ss Adding new libraries
100 When adding a new sub-library to OpenSSL, assign it a library number
105 .In openssl/err.h ) ,
107 .Va ERR_str_libraries[]
109 .Pa /usr/src/lib/libcrypto/err/err.c ) ,
111 .Fn ERR_load_XXX_strings
113 .Fn ERR_load_crypto_strings
115 .Sy /usr/src/lib/libcrypto/err/err_all.c ) .
116 Finally, add an entry
118 .Dl L XXX xxx.h xxx_err.c
121 .Sy /usr/src/lib/libcrypto/err/openssl.ec ,
128 will then generate a file
130 and add all error codes used in the library to
133 Additionally the library include file must have a certain form.
134 Typically it will initially look like this:
135 .Bd -literal -offset indent
145 #include <openssl/bio.h>
146 #include <openssl/x509.h>
148 /* Macros, structures and function prototypes */
150 /* BEGIN ERROR CODES */
154 .Sy BEGIN ERROR CODES
155 sequence is used by the error code generation script as the point to
156 place new error codes.
157 Any text after this point will be overwritten when
160 The closing #endif etc. will be automatically added by the script.
162 The generated C error code file
164 will load the header files
169 so the header file must load any additional header files containing any
171 .Sh USING ERROR CODES IN EXTERNAL LIBRARIES
172 It is also possible to use OpenSSL's error code scheme in external
174 The library needs to load its own codes and call the OpenSSL error code
177 explicitly to add codes to the header file and generate the C error code
179 This will normally be done if the external library needs to generate new
180 ASN.1 structures but it can also be used to add more general purpose
183 The error queues are stored in a hash table with one
187 returns the current thread's
194 When more error codes are added, the old ones are overwritten, on the
195 assumption that the most recent errors are most important.
197 Error strings are also stored in a hash table.
198 The hash tables can be obtained by calling
199 .Fn ERR_get_err_state_table
201 .Fn ERR_get_string_table .
203 .Xr CRYPTO_set_locking_callback 3 ,
204 .Xr ERR_clear_error 3 ,
205 .Xr ERR_error_string 3 ,
206 .Xr ERR_get_error 3 ,
208 .Xr ERR_load_crypto_strings 3 ,
209 .Xr ERR_load_strings 3 ,
210 .Xr ERR_print_errors 3 ,
211 .Xr ERR_put_error 3 ,
212 .Xr ERR_remove_state 3 ,