Error handling for OpenSSL

Source: Internet
Author: User
Tags openssl library

Skilled use of error functions is particularly important for the correct use of open source libraries.

Here is a simple example of an application:

Include header file: Openssl/err.h

Loading error messages
Err_load_err_strings ();
Err_load_crypto_strings ();
Get error number
unsigned long ulerr = Err_get_error ();
Char szerrmsg[1024] = {0};
char *ptmp = NULL;
Format: Error:errid: library: function: Reason
Ptmp = err_error_string (ulerr,szerrmsg);

Other information needs to use the rich functions in the OpenSSL library, and here are 28 functions that you can apply yourself against the instructions.

1) Err_add_error_data

Add descriptive information to the err_data element of this layer error. This function is typically called by individual modules, for example, it can be used to indicate what operation caused the error.

2) Err_clear_error

Clears all error messages. If you do not know all the error messages, there may be other unrelated errors left in the Err_state table.

3) Err_error_string/err_error_string_n

Obtain specific error information based on the error code, including the library where the error occurred, the function that failed, and the cause of the error.

4) Err_free_strings

Releases the error message hash table, usually at the last call.

5) err_func_error_string

Gets the function information of the error based on the fault number.

6) err_get_err_state_table

Gets the hash table that holds the error.

7) Err_get_error

Gets the first error number.

8) Err_get_error_line

Gets the line number of the error, based on the error number.

9) Err_get_error_line_data

Gets an error message based on the error number.

) err_get_implementation

Gets the error handler associated with the hash table operation.

One) err_get_state

Gets the Err_state table.

err_lib_error_string)

Based on the error number, gets the library error.

Err_load_strings)

Loading error messages, called by each module.

Err_load_asn1_strings)

Err_load_bio_strings

Err_load_bn_strings

Err_load_buf_strings

Err_load_comp_strings

Err_load_conf_strings

Err_load_crypto_strings

Err_load_crypto_strings

Err_load_dh_strings

Err_load_dsa_strings

Err_load_dso_strings

Err_load_ec_strings

Err_load_engine_strings

Err_load_err_strings

Err_load_evp_strings

Err_load_obj_strings

Err_load_ocsp_strings

Err_load_pem_strings

Err_load_pkcs12_strings

Err_load_pkcs7_strings

Err_load_rand_strings

Err_load_rsa_strings

Err_load_ui_strings

Err_load_x509_strings

Err_load_x509v3_strings

Each module is implemented to load its own error message.

Err_peek_error)

Gets the first error number.

Err_peek_error_line)

Gets the error line for the first error.

Err_peek_error_line_data)

Gets the number of rows and error messages for the first error.

) Err_peek_last_error

Gets the last error number.

Err_peek_last_error_line)

Gets the line number of the last error.

Err_peek_last_error_line_data)

Gets the line number and error information for the last error.

) err_print_errors

Output the error message to the bio.

ERR_PRINT_ERRORS_CB)

The error message is printed according to the callback function set by the user.

ERR_PRINT_ERRORS_FP)

Prints the error to file.

) Err_put_error

The error message is stored in the error stack specified by top of the Err_state table (the last error).

err_reason_error_string)

Get the cause of the error based on the error number.

Err_remove_state)

Removes thread-related error messages.

Err_set_error_data)

The error message is stored in the error stack specified by top of the Err_state table (the last error).

Err_unload_strings)

Removes the relevant information from the Error hash table.

Error handling for OpenSSL

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.