Openssl consists of 2 libraries: libcrypto
and libssl
. Before openssl API can be used in an application, mandatory initialization procedures are expected to be performed. Once application is done with openssl related work, it is expected to cleanup allocated resources.
Code below does complete initialization, however, developer is free to initialize only openssl stuff he is interested in.
ERR_load_crypto_strings();
OpenSSL_add_all_algorithms();
OPENSSL_config(NULL); // Load default configuration (e.g. openssl.conf)
OPENSSL_init_ssl(0, NULL);
CONF_modules_unload(1);
EVP_cleanup();
CRYPTO_cleanup_all_ex_data();
ERR_remove_state();
ERR_free_strings();