From e392f3636a3a875b4f581fc2e9b9060e9646e11d Mon Sep 17 00:00:00 2001 From: loonycyborg Date: Wed, 10 Feb 2021 20:17:10 +0300 Subject: [PATCH] Properly shut down client connection preventing TLS tuncation --- src/wesnothd_connection.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/wesnothd_connection.cpp b/src/wesnothd_connection.cpp index 4d6f5559abfa..0814e1f60633 100644 --- a/src/wesnothd_connection.cpp +++ b/src/wesnothd_connection.cpp @@ -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(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(socket_), boost::asio::buffer(buffer, 0), ec); + } // Stop the io_service and wait for the worker thread to terminate. stop(); worker_thread_.join();