OpenSSL/初始化
外觀
< OpenSSL
要初始化 libcrypto 和 libssl
[first, set up threading callbacks if your program is multithreaded] SSL_load_error_strings (); SSL_library_init (); OpenSSL_add_all_algorithms (); OPENSSL_config (NULL);
或者僅初始化 libcrypto,不初始化 libssl
[first, set up threading callbacks if your program is multithreaded] ERR_load_crypto_strings (); OpenSSL_add_all_algorithms (); OPENSSL_config (NULL);
注意:OPENSSL_config 會呼叫 ENGINE_load_builtin_engines,因此如果您呼叫 OPENSSL_config,則不需要呼叫 ENGINE_load_builtin_engines(事實上,這樣做似乎會導致記憶體洩漏)。
OpenSSL 無法識別 pthreads 或 Windows 執行緒。因此,如果您的程式是多執行緒的,則必須編寫回調,將 OpenSSL 連線到 pthreads 或 Windows 執行緒(或者兩者,如果您的程式是跨平臺的)。
不是必需的,因為資源將在程序終止時釋放,但您可以執行以下操作
ERR_free_strings (); RAND_cleanup (); EVP_cleanup (); // this seems to cause double-frees for me: ENGINE_cleanup (); CONF_modules_free (); ERR_remove_state (0);
