diff OrthancServer/OrthancInitialization.cpp @ 2352:3ab96768d144

Fix issue #52 (DICOM level security association problems)
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 18 Jul 2017 17:33:26 +0200
parents 9c7a80c87ae9
children 96b3ec054b69
line wrap: on
line diff
--- a/OrthancServer/OrthancInitialization.cpp	Tue Jul 18 08:41:09 2017 +0200
+++ b/OrthancServer/OrthancInitialization.cpp	Tue Jul 18 17:33:26 2017 +0200
@@ -855,10 +855,30 @@
   }
 
 
-  bool Configuration::IsKnownAETitle(const std::string& aet)
+  bool Configuration::IsKnownAETitle(const std::string& aet,
+                                     const std::string& ip)
   {
     RemoteModalityParameters modality;
-    return LookupDicomModalityUsingAETitle(modality, aet);
+    
+    if (!LookupDicomModalityUsingAETitle(modality, aet))
+    {
+      LOG(WARNING) << "Modality \"" << aet
+                   << "\" is not listed in the \"DicomModalities\" configuration option";
+      return false;
+    }
+    else if (!Configuration::GetGlobalBoolParameter("DicomCheckModalityHost", false) ||
+             ip == modality.GetHost())
+    {
+      return true;
+    }
+    else
+    {
+      LOG(WARNING) << "Forbidding access from AET \"" << aet
+                   << "\" given its hostname (" << ip << ") does not match "
+                   << "the \"DicomModalities\" configuration option ("
+                   << modality.GetHost() << " was expected)";
+      return false;
+    }
   }