diff Core/HttpServer/HttpServer.cpp @ 3801:9fe1d64a748c

upgrade to civetweb 1.12, error reporting if OpenSSL failure
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 02 Apr 2020 11:24:47 +0200
parents 2a170a8f1faf
children 0c16051dfd56
line wrap: on
line diff
--- a/Core/HttpServer/HttpServer.cpp	Wed Apr 01 11:08:43 2020 +0200
+++ b/Core/HttpServer/HttpServer.cpp	Thu Apr 02 11:24:47 2020 +0200
@@ -72,7 +72,8 @@
 #endif
 
 #if ORTHANC_ENABLE_SSL == 1
-#include <openssl/opensslv.h>
+#  include <openssl/opensslv.h>
+#  include <openssl/err.h>
 #endif
 
 #define ORTHANC_REALM "Orthanc Secure Area"
@@ -1182,8 +1183,35 @@
 
       if (!pimpl_->context_)
       {
-        throw OrthancException(ErrorCode_HttpPortInUse,
-                               " (port = " + boost::lexical_cast<std::string>(port_) + ")");
+        bool isSslError = false;
+
+#if ORTHANC_ENABLE_SSL == 1
+        for (;;)
+        {
+          unsigned long code = ERR_get_error();
+          if (code == 0)
+          {
+            break;
+          }
+          else
+          {
+            isSslError = true;
+            char message[1024];
+            ERR_error_string_n(code, message, sizeof(message) - 1);
+            LOG(ERROR) << "OpenSSL error: " << message;
+          }
+        }        
+#endif
+
+        if (isSslError)
+        {
+          throw OrthancException(ErrorCode_SslInitialization);
+        }
+        else
+        {
+          throw OrthancException(ErrorCode_HttpPortInUse,
+                                 " (port = " + boost::lexical_cast<std::string>(port_) + ")");
+        }
       }
 
       LOG(WARNING) << "HTTP server listening on port: " << GetPortNumber()