# HG changeset patch # User Sebastien Jodogne # Date 1585819487 -7200 # Node ID 9fe1d64a748cc0fe81ef29cfb8e83f302e0bee11 # Parent 38b0f51781aa0c570839f3c8289573a26d9a26f6 upgrade to civetweb 1.12, error reporting if OpenSSL failure diff -r 38b0f51781aa -r 9fe1d64a748c Core/Enumerations.cpp --- 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"; diff -r 38b0f51781aa -r 9fe1d64a748c Core/Enumerations.h --- 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 */, diff -r 38b0f51781aa -r 9fe1d64a748c Core/HttpServer/HttpServer.cpp --- 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 +# include +# include #endif #define ORTHANC_REALM "Orthanc Secure Area" @@ -1182,8 +1183,35 @@ if (!pimpl_->context_) { - throw OrthancException(ErrorCode_HttpPortInUse, - " (port = " + boost::lexical_cast(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(port_) + ")"); + } } LOG(WARNING) << "HTTP server listening on port: " << GetPortNumber() diff -r 38b0f51781aa -r 9fe1d64a748c NEWS --- 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) diff -r 38b0f51781aa -r 9fe1d64a748c OrthancServer/main.cpp --- 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"); diff -r 38b0f51781aa -r 9fe1d64a748c Plugins/Include/orthanc/OrthancCPlugin.h --- 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 */, diff -r 38b0f51781aa -r 9fe1d64a748c Resources/CMake/CivetwebConfiguration.cmake --- 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 ) diff -r 38b0f51781aa -r 9fe1d64a748c Resources/ErrorCodes.json --- 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" + }, diff -r 38b0f51781aa -r 9fe1d64a748c Resources/Patches/civetweb-1.12.patch --- /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 */