Skip to content

Commit

Permalink
Properly shut down client connection preventing TLS tuncation
Browse files Browse the repository at this point in the history
  • Loading branch information
loonycyborg committed Feb 23, 2021
1 parent f8b026f commit e392f36
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/wesnothd_connection.cpp
Expand Up @@ -115,6 +115,14 @@ wesnothd_connection::~wesnothd_connection()
{
MPTEST_LOG;

if(socket_.index() == 1) {
error_code ec;
// this sends close_notify for secure connection shutdown
utils::get<tls_socket>(socket_).async_shutdown([](const error_code&) {} );
const char buffer[] = "";
// this write is needed to trigger immediate close instead of waiting for other side's close_notify
boost::asio::write(utils::get<tls_socket>(socket_), boost::asio::buffer(buffer, 0), ec);
}
// Stop the io_service and wait for the worker thread to terminate.
stop();
worker_thread_.join();
Expand Down

0 comments on commit e392f36

Please sign in to comment.