Skip to content

Commit d27f533

Browse files
committed
ApiListener: Update the ssl cont after each accepting incoming connection
1 parent 0572546 commit d27f533

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

lib/remote/apilistener.cpp

+22-2
Original file line numberDiff line numberDiff line change
@@ -432,11 +432,31 @@ void ApiListener::ListenerCoroutineProc(boost::asio::yield_context yc, const Sha
432432

433433
auto& io (IoEngine::Get().GetIoContext());
434434

435+
time_t lastModified = -1;
436+
const String crlPath = GetCrlPath();
437+
438+
if (!crlPath.IsEmpty()) {
439+
lastModified = Utility::GetFileCreationTime(crlPath);
440+
}
441+
435442
for (;;) {
436443
try {
437-
auto sslConn (Shared<AsioTlsStream>::Make(io, *sslContext));
444+
asio::ip::tcp::socket socket (io);
445+
446+
server->async_accept(socket.lowest_layer(), yc);
447+
448+
if (!crlPath.IsEmpty()) {
449+
time_t currentCreationTime = Utility::GetFileCreationTime(crlPath);
438450

439-
server->async_accept(sslConn->lowest_layer(), yc);
451+
if (lastModified != currentCreationTime) {
452+
UpdateSSLContext();
453+
454+
lastModified = currentCreationTime;
455+
}
456+
}
457+
458+
auto sslConn (Shared<AsioTlsStream>::Make(io, *sslContext));
459+
sslConn->lowest_layer() = std::move(socket);
440460

441461
auto strand (Shared<asio::io_context::strand>::Make(io));
442462

0 commit comments

Comments
 (0)