Err_error_string

 admin

C (Cpp) ERRerrorstring - 30 examples found. These are the top rated real world C (Cpp) examples of ERRerrorstring extracted from open source projects. You can rate examples to help us improve the quality of examples. ERRerrorstring generates a human-readable string representing the error code e, and places it at buf. Buf must be at least 256 bytes long. If buf is NULL, the error string is placed in a static buffer. Note that this function is not thread-safe and does no checks on the size of the buffer; use ERRerrorstringn instead. ERRerrorstringn is a variant of ERRerrorstring that writes at most len characters (including the terminating 0) and truncates the string if necessary. For ERRerrorstringn, buf may not be NULL. The string will have the following format. Namespace: System Assembly: System.Console.dll Assemblies: mscorlib.dll, System.Console.dll Assembly: mscorlib.dll Assembly: netstandard.dll. Instead of returning a pointer to a static buffer, wolfSSL's ERRerrorstring will return a pointer to a static constant string 'Please supply a buffer for error string'. We don't have a complete list of compatibility gaps, but will help answer your questions if you encounter them in your porting effort.

ERR_error_string() generates a human-readable string representing the error code e and places it in buf. buf must be at least 256 bytes long. If buf is NULL, the error string is placed in a static buffer. Note that this function is not thread-safe and does no checks on the size of the buffer; use ERR_error_string_n() instead.

ERR_error_string_n() is a variant of ERR_error_string() that writes at most len characters (including the terminating NUL) and truncates the string if necessary. For ERR_error_string_n(), buf may not be NULL.

The string will have the following format:

Err_error_string_n
error:[error code]:[library name]:[function name]:[reason string]

The error code is an 8-digit hexadecimal number. The library name, the function name, and the reason string are ASCII text.

ERR_lib_error_string(), ERR_func_error_string(), and ERR_reason_error_string() return the library name, the function name, and the reason string, respectively.

The OpenSSL error strings should be loaded by calling ERR_load_crypto_strings(3) or, for SSL applications, SSL_load_error_strings(3) first. If there is no text string registered for the given error code, the error string will contain the numeric code.

ERR_print_errors(3) can be used to print all error codes currently in the queue.

8.1 Debugging and Logging

wolfSSL (formerly CyaSSL) has support for debugging through log messages in environments where debugging is limited. To turn logging on use the function wolfSSL_Debugging_ON() and to turn it off use wolfSSL_Debugging_OFF(). In a normal build (release mode) these functions will have no effect. In a debug build, define DEBUG_WOLFSSL to ensure these functions are turned on.

As of wolfSSL 2.0, logging callback functions may be registered at runtime to provide more flexibility with how logging is done. The logging callback can be registered with the following function:

int wolfSSL_SetLoggingCb(wolfSSL_Logging_cb log_function);

typedef void (*wolfSSL_Logging_cb)(const int logLevel,

const char *const logMessage);

The log levels can be found in wolfssl/wolfcrypt/logging.h, and the implementation is located in logging.c. By default, wolfSSL logs to stderr with fprintf.

8.2 Error Codes

wolfSSL tries to provide informative error messages in order to help with debugging.

Each wolfSSL_read() and wolfSSL_write() call will return the number of bytes written upon success, 0 upon connection closure, and -1 for an error, just like read() and write(). In the event of an error you can use two calls to get more information about the error.

The function wolfSSL_get_error() will return the current error code. It takes the current WOLFSSL object, and wolfSSL_read() or wolfSSL_write() result value as an arguments and returns the corresponding error code.

Err_error_stringErr_error_string

int err = wolfSSL_get_error(ssl, result);

To get a more human-readable error code description, the wolfSSL_ERR_error_string() function can be used. It takes the return code from wolfSSL_get_error and a storage buffer as arguments, and places the corresponding error description into the storage buffer (errorString in the example below).

char errorString[80];

wolfSSL_ERR_error_string(err, errorString);

Null)

Err_error_string Err_peek Last_error

If you are using non blocking sockets, you can test for errno EAGAIN/EWOULDBLOCK or more correctly you can test the specific error code for SSL_ERROR_WANT_READ or SSL_ERROR_WANT_WRITE.

Err_error_string(err_get_error() Null)

For a list of wolfSSL and wolfCrypt error codes, please see Appendix C (Error Codes).