1.\" $OpenBSD: ERR_error_string.3,v 1.7 2018/03/27 17:35:50 schwarze Exp $ 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 3.\" 4.\" This file was written by Ulf Moeller <ulf@openssl.org>. 5.\" Copyright (c) 2000, 2004 The OpenSSL Project. All rights reserved. 6.\" 7.\" Redistribution and use in source and binary forms, with or without 8.\" modification, are permitted provided that the following conditions 9.\" are met: 10.\" 11.\" 1. Redistributions of source code must retain the above copyright 12.\" notice, this list of conditions and the following disclaimer. 13.\" 14.\" 2. Redistributions in binary form must reproduce the above copyright 15.\" notice, this list of conditions and the following disclaimer in 16.\" the documentation and/or other materials provided with the 17.\" distribution. 18.\" 19.\" 3. All advertising materials mentioning features or use of this 20.\" software must display the following acknowledgment: 21.\" "This product includes software developed by the OpenSSL Project 22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)" 23.\" 24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 25.\" endorse or promote products derived from this software without 26.\" prior written permission. For written permission, please contact 27.\" openssl-core@openssl.org. 28.\" 29.\" 5. Products derived from this software may not be called "OpenSSL" 30.\" nor may "OpenSSL" appear in their names without prior written 31.\" permission of the OpenSSL Project. 32.\" 33.\" 6. Redistributions of any form whatsoever must retain the following 34.\" acknowledgment: 35.\" "This product includes software developed by the OpenSSL Project 36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)" 37.\" 38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" 51.Dd $Mdocdate: March 27 2018 $ 52.Dt ERR_ERROR_STRING 3 53.Os 54.Sh NAME 55.Nm ERR_error_string , 56.Nm ERR_error_string_n , 57.Nm ERR_lib_error_string , 58.Nm ERR_func_error_string , 59.Nm ERR_reason_error_string 60.Nd obtain human-readable OpenSSL error messages 61.Sh SYNOPSIS 62.In openssl/err.h 63.Ft char * 64.Fo ERR_error_string 65.Fa "unsigned long e" 66.Fa "char *buf" 67.Fc 68.Ft void 69.Fo ERR_error_string_n 70.Fa "unsigned long e" 71.Fa "char *buf" 72.Fa "size_t len" 73.Fc 74.Ft const char * 75.Fo ERR_lib_error_string 76.Fa "unsigned long e" 77.Fc 78.Ft const char * 79.Fo ERR_func_error_string 80.Fa "unsigned long e" 81.Fc 82.Ft const char * 83.Fo ERR_reason_error_string 84.Fa "unsigned long e" 85.Fc 86.Sh DESCRIPTION 87.Fn ERR_error_string 88generates a human-readable string representing the error code 89.Fa e 90and places it in 91.Fa buf . 92.Fa buf 93must be at least 256 bytes long. 94If 95.Fa buf 96is 97.Dv NULL , 98the error string is placed in a static buffer. 99Note that this function is not thread-safe and does no checks on 100the size of the buffer; use 101.Fn ERR_error_string_n 102instead. 103.Pp 104.Fn ERR_error_string_n 105is a variant of 106.Fn ERR_error_string 107that writes at most 108.Fa len 109characters (including the terminating NUL) and truncates the string 110if necessary. 111For 112.Fn ERR_error_string_n , 113.Fa buf 114may not be 115.Dv NULL . 116.Pp 117The string will have the following format: 118.Pp 119.Dl error:[error code]:[library name]:[function name]:[reason string] 120.Pp 121The error code is an 8-digit hexadecimal number. 122The library name, the function name, and the reason string are ASCII 123text. 124.Pp 125.Fn ERR_lib_error_string , 126.Fn ERR_func_error_string , 127and 128.Fn ERR_reason_error_string 129return the library name, the function name, and the reason string, 130respectively. 131.Pp 132The OpenSSL error strings should be loaded by calling 133.Xr ERR_load_crypto_strings 3 134or, for SSL applications, 135.Xr SSL_load_error_strings 3 136first. 137If there is no text string registered for the given error code, the 138error string will contain the numeric code. 139.Pp 140.Xr ERR_print_errors 3 141can be used to print all error codes currently in the queue. 142.Sh RETURN VALUES 143.Fn ERR_error_string 144returns a pointer to a static buffer containing the string if 145.Fa buf 146is 147.Dv NULL , 148or 149.Fa buf 150otherwise. 151.Pp 152.Fn ERR_lib_error_string , 153.Fn ERR_func_error_string , 154and 155.Fn ERR_reason_error_string 156return the strings, or 157.Dv NULL 158if none is registered for the error code. 159.Sh SEE ALSO 160.Xr ERR 3 , 161.Xr ERR_get_error 3 , 162.Xr ERR_load_crypto_strings 3 , 163.Xr ERR_print_errors 3 , 164.Xr SSL_load_error_strings 3 165.Sh HISTORY 166.Fn ERR_error_string , 167.Fn ERR_lib_error_string , 168.Fn ERR_func_error_string , 169and 170.Fn ERR_reason_error_string 171first appeared in SSLeay 0.4.4 and have been available since 172.Ox 2.4 . 173.Pp 174.Fn ERR_error_string_n 175first appeared in OpenSSL 0.9.6 and has been available since 176.Ox 2.9 . 177