Mercurial > hg > orthanc
changeset 2101:0b6464320aac
merge
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 10 Oct 2016 15:56:07 +0200 |
parents | 1554fc153a93 (current diff) bcbc9137a535 (diff) |
children | f0544ab9396b |
files | |
diffstat | 3 files changed, 46 insertions(+), 30 deletions(-) [+] |
line wrap: on
line diff
--- a/Core/HttpClient.cpp Mon Oct 10 15:55:56 2016 +0200 +++ b/Core/HttpClient.cpp Mon Oct 10 15:56:07 2016 +0200 @@ -44,6 +44,16 @@ #include <boost/thread/mutex.hpp> +#if ORTHANC_SSL_ENABLED == 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 ORTHANC_PKCS11_ENABLED == 1 # include "Pkcs11.h" #endif @@ -784,4 +794,32 @@ throw OrthancException(ErrorCode_InternalError); #endif } + + + void HttpClient::InitializeOpenSsl() + { +#if ORTHANC_SSL_ENABLED == 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_SSL_ENABLED == 1 + // Finalize OpenSSL + // https://wiki.openssl.org/index.php/Library_Initialization#Cleanup + FIPS_mode_set(0); + ENGINE_cleanup(); + CONF_modules_unload(1); + EVP_cleanup(); + CRYPTO_cleanup_all_ex_data(); + ERR_remove_state(0); + ERR_free_strings(); +#endif + } }
--- a/Core/HttpClient.h Mon Oct 10 15:55:56 2016 +0200 +++ b/Core/HttpClient.h Mon Oct 10 15:56:07 2016 +0200 @@ -247,6 +247,10 @@ static void GlobalFinalize(); + static void InitializeOpenSsl(); + + static void FinalizeOpenSsl(); + static void InitializePkcs11(const std::string& module, const std::string& pin, bool verbose);
--- a/OrthancServer/OrthancInitialization.cpp Mon Oct 10 15:55:56 2016 +0200 +++ b/OrthancServer/OrthancInitialization.cpp Mon Oct 10 15:56:07 2016 +0200 @@ -50,23 +50,13 @@ #include <boost/thread.hpp> -#if ORTHANC_SSL_ENABLED == 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 ORTHANC_JPEG_ENABLED == 1 -#include <dcmtk/dcmjpeg/djdecode.h> +# include <dcmtk/dcmjpeg/djdecode.h> #endif #if ORTHANC_JPEG_LOSSLESS_ENABLED == 1 -#include <dcmtk/dcmjpls/djdecode.h> +# include <dcmtk/dcmjpls/djdecode.h> #endif @@ -471,13 +461,7 @@ { boost::recursive_mutex::scoped_lock lock(globalMutex_); -#if ORTHANC_SSL_ENABLED == 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 + HttpClient::InitializeOpenSsl(); InitializeServerEnumerations(); @@ -531,17 +515,7 @@ DJDecoderRegistration::cleanup(); #endif -#if ORTHANC_SSL_ENABLED == 1 - // Finalize OpenSSL - // https://wiki.openssl.org/index.php/Library_Initialization#Cleanup - FIPS_mode_set(0); - ENGINE_cleanup(); - CONF_modules_unload(1); - EVP_cleanup(); - CRYPTO_cleanup_all_ex_data(); - ERR_remove_state(0); - ERR_free_strings(); -#endif + HttpClient::FinalizeOpenSsl(); }