ApiListener: Update the ssl cont after each accepting incoming connection

This commit is contained in:
Yonas Habteab 2021-01-14 18:40:20 +01:00
parent 057254695d
commit d27f533e5f
1 changed files with 22 additions and 2 deletions

View File

@ -432,11 +432,31 @@ void ApiListener::ListenerCoroutineProc(boost::asio::yield_context yc, const Sha
auto& io (IoEngine::Get().GetIoContext()); auto& io (IoEngine::Get().GetIoContext());
time_t lastModified = -1;
const String crlPath = GetCrlPath();
if (!crlPath.IsEmpty()) {
lastModified = Utility::GetFileCreationTime(crlPath);
}
for (;;) { for (;;) {
try { try {
auto sslConn (Shared<AsioTlsStream>::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<AsioTlsStream>::Make(io, *sslContext));
sslConn->lowest_layer() = std::move(socket);
auto strand (Shared<asio::io_context::strand>::Make(io)); auto strand (Shared<asio::io_context::strand>::Make(io));