openssl: Update initialization and cleanup for OpenSSL 1.1.0
We can't call OPENSSL_cleanup() as that would prevent us from re-initializing the library again (which we use in the Android app, that loads/unloads plugins).
This commit is contained in:
@@ -515,6 +515,10 @@ METHOD(plugin_t, get_features, int,
|
|||||||
METHOD(plugin_t, destroy, void,
|
METHOD(plugin_t, destroy, void,
|
||||||
private_openssl_plugin_t *this)
|
private_openssl_plugin_t *this)
|
||||||
{
|
{
|
||||||
|
/* OpenSSL 1.1.0 cleans up itself at exit and while OPENSSL_cleanup() exists we
|
||||||
|
* can't call it as we couldn't re-initialize the library (as required by the
|
||||||
|
* unit tests and the Android app) */
|
||||||
|
#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
||||||
#ifndef OPENSSL_IS_BORINGSSL
|
#ifndef OPENSSL_IS_BORINGSSL
|
||||||
CONF_modules_free();
|
CONF_modules_free();
|
||||||
OBJ_cleanup();
|
OBJ_cleanup();
|
||||||
@@ -526,6 +530,7 @@ METHOD(plugin_t, destroy, void,
|
|||||||
CRYPTO_cleanup_all_ex_data();
|
CRYPTO_cleanup_all_ex_data();
|
||||||
threading_cleanup();
|
threading_cleanup();
|
||||||
ERR_free_strings();
|
ERR_free_strings();
|
||||||
|
#endif /* OPENSSL_VERSION_NUMBER */
|
||||||
|
|
||||||
free(this);
|
free(this);
|
||||||
}
|
}
|
||||||
@@ -568,12 +573,23 @@ plugin_t *openssl_plugin_create()
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
|
||||||
|
/* note that we can't call OPENSSL_cleanup() when the plugin is destroyed
|
||||||
|
* as we couldn't initialize the library again afterwards */
|
||||||
|
OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CONFIG |
|
||||||
|
OPENSSL_INIT_ENGINE_ALL_BUILTIN, NULL);
|
||||||
|
#else /* OPENSSL_VERSION_NUMBER */
|
||||||
threading_init();
|
threading_init();
|
||||||
|
|
||||||
#ifndef OPENSSL_IS_BORINGSSL
|
#ifndef OPENSSL_IS_BORINGSSL
|
||||||
OPENSSL_config(NULL);
|
OPENSSL_config(NULL);
|
||||||
#endif
|
#endif
|
||||||
OpenSSL_add_all_algorithms();
|
OpenSSL_add_all_algorithms();
|
||||||
|
#ifndef OPENSSL_NO_ENGINE
|
||||||
|
/* activate support for hardware accelerators */
|
||||||
|
ENGINE_load_builtin_engines();
|
||||||
|
ENGINE_register_all_complete();
|
||||||
|
#endif /* OPENSSL_NO_ENGINE */
|
||||||
|
#endif /* OPENSSL_VERSION_NUMBER */
|
||||||
|
|
||||||
#ifdef OPENSSL_FIPS
|
#ifdef OPENSSL_FIPS
|
||||||
/* we do this here as it may have been enabled via openssl.conf */
|
/* we do this here as it may have been enabled via openssl.conf */
|
||||||
@@ -582,12 +598,6 @@ plugin_t *openssl_plugin_create()
|
|||||||
"openssl FIPS mode(%d) - %sabled ", fips_mode, fips_mode ? "en" : "dis");
|
"openssl FIPS mode(%d) - %sabled ", fips_mode, fips_mode ? "en" : "dis");
|
||||||
#endif /* OPENSSL_FIPS */
|
#endif /* OPENSSL_FIPS */
|
||||||
|
|
||||||
#ifndef OPENSSL_NO_ENGINE
|
|
||||||
/* activate support for hardware accelerators */
|
|
||||||
ENGINE_load_builtin_engines();
|
|
||||||
ENGINE_register_all_complete();
|
|
||||||
#endif /* OPENSSL_NO_ENGINE */
|
|
||||||
|
|
||||||
if (!seed_rng())
|
if (!seed_rng())
|
||||||
{
|
{
|
||||||
DBG1(DBG_CFG, "no RNG found to seed OpenSSL");
|
DBG1(DBG_CFG, "no RNG found to seed OpenSSL");
|
||||||
|
|||||||
Reference in New Issue
Block a user