Adjust SSL context generation for Server:

The creation of self-signed certificates slows down the command
line client when launched repeatedly during unit test.
* Contexts are no longer generated for the command line client
* A port with no secure protocols generates an empty context
This commit is contained in:
Vinnie Falco
2014-11-07 04:43:54 -08:00
parent 9a7f66cfe9
commit 788219fe05
4 changed files with 44 additions and 9 deletions

View File

@@ -427,6 +427,29 @@ adminRole (HTTP::Port const& port,
//------------------------------------------------------------------------------
void
ServerHandler::Setup::makeContexts()
{
for(auto& p : ports)
{
if (p.secure())
{
if (p.ssl_key.empty() && p.ssl_cert.empty() &&
p.ssl_chain.empty())
p.context = make_SSLContext();
else
p.context = make_SSLContextAuthed (
p.ssl_key, p.ssl_cert, p.ssl_chain);
}
else
{
p.context = std::make_shared<
boost::asio::ssl::context>(
boost::asio::ssl::context::sslv23);
}
}
}
namespace detail {
// Parse a comma-delimited list of values.
@@ -616,13 +639,6 @@ to_Port(ParsedPort const& parsed, std::ostream& log)
p.ssl_cert = parsed.ssl_cert;
p.ssl_chain = parsed.ssl_chain;
if (p.ssl_key.empty() && p.ssl_cert.empty() &&
p.ssl_chain.empty())
p.context = make_SSLContext();
else
p.context = make_SSLContextAuthed (
p.ssl_key, p.ssl_cert, p.ssl_chain);
return p;
}