在我的C项目,我OpenSSL库1.0.2g更新到较新的一个(1.1.x的版本),而我编译我的代码,我有以下警告抛出:
main.c中:40:3:警告:“OPENSSL_config”被弃用[-Wdeprecated-声明] OPENSSL_config(NULL);
引发此错误代码是:
#include <stdio.h>
// Openssl
#include <openssl/conf.h>
#include <openssl/evp.h>
#include <openssl/err.h>
int main(int argc, char *argv[]) {
/* Load the human readable error strings for libcrypto */
ERR_load_crypto_strings();
/* Load all digest and cipher algorithms */
OpenSSL_add_all_algorithms();
/* Load config file, and other important initialisation */
OPENSSL_config(NULL);
//Come code here
EVP_cleanup();
CRYPTO_cleanup_all_ex_data();
ERR_free_strings();
return 0;
}
因此,作为最佳实践要求我应该避免和我的情况不建议使用的功能,哪一个我应该用用其他办法?
该OPENSSL_config说,这一切:
此功能已被废弃,应避免其使用。应用程序应改为调用CONF_modules_load()初始化期间(即在开始任何线程之前)。
此外SSL_load_error_strings和OpenSSL_add_all_algorithms也不赞成好。
OpenSSL的> = 1.1,你可以删除你的整个启动和清理代码上面是没有必要的任何更长的时间。这一切都自动现在为你做。