diff Core/HttpClient.cpp @ 2099:bcbc9137a535

refactoring
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 07 Oct 2016 11:13:41 +0200
parents 72a7624215ae
children 58a0ee0b4be1
line wrap: on
line diff
--- a/Core/HttpClient.cpp	Thu Oct 06 17:28:43 2016 +0200
+++ b/Core/HttpClient.cpp	Fri Oct 07 11:13:41 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
+  }
 }