# HG changeset patch # User Sebastien Jodogne # Date 1517589275 -3600 # Node ID 7a3f4d580625311b8efc60a38bfb6f11dfb0bc9f # Parent 24bd36849c56237c1a00035ea53549606c1f49a3 SSL is enabled by default for HTTPS transfers diff -r 24bd36849c56 -r 7a3f4d580625 Applications/ApplicationToolbox.cpp --- a/Applications/ApplicationToolbox.cpp Mon Jan 15 09:36:39 2018 +0100 +++ b/Applications/ApplicationToolbox.cpp Fri Feb 02 17:34:35 2018 +0100 @@ -235,5 +235,64 @@ LOG(WARNING) << "Orthanc WSI version: " << version; } + + + + void AddRestApiOptions(boost::program_options::options_description& section) + { + section.add_options() + ("username", boost::program_options::value(), "Username for the target Orthanc server") + ("password", boost::program_options::value(), "Password for the target Orthanc server") + ("proxy", boost::program_options::value(), "HTTP proxy to be used") + ("timeout", boost::program_options::value()->default_value(0), "HTTP timeout (in seconds, 0 means no timeout)") + ("verify-peers", boost::program_options::value()->default_value(true), "Enable the verification of the peers during HTTPS requests") + ("ca-certificates", boost::program_options::value()->default_value(""), "Path to the CA (certification authority) certificates to validate peers in HTTPS requests") + ; + } + + + void SetupRestApi(Orthanc::WebServiceParameters& parameters, + const boost::program_options::variables_map& options) + { + if (options.count("orthanc")) + { + parameters.SetUrl(options["orthanc"].as()); + } + + if (options.count("username") && + options.count("password")) + { + parameters.SetUsername(options["username"].as()); + parameters.SetPassword(options["password"].as()); + } + + if (options.count("timeout")) + { + int timeout = options["timeout"].as(); + if (timeout < 0) + { + LOG(ERROR) << "Timeouts cannot be negative: " << timeout; + throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); + } + else + { + Orthanc::HttpClient::SetDefaultTimeout(timeout); + } + + if (options.count("proxy")) + { + Orthanc::HttpClient::SetDefaultProxy(options["proxy"].as()); + } + } + +#if ORTHANC_ENABLE_SSL == 1 + if (options.count("verify-peers") || + options.count("ca-certificates")) + { + Orthanc::HttpClient::ConfigureSsl(options["verify-peers"].as(), + options["ca-certificates"].as()); + } +#endif + } } } diff -r 24bd36849c56 -r 7a3f4d580625 Applications/ApplicationToolbox.h --- a/Applications/ApplicationToolbox.h Mon Jan 15 09:36:39 2018 +0100 +++ b/Applications/ApplicationToolbox.h Fri Feb 02 17:34:35 2018 +0100 @@ -22,9 +22,11 @@ #pragma once #include "../Resources/Orthanc/Core/MultiThreading/BagOfTasks.h" +#include "../Resources/Orthanc/Core/WebServiceParameters.h" #include #include +#include namespace OrthancWSI { @@ -45,5 +47,10 @@ void PrintVersion(const char* path); void ShowVersionInLog(const char* path); + + void AddRestApiOptions(boost::program_options::options_description& section); + + void SetupRestApi(Orthanc::WebServiceParameters& parameters, + const boost::program_options::variables_map& options); } } diff -r 24bd36849c56 -r 7a3f4d580625 Applications/CMakeLists.txt --- a/Applications/CMakeLists.txt Mon Jan 15 09:36:39 2018 +0100 +++ b/Applications/CMakeLists.txt Fri Feb 02 17:34:35 2018 +0100 @@ -12,7 +12,7 @@ SET(ENABLE_PROFILING OFF CACHE BOOL "Whether to enable the generation of profiling information with gprof") # Optional components -SET(ENABLE_SSL OFF CACHE BOOL "Include support for SSL") +SET(ENABLE_SSL ON CACHE BOOL "Include support for SSL") SET(USE_DCMTK_361 OFF CACHE BOOL "Use forthcoming DCMTK version 3.6.1 in static builds (instead of 3.6.0)") if (CMAKE_SYSTEM_NAME STREQUAL "Linux") diff -r 24bd36849c56 -r 7a3f4d580625 Applications/DicomToTiff.cpp --- a/Applications/DicomToTiff.cpp Mon Jan 15 09:36:39 2018 +0100 +++ b/Applications/DicomToTiff.cpp Fri Feb 02 17:34:35 2018 +0100 @@ -31,8 +31,6 @@ #include "ApplicationToolbox.h" -#include - static bool ParseParameters(int& exitStatus, boost::program_options::variables_map& options, @@ -51,9 +49,8 @@ source.add_options() ("orthanc", boost::program_options::value()->default_value("http://localhost:8042/"), "URL to the REST API of the target Orthanc server") - ("username", boost::program_options::value(), "Username for the target Orthanc server") - ("password", boost::program_options::value(), "Password for the target Orthanc server") ; + OrthancWSI::ApplicationToolbox::AddRestApiOptions(source); boost::program_options::options_description target("Options for the target TIFF image"); target.add_options() @@ -286,20 +283,7 @@ { Orthanc::WebServiceParameters params; - if (options.count("orthanc")) - { - params.SetUrl(options["orthanc"].as()); - } - - if (options.count("username")) - { - params.SetUsername(options["username"].as()); - } - - if (options.count("password")) - { - params.SetPassword(options["password"].as()); - } + OrthancWSI::ApplicationToolbox::SetupRestApi(params, options); OrthancPlugins::OrthancHttpConnection orthanc(params); OrthancWSI::DicomPyramid source(orthanc, options["input"].as(), diff -r 24bd36849c56 -r 7a3f4d580625 Applications/Dicomizer.cpp --- a/Applications/Dicomizer.cpp Mon Jan 15 09:36:39 2018 +0100 +++ b/Applications/Dicomizer.cpp Fri Feb 02 17:34:35 2018 +0100 @@ -33,7 +33,6 @@ #include "../Framework/Outputs/TruncatedPyramidWriter.h" #include "../Resources/Orthanc/Core/DicomParsing/FromDcmtkBridge.h" -#include "../Resources/Orthanc/Core/HttpClient.h" #include "../Resources/Orthanc/Core/Logging.h" #include "../Resources/Orthanc/Core/MultiThreading/BagOfTasksProcessor.h" #include "../Resources/Orthanc/Core/OrthancException.h" @@ -43,8 +42,6 @@ #include -#include - #include #include #include @@ -513,8 +510,6 @@ "Pattern for the files in the output folder") ("orthanc", boost::program_options::value()->default_value("http://localhost:8042/"), "URL to the REST API of the target Orthanc server") - ("username", boost::program_options::value(), "Username for the target Orthanc server") - ("password", boost::program_options::value(), "Password for the target Orthanc server") ; boost::program_options::options_description volumeOptions("Description of the imaged volume"); @@ -528,6 +523,9 @@ "Y offset the specimen, wrt. slide coordinates origin (in mm)") ; + boost::program_options::options_description restOptions("HTTP/HTTPS client configuration to access the Orthanc REST API"); + OrthancWSI::ApplicationToolbox::AddRestApiOptions(restOptions); + boost::program_options::options_description advancedOptions("Advanced options"); advancedOptions.add_options() ("optical-path", boost::program_options::value()->default_value("brightfield"), @@ -546,7 +544,14 @@ ; boost::program_options::options_description allWithoutHidden; - allWithoutHidden.add(generic).add(source).add(pyramid).add(target).add(volumeOptions).add(advancedOptions); + allWithoutHidden + .add(generic) + .add(source) + .add(pyramid) + .add(target) + .add(volumeOptions) + .add(restOptions) + .add(advancedOptions); boost::program_options::options_description all = allWithoutHidden; all.add(hidden); @@ -745,17 +750,7 @@ parameters.SetTargetFolderPattern(options["folder-pattern"].as()); } - if (options.count("orthanc")) - { - parameters.GetOrthancParameters().SetUrl(options["orthanc"].as()); - - if (options.count("username") && - options.count("password")) - { - parameters.GetOrthancParameters().SetUsername(options["username"].as()); - parameters.GetOrthancParameters().SetPassword(options["password"].as()); - } - } + OrthancWSI::ApplicationToolbox::SetupRestApi(parameters.GetOrthancParameters(), options); if (options.count("dataset")) { diff -r 24bd36849c56 -r 7a3f4d580625 NEWS --- a/NEWS Mon Jan 15 09:36:39 2018 +0100 +++ b/NEWS Fri Feb 02 17:34:35 2018 +0100 @@ -3,6 +3,7 @@ * "--max-size=0" allowed to create a single instance per pyramid level * Support more colorspaces with JPEG2k +* SSL is enabled by default for HTTPS transfers * Fix Debian #876807 (orthanc-wsi FTBFS with libopenjp2-7-dev 2.2.0-1) * Support of OpenBSD and FreeBSD * Support of Linux Standard Base