Skip to content

Commit

Permalink
Don't use TLS for explicitly specified ip adresses
Browse files Browse the repository at this point in the history
  • Loading branch information
loonycyborg committed Mar 11, 2021
1 parent 68ee930 commit 2c08923
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/wesnothd_connection.cpp
Expand Up @@ -80,12 +80,16 @@ wesnothd_connection::wesnothd_connection(const std::string& host, const std::str
, bytes_read_(0)
{
MPTEST_LOG;
#if BOOST_VERSION >= 106600
resolver_.async_resolve(host, service,
#else
resolver_.async_resolve(boost::asio::ip::tcp::resolver::query(host, service),
#endif
std::bind(&wesnothd_connection::handle_resolve, this, std::placeholders::_1, std::placeholders::_2));

error_code ec;
auto result = resolver_.resolve(host, service, boost::asio::ip::resolver_query_base::numeric_host, ec);
if(!ec) { // if numeric resolve succeeds then we got raw ip address so TLS host name validation would never pass
use_tls_ = false;
boost::asio::post(io_context_, [this, ec, result](){ handle_resolve(ec, { result } ); } );
} else {
resolver_.async_resolve(host, service,
std::bind(&wesnothd_connection::handle_resolve, this, std::placeholders::_1, std::placeholders::_2));
}

// Starts the worker thread. Do this *after* the above async_resolve call or it will just exit immediately!
worker_thread_ = std::thread([this]() {
Expand Down

0 comments on commit 2c08923

Please sign in to comment.