Commit 9f44fe66 authored by Micha Mueller's avatar Micha Mueller
Browse files

RestServer: Log error before crashing if invalid file path for certificates is given

parent b9de46ae
......@@ -61,10 +61,15 @@ RESTHttpsServer::RESTHttpsServer(serverSettings_t settings) :
});
*/
//TODO make more robust if certificate not found
_ctx->use_certificate_chain_file(settings.certificate);
_ctx->use_private_key_file(settings.privateKey, ssl::context::pem);
_ctx->use_tmp_dh_file(settings.dhFile);
try {
_ctx->use_certificate_chain_file(settings.certificate);
_ctx->use_private_key_file(settings.privateKey, ssl::context::pem);
_ctx->use_tmp_dh_file(settings.dhFile);
} catch (const std::exception& e) {
ServerLOG(fatal) << "Could not load certificate OR private key OR DH settings file! "
"Please ensure the paths in the config file are valid!";
throw;
}
// This will receive the new connection
_socket = std::unique_ptr<tcp::socket>(new tcp::socket(*_io));
......@@ -76,7 +81,7 @@ RESTHttpsServer::RESTHttpsServer(serverSettings_t settings) :
_acceptor = std::unique_ptr<tcp::acceptor>(new tcp::acceptor(*_io, {address, port}));
_acceptor->set_option(tcp::acceptor::reuse_address(true));
} catch (const std::exception& e) {
LOG(fatal) << "RestAPI address invalid! Please make sure IP address and port are valid!";
ServerLOG(fatal) << "RestAPI address invalid! Please make sure IP address and port are valid!";
throw;
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment