| 405 | } |
| 406 | |
| 407 | Status Webserver::Start() { |
| 408 | LOG(INFO) << "Starting webserver on " << TNetworkAddressToString(http_address_); |
| 409 | |
| 410 | IpAddr ipv4, ipv6; |
| 411 | Status ip_v6_status = HostnameToIpAddr(http_address_.hostname, &ipv6, true); |
| 412 | Status ip_v4_status = HostnameToIpAddr(http_address_.hostname, &ipv4, false); |
| 413 | if (!ip_v4_status.ok() && !ip_v6_status.ok()) return ip_v6_status; |
| 414 | |
| 415 | if (IsSecure()) LOG(INFO) << "Webserver: Enabling HTTPS support"; |
| 416 | stringstream listening_spec; |
| 417 | if (ip_v6_status.ok()) { |
| 418 | listening_spec << "[" << ipv6 << "]:" << http_address_.port; |
| 419 | if (IsSecure()) listening_spec << "s"; |
| 420 | } |
| 421 | if (ip_v4_status.ok()) { |
| 422 | if (ip_v6_status.ok()) listening_spec << ","; |
| 423 | listening_spec << ipv4 << ":" << http_address_.port; |
| 424 | if (IsSecure()) listening_spec << "s"; |
| 425 | } |
| 426 | string listening_str = listening_spec.str(); |
| 427 | LOG(INFO) << "Starting webserver listening to " << listening_str; |
| 428 | |
| 429 | vector<const char*> options; |
| 430 | |
| 431 | if (!FLAGS_webserver_doc_root.empty() && FLAGS_enable_webserver_doc_root) { |
| 432 | LOG(INFO) << "Document root: " << FLAGS_webserver_doc_root; |
| 433 | options.push_back("document_root"); |
| 434 | options.push_back(FLAGS_webserver_doc_root.c_str()); |
| 435 | } else { |
| 436 | LOG(INFO)<< "Document root disabled"; |
| 437 | } |
| 438 | |
| 439 | string key_password; |
| 440 | if (IsSecure()) { |
| 441 | // Impala initializes OpenSSL (see authentication.h). |
| 442 | options.push_back("ssl_global_init"); |
| 443 | options.push_back("false"); |
| 444 | |
| 445 | options.push_back("ssl_certificate"); |
| 446 | options.push_back(FLAGS_webserver_certificate_file.c_str()); |
| 447 | |
| 448 | if (!FLAGS_webserver_private_key_file.empty()) { |
| 449 | options.push_back("ssl_private_key"); |
| 450 | options.push_back(FLAGS_webserver_private_key_file.c_str()); |
| 451 | |
| 452 | const string& password_cmd = FLAGS_webserver_private_key_password_cmd; |
| 453 | if (!password_cmd.empty()) { |
| 454 | if (!RunShellProcess(password_cmd, &key_password, true, {"JAVA_TOOL_OPTIONS"})) { |
| 455 | return Status(TErrorCode::SSL_PASSWORD_CMD_FAILED, password_cmd, key_password); |
| 456 | } |
| 457 | options.push_back("ssl_private_key_password"); |
| 458 | options.push_back(key_password.c_str()); |
| 459 | } |
| 460 | } |
| 461 | |
| 462 | options.push_back("ssl_min_version"); |
| 463 | options.push_back(FLAGS_ssl_minimum_version.c_str()); |
| 464 | if (!FLAGS_ssl_cipher_list.empty()) { |