Mercurial > hg > orthanc
diff Core/Toolbox.cpp @ 2677:0196d07a900f jobs
migrate OpenSSL initialization to Toolbox
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 15 Jun 2018 11:16:37 +0200 |
parents | 97a74f0eac7a |
children | e0476e8cb73d |
line wrap: on
line diff
--- 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 <boost/locale.hpp> #endif +#if ORTHANC_ENABLE_SSL == 1 +// For OpenSSL initialization and finalization +# include <openssl/conf.h> +# include <openssl/engine.h> +# include <openssl/err.h> +# include <openssl/evp.h> +# include <openssl/ssl.h> +#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)