From 67f60f1889cd14ab4044b38bcf70163cec1ec759 Mon Sep 17 00:00:00 2001 From: orignal Date: Tue, 4 Dec 2018 21:20:12 -0500 Subject: [PATCH] set openssl no_config before boost::asio:ssl --- libi2pd/Crypto.cpp | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/libi2pd/Crypto.cpp b/libi2pd/Crypto.cpp index 271e98a1..60ba4c8f 100644 --- a/libi2pd/Crypto.cpp +++ b/libi2pd/Crypto.cpp @@ -1239,15 +1239,10 @@ namespace crypto } }*/ - + void InitCrypto (bool precomputation) { - i2p::cpu::Detect (); -#if LEGACY_OPENSSL - OPENSSL_no_config (); -#else - OPENSSL_init_crypto (OPENSSL_INIT_NO_LOAD_CONFIG, NULL); -#endif + i2p::cpu::Detect (); SSL_library_init (); /* auto numLocks = CRYPTO_num_locks(); for (int i = 0; i < numLocks; i++) @@ -1283,3 +1278,22 @@ namespace crypto } } } + +// TODO: move to InitCrypto if boost::asio::ssl is not used anymore +// no_config must be called before SSL_library_init () +class DummyOpenSSLInitializer +{ + public: + + DummyOpenSSLInitializer () + { +#if LEGACY_OPENSSL + OPENSSL_no_config (); +#else + OPENSSL_init_ssl (OPENSSL_INIT_NO_LOAD_CONFIG, NULL); +#endif + } +}; +static DummyOpenSSLInitializer g_OpenSSLInitializer; // must be called before +// boost::asio::ssl containing static openssl_init instance_; +#include