comparison OrthancServer/OrthancInitialization.cpp @ 1526:096a8af528c9

fix streams, initialization/finalization of libcurl and openssl
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 12 Aug 2015 10:43:10 +0200
parents 27661b33f624
children 0011cc99443c
comparison
equal deleted inserted replaced
1525:f9b0169eb6bb 1526:096a8af528c9
47 #include <boost/filesystem.hpp> 47 #include <boost/filesystem.hpp>
48 #include <curl/curl.h> 48 #include <curl/curl.h>
49 #include <boost/thread.hpp> 49 #include <boost/thread.hpp>
50 50
51 51
52 #if ORTHANC_SSL_ENABLED == 1
53 // For OpenSSL initialization and finalization
54 #include <openssl/conf.h>
55 #include <openssl/engine.h>
56 #include <openssl/err.h>
57 #include <openssl/evp.h>
58 #include <openssl/ssl.h>
59 #endif
60
61
52 #if ORTHANC_JPEG_ENABLED == 1 62 #if ORTHANC_JPEG_ENABLED == 1
53 #include <dcmtk/dcmjpeg/djdecode.h> 63 #include <dcmtk/dcmjpeg/djdecode.h>
54 #endif 64 #endif
55 65
56 66
257 267
258 void OrthancInitialize(const char* configurationFile) 268 void OrthancInitialize(const char* configurationFile)
259 { 269 {
260 boost::mutex::scoped_lock lock(globalMutex_); 270 boost::mutex::scoped_lock lock(globalMutex_);
261 271
272 #if ORTHANC_SSL_ENABLED == 1
273 // https://wiki.openssl.org/index.php/Library_Initialization
274 SSL_library_init();
275 SSL_load_error_strings();
276 OpenSSL_add_all_algorithms();
277 ERR_load_crypto_strings();
278
279 curl_global_init(CURL_GLOBAL_ALL);
280 #else
281 curl_global_init(CURL_GLOBAL_ALL & ~CURL_GLOBAL_SSL);
282 #endif
283
262 InitializeServerEnumerations(); 284 InitializeServerEnumerations();
263 285
264 // Read the user-provided configuration 286 // Read the user-provided configuration
265 ReadGlobalConfiguration(configurationFile); 287 ReadGlobalConfiguration(configurationFile);
266 288
295 #endif 317 #endif
296 318
297 #if ORTHANC_JPEG_ENABLED == 1 319 #if ORTHANC_JPEG_ENABLED == 1
298 // Unregister JPEG codecs 320 // Unregister JPEG codecs
299 DJDecoderRegistration::cleanup(); 321 DJDecoderRegistration::cleanup();
322 #endif
323
324 curl_global_cleanup();
325
326 #if ORTHANC_SSL_ENABLED == 1
327 // Finalize OpenSSL
328 // https://wiki.openssl.org/index.php/Library_Initialization#Cleanup
329 FIPS_mode_set(0);
330 ENGINE_cleanup();
331 CONF_modules_unload(1);
332 EVP_cleanup();
333 CRYPTO_cleanup_all_ex_data();
334 ERR_remove_state(0);
335 ERR_free_strings();
300 #endif 336 #endif
301 } 337 }
302 338
303 339
304 340