Reputation: 10028
In my C project I updated the OpenSSl library 1.0.2g into newer one (1.1.x versions) while I was compiling my code I had the following warning thrown:
main.c:40:3: warning: ‘OPENSSL_config’ is deprecated [-Wdeprecated-declarations] OPENSSL_config(NULL);
The code throwing this error is:
#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;
}
So as the best practices dictate I should avoid and use alternative approaches on deprecated functions in my case which one should I use?
Upvotes: 3
Views: 3058
Reputation: 14148
The OPENSSL_config says it all:
This function is deprecated and its use should be avoided. Applications should instead call CONF_modules_load() during initialization (that is before starting any threads).
Also SSL_load_error_strings and OpenSSL_add_all_algorithms are also deprecated as well.
For openssl >= 1.1 you can remove the your whole startup and cleanup code above as it's not needed any longer. It's all done automatically now for you.
Upvotes: 6