diff OrthancServer/OrthancInitialization.cpp @ 1533:0011cc99443c

improving HTTPS support
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 12 Aug 2015 17:52:10 +0200
parents 096a8af528c9
children 95b3b0260240
line wrap: on
line diff
--- a/OrthancServer/OrthancInitialization.cpp	Wed Aug 12 15:04:12 2015 +0200
+++ b/OrthancServer/OrthancInitialization.cpp	Wed Aug 12 17:52:10 2015 +0200
@@ -77,6 +77,35 @@
   static std::string configurationAbsolutePath_;
 
 
+  static std::string GetGlobalStringParameterInternal(const std::string& parameter,
+                                                      const std::string& defaultValue)
+  {
+    if (configuration_.isMember(parameter))
+    {
+      return configuration_[parameter].asString();
+    }
+    else
+    {
+      return defaultValue;
+    }
+  }
+
+
+  static bool GetGlobalBoolParameterInternal(const std::string& parameter,
+                                             bool defaultValue)
+  {
+    if (configuration_.isMember(parameter))
+    {
+      return configuration_[parameter].asBool();
+    }
+    else
+    {
+      return defaultValue;
+    }
+  }
+
+
+
   static void AddFileToConfiguration(const boost::filesystem::path& path)
   {
     LOG(WARNING) << "Reading the configuration from: " << path;
@@ -286,7 +315,8 @@
     // Read the user-provided configuration
     ReadGlobalConfiguration(configurationFile);
 
-    HttpClient::GlobalInitialize();
+    HttpClient::GlobalInitialize(GetGlobalBoolParameterInternal("HttpsVerifyPeers", true),
+                                 GetGlobalStringParameterInternal("HttpsVerifyCertificates", ""));
 
     RegisterUserMetadata();
     RegisterUserContentType();
@@ -337,20 +367,11 @@
   }
 
 
-
   std::string Configuration::GetGlobalStringParameter(const std::string& parameter,
                                                       const std::string& defaultValue)
   {
     boost::mutex::scoped_lock lock(globalMutex_);
-
-    if (configuration_.isMember(parameter))
-    {
-      return configuration_[parameter].asString();
-    }
-    else
-    {
-      return defaultValue;
-    }
+    return GetGlobalStringParameterInternal(parameter, defaultValue);
   }
 
 
@@ -374,15 +395,7 @@
                                              bool defaultValue)
   {
     boost::mutex::scoped_lock lock(globalMutex_);
-
-    if (configuration_.isMember(parameter))
-    {
-      return configuration_[parameter].asBool();
-    }
-    else
-    {
-      return defaultValue;
-    }
+    return GetGlobalBoolParameterInternal(parameter, defaultValue);
   }