comparison Applications/ApplicationToolbox.cpp @ 125:7a3f4d580625

SSL is enabled by default for HTTPS transfers
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 02 Feb 2018 17:34:35 +0100
parents e8fe7c9a7d6c
children 2cb9fabb529e
comparison
equal deleted inserted replaced
124:24bd36849c56 125:7a3f4d580625
233 } 233 }
234 } 234 }
235 235
236 LOG(WARNING) << "Orthanc WSI version: " << version; 236 LOG(WARNING) << "Orthanc WSI version: " << version;
237 } 237 }
238
239
240
241 void AddRestApiOptions(boost::program_options::options_description& section)
242 {
243 section.add_options()
244 ("username", boost::program_options::value<std::string>(), "Username for the target Orthanc server")
245 ("password", boost::program_options::value<std::string>(), "Password for the target Orthanc server")
246 ("proxy", boost::program_options::value<std::string>(), "HTTP proxy to be used")
247 ("timeout", boost::program_options::value<int>()->default_value(0), "HTTP timeout (in seconds, 0 means no timeout)")
248 ("verify-peers", boost::program_options::value<bool>()->default_value(true), "Enable the verification of the peers during HTTPS requests")
249 ("ca-certificates", boost::program_options::value<std::string>()->default_value(""), "Path to the CA (certification authority) certificates to validate peers in HTTPS requests")
250 ;
251 }
252
253
254 void SetupRestApi(Orthanc::WebServiceParameters& parameters,
255 const boost::program_options::variables_map& options)
256 {
257 if (options.count("orthanc"))
258 {
259 parameters.SetUrl(options["orthanc"].as<std::string>());
260 }
261
262 if (options.count("username") &&
263 options.count("password"))
264 {
265 parameters.SetUsername(options["username"].as<std::string>());
266 parameters.SetPassword(options["password"].as<std::string>());
267 }
268
269 if (options.count("timeout"))
270 {
271 int timeout = options["timeout"].as<int>();
272 if (timeout < 0)
273 {
274 LOG(ERROR) << "Timeouts cannot be negative: " << timeout;
275 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
276 }
277 else
278 {
279 Orthanc::HttpClient::SetDefaultTimeout(timeout);
280 }
281
282 if (options.count("proxy"))
283 {
284 Orthanc::HttpClient::SetDefaultProxy(options["proxy"].as<std::string>());
285 }
286 }
287
288 #if ORTHANC_ENABLE_SSL == 1
289 if (options.count("verify-peers") ||
290 options.count("ca-certificates"))
291 {
292 Orthanc::HttpClient::ConfigureSsl(options["verify-peers"].as<bool>(),
293 options["ca-certificates"].as<std::string>());
294 }
295 #endif
296 }
238 } 297 }
239 } 298 }