# HG changeset patch # User Sebastien Jodogne # Date 1529054197 -7200 # Node ID 0196d07a900fa171c47aba61c3ee5968d4b39ae7 # Parent d2f70c8f8bfdeced5c0bbb82c6f5b3e5fb66141f migrate OpenSSL initialization to Toolbox diff -r d2f70c8f8bfd -r 0196d07a900f Core/HttpClient.cpp --- a/Core/HttpClient.cpp Tue Jun 12 16:22:07 2018 +0200 +++ b/Core/HttpClient.cpp Fri Jun 15 11:16:37 2018 +0200 @@ -46,16 +46,6 @@ #include -#if ORTHANC_ENABLE_SSL == 1 -// For OpenSSL initialization and finalization -# include -# include -# include -# include -# include -#endif - - #if ORTHANC_ENABLE_PKCS11 == 1 # include "Pkcs11.h" #endif @@ -812,34 +802,4 @@ throw OrthancException(ErrorCode_InternalError); #endif } - - - void HttpClient::InitializeOpenSsl() - { -#if ORTHANC_ENABLE_SSL == 1 - // https://wiki.openssl.org/index.php/Library_Initialization - SSL_library_init(); - SSL_load_error_strings(); - OpenSSL_add_all_algorithms(); - ERR_load_crypto_strings(); -#endif - } - - - void HttpClient::FinalizeOpenSsl() - { -#if ORTHANC_ENABLE_SSL == 1 - // Finalize OpenSSL - // https://wiki.openssl.org/index.php/Library_Initialization#Cleanup -#ifdef FIPS_mode_set - FIPS_mode_set(0); -#endif - ENGINE_cleanup(); - CONF_modules_unload(1); - EVP_cleanup(); - CRYPTO_cleanup_all_ex_data(); - ERR_remove_state(0); - ERR_free_strings(); -#endif - } } diff -r d2f70c8f8bfd -r 0196d07a900f Core/HttpClient.h --- a/Core/HttpClient.h Tue Jun 12 16:22:07 2018 +0200 +++ b/Core/HttpClient.h Fri Jun 15 11:16:37 2018 +0200 @@ -268,10 +268,6 @@ static void GlobalFinalize(); - static void InitializeOpenSsl(); - - static void FinalizeOpenSsl(); - static void InitializePkcs11(const std::string& module, const std::string& pin, bool verbose); diff -r d2f70c8f8bfd -r 0196d07a900f Core/Toolbox.cpp --- a/Core/Toolbox.cpp Tue Jun 12 16:22:07 2018 +0200 +++ b/Core/Toolbox.cpp Fri Jun 15 11:16:37 2018 +0200 @@ -62,6 +62,15 @@ # include #endif +#if ORTHANC_ENABLE_SSL == 1 +// For OpenSSL initialization and finalization +# include +# include +# include +# include +# include +#endif + #if defined(_MSC_VER) && (_MSC_VER < 1800) // Patch for the missing "_strtoll" symbol when compiling with Visual Studio < 2013 @@ -1421,7 +1430,37 @@ globalLocale_.reset(); } - + + void Toolbox::InitializeOpenSsl() + { +#if ORTHANC_ENABLE_SSL == 1 + // https://wiki.openssl.org/index.php/Library_Initialization + SSL_library_init(); + SSL_load_error_strings(); + OpenSSL_add_all_algorithms(); + ERR_load_crypto_strings(); +#endif + } + + + void Toolbox::FinalizeOpenSsl() + { +#if ORTHANC_ENABLE_SSL == 1 + // Finalize OpenSSL + // https://wiki.openssl.org/index.php/Library_Initialization#Cleanup +#ifdef FIPS_mode_set + FIPS_mode_set(0); +#endif + ENGINE_cleanup(); + CONF_modules_unload(1); + EVP_cleanup(); + CRYPTO_cleanup_all_ex_data(); + ERR_remove_state(0); + ERR_free_strings(); +#endif + } + + std::string Toolbox::ToUpperCaseWithAccents(const std::string& source) { if (globalLocale_.get() == NULL) diff -r d2f70c8f8bfd -r 0196d07a900f Core/Toolbox.h --- a/Core/Toolbox.h Tue Jun 12 16:22:07 2018 +0200 +++ b/Core/Toolbox.h Fri Jun 15 11:16:37 2018 +0200 @@ -233,6 +233,10 @@ std::string ToUpperCaseWithAccents(const std::string& source); #endif + void InitializeOpenSsl(); + + void FinalizeOpenSsl(); + std::string GenerateUuid(); } } diff -r d2f70c8f8bfd -r 0196d07a900f OrthancServer/OrthancInitialization.cpp --- a/OrthancServer/OrthancInitialization.cpp Tue Jun 12 16:22:07 2018 +0200 +++ b/OrthancServer/OrthancInitialization.cpp Fri Jun 15 11:16:37 2018 +0200 @@ -458,7 +458,7 @@ { boost::recursive_mutex::scoped_lock lock(globalMutex_); - HttpClient::InitializeOpenSsl(); + Toolbox::InitializeOpenSsl(); InitializeServerEnumerations(); @@ -514,7 +514,7 @@ boost::recursive_mutex::scoped_lock lock(globalMutex_); HttpClient::GlobalFinalize(); FromDcmtkBridge::FinalizeCodecs(); - HttpClient::FinalizeOpenSsl(); + Toolbox::FinalizeOpenSsl(); Toolbox::FinalizeGlobalLocale(); }