Mercurial > hg > orthanc
changeset 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 | 38b0f51781aa |
children | 6462ecaa045b |
files | Core/Enumerations.cpp Core/Enumerations.h Core/HttpServer/HttpServer.cpp NEWS OrthancServer/main.cpp Plugins/Include/orthanc/OrthancCPlugin.h Resources/CMake/CivetwebConfiguration.cmake Resources/ErrorCodes.json Resources/Patches/civetweb-1.12.patch |
diffstat | 9 files changed, 79 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/Core/Enumerations.cpp Wed Apr 01 11:08:43 2020 +0200 +++ b/Core/Enumerations.cpp Thu Apr 02 11:24:47 2020 +0200 @@ -189,6 +189,9 @@ case ErrorCode_BadGeometry: return "Geometry error encountered in Stone"; + case ErrorCode_SslInitialization: + return "Cannot initialize SSL encryption, check out your certificates"; + case ErrorCode_SQLiteNotOpened: return "SQLite: The database is not opened";
--- a/Core/Enumerations.h Wed Apr 01 11:08:43 2020 +0200 +++ b/Core/Enumerations.h Thu Apr 02 11:24:47 2020 +0200 @@ -180,6 +180,7 @@ ErrorCode_DatabaseUnavailable = 36 /*!< The database is currently not available (probably a transient situation) */, ErrorCode_CanceledJob = 37 /*!< This job was canceled */, ErrorCode_BadGeometry = 38 /*!< Geometry error encountered in Stone */, + ErrorCode_SslInitialization = 39 /*!< Cannot initialize SSL encryption, check out your certificates */, ErrorCode_SQLiteNotOpened = 1000 /*!< SQLite: The database is not opened */, ErrorCode_SQLiteAlreadyOpened = 1001 /*!< SQLite: Connection is already open */, ErrorCode_SQLiteCannotOpen = 1002 /*!< SQLite: Unable to open the database */,
--- 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()
--- a/NEWS Wed Apr 01 11:08:43 2020 +0200 +++ b/NEWS Thu Apr 02 11:24:47 2020 +0200 @@ -8,6 +8,9 @@ * Source code repository moved from BitBucket to self-hosted server * Fix lookup form in Orthanc Explorer (wildcards not allowed in StudyDate) * Fix signature of "OrthancPluginRegisterStorageCommitmentScpCallback()" in plugins SDK +* Error reporting on failure while initializing SSL +* Upgraded dependencies for static builds (notably on Windows): + - civetweb 1.12 Version 1.6.0 (2020-03-18)
--- a/OrthancServer/main.cpp Wed Apr 01 11:08:43 2020 +0200 +++ b/OrthancServer/main.cpp Thu Apr 02 11:24:47 2020 +0200 @@ -700,6 +700,7 @@ PrintErrorCode(ErrorCode_DatabaseUnavailable, "The database is currently not available (probably a transient situation)"); PrintErrorCode(ErrorCode_CanceledJob, "This job was canceled"); PrintErrorCode(ErrorCode_BadGeometry, "Geometry error encountered in Stone"); + PrintErrorCode(ErrorCode_SslInitialization, "Cannot initialize SSL encryption, check out your certificates"); PrintErrorCode(ErrorCode_SQLiteNotOpened, "SQLite: The database is not opened"); PrintErrorCode(ErrorCode_SQLiteAlreadyOpened, "SQLite: Connection is already open"); PrintErrorCode(ErrorCode_SQLiteCannotOpen, "SQLite: Unable to open the database");
--- a/Plugins/Include/orthanc/OrthancCPlugin.h Wed Apr 01 11:08:43 2020 +0200 +++ b/Plugins/Include/orthanc/OrthancCPlugin.h Thu Apr 02 11:24:47 2020 +0200 @@ -243,6 +243,7 @@ OrthancPluginErrorCode_DatabaseUnavailable = 36 /*!< The database is currently not available (probably a transient situation) */, OrthancPluginErrorCode_CanceledJob = 37 /*!< This job was canceled */, OrthancPluginErrorCode_BadGeometry = 38 /*!< Geometry error encountered in Stone */, + OrthancPluginErrorCode_SslInitialization = 39 /*!< Cannot initialize SSL encryption, check out your certificates */, OrthancPluginErrorCode_SQLiteNotOpened = 1000 /*!< SQLite: The database is not opened */, OrthancPluginErrorCode_SQLiteAlreadyOpened = 1001 /*!< SQLite: Connection is already open */, OrthancPluginErrorCode_SQLiteCannotOpen = 1002 /*!< SQLite: Unable to open the database */,
--- a/Resources/CMake/CivetwebConfiguration.cmake Wed Apr 01 11:08:43 2020 +0200 +++ b/Resources/CMake/CivetwebConfiguration.cmake Thu Apr 02 11:24:47 2020 +0200 @@ -1,7 +1,7 @@ if (STATIC_BUILD OR NOT USE_SYSTEM_CIVETWEB) - set(CIVETWEB_SOURCES_DIR ${CMAKE_BINARY_DIR}/civetweb-1.11) - set(CIVETWEB_URL "http://orthanc.osimis.io/ThirdPartyDownloads/civetweb-1.11.tar.gz") - set(CIVETWEB_MD5 "b6d2175650a27924bccb747cbe084cd4") + set(CIVETWEB_SOURCES_DIR ${CMAKE_BINARY_DIR}/civetweb-1.12) + set(CIVETWEB_URL "http://orthanc.osimis.io/ThirdPartyDownloads/civetweb-1.12.tar.gz") + set(CIVETWEB_MD5 "2a2a82c19b10b4ac178952f227f19d70") if (IS_DIRECTORY "${CIVETWEB_SOURCES_DIR}") set(FirstRun OFF) @@ -13,7 +13,7 @@ execute_process( COMMAND ${PATCH_EXECUTABLE} -p0 -N -i - ${ORTHANC_ROOT}/Resources/Patches/civetweb-1.11.patch + ${ORTHANC_ROOT}/Resources/Patches/civetweb-1.12.patch WORKING_DIRECTORY ${CMAKE_BINARY_DIR} RESULT_VARIABLE Failure )
--- a/Resources/ErrorCodes.json Wed Apr 01 11:08:43 2020 +0200 +++ b/Resources/ErrorCodes.json Thu Apr 02 11:24:47 2020 +0200 @@ -217,6 +217,11 @@ "Name": "BadGeometry", "Description": "Geometry error encountered in Stone" }, + { + "Code": 39, + "Name": "SslInitialization", + "Description": "Cannot initialize SSL encryption, check out your certificates" + },
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Resources/Patches/civetweb-1.12.patch Thu Apr 02 11:24:47 2020 +0200 @@ -0,0 +1,30 @@ +diff -urEb civetweb-1.12.orig/include/civetweb.h civetweb-1.12/include/civetweb.h +--- civetweb-1.12.orig/include/civetweb.h 2020-04-02 10:56:55.681988632 +0200 ++++ civetweb-1.12/include/civetweb.h 2020-04-02 10:57:36.413858039 +0200 +@@ -1614,6 +1614,9 @@ + struct mg_error_data *error); + #endif + ++// Added by SJ ++CIVETWEB_API void mg_disable_keep_alive(struct mg_connection *conn); ++ + #ifdef __cplusplus + } + #endif /* __cplusplus */ +diff -urEb civetweb-1.12.orig/src/civetweb.c civetweb-1.12/src/civetweb.c +--- civetweb-1.12.orig/src/civetweb.c 2020-04-02 10:56:55.685988619 +0200 ++++ civetweb-1.12/src/civetweb.c 2020-04-02 11:00:31.345304121 +0200 +@@ -20705,4 +20705,13 @@ + } + + ++// Added by SJ ++void mg_disable_keep_alive(struct mg_connection *conn) ++{ ++ if (conn != NULL) { ++ conn->must_close = 1; ++ } ++} ++ ++ + /* End of civetweb.c */