From d27f533e5fc2aad6b7c485579a826f516601950f Mon Sep 17 00:00:00 2001 From: Yonas Habteab Date: Thu, 14 Jan 2021 18:40:20 +0100 Subject: [PATCH] ApiListener: Update the ssl cont after each accepting incoming connection --- lib/remote/apilistener.cpp | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/lib/remote/apilistener.cpp b/lib/remote/apilistener.cpp index 02a5eef03..3a302544b 100644 --- a/lib/remote/apilistener.cpp +++ b/lib/remote/apilistener.cpp @@ -432,11 +432,31 @@ void ApiListener::ListenerCoroutineProc(boost::asio::yield_context yc, const Sha auto& io (IoEngine::Get().GetIoContext()); + time_t lastModified = -1; + const String crlPath = GetCrlPath(); + + if (!crlPath.IsEmpty()) { + lastModified = Utility::GetFileCreationTime(crlPath); + } + for (;;) { try { - auto sslConn (Shared::Make(io, *sslContext)); + asio::ip::tcp::socket socket (io); - server->async_accept(sslConn->lowest_layer(), yc); + server->async_accept(socket.lowest_layer(), yc); + + if (!crlPath.IsEmpty()) { + time_t currentCreationTime = Utility::GetFileCreationTime(crlPath); + + if (lastModified != currentCreationTime) { + UpdateSSLContext(); + + lastModified = currentCreationTime; + } + } + + auto sslConn (Shared::Make(io, *sslContext)); + sslConn->lowest_layer() = std::move(socket); auto strand (Shared::Make(io));