mirror of https://github.com/Icinga/icinga2.git
Fix TLS context copies in ApiListener
This avoids copying the TLS context in the ApiListener class and removes the obsolete variable. This is a follow-up from #7654
This commit is contained in:
parent
ce4409d1d2
commit
859658ab98
|
@ -356,9 +356,7 @@ bool ApiListener::AddListener(const String& node, const String& service)
|
||||||
|
|
||||||
ObjectLock olock(this);
|
ObjectLock olock(this);
|
||||||
|
|
||||||
auto sslContext (m_SSLContext);
|
if (!m_SSLContext) {
|
||||||
|
|
||||||
if (!sslContext) {
|
|
||||||
Log(LogCritical, "ApiListener", "SSL context is required for AddListener()");
|
Log(LogCritical, "ApiListener", "SSL context is required for AddListener()");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -453,16 +451,14 @@ void ApiListener::AddConnection(const Endpoint::Ptr& endpoint)
|
||||||
namespace asio = boost::asio;
|
namespace asio = boost::asio;
|
||||||
using asio::ip::tcp;
|
using asio::ip::tcp;
|
||||||
|
|
||||||
auto sslContext (m_SSLContext);
|
if (!m_SSLContext) {
|
||||||
|
|
||||||
if (!sslContext) {
|
|
||||||
Log(LogCritical, "ApiListener", "SSL context is required for AddConnection()");
|
Log(LogCritical, "ApiListener", "SSL context is required for AddConnection()");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto& io (IoEngine::Get().GetIoContext());
|
auto& io (IoEngine::Get().GetIoContext());
|
||||||
|
|
||||||
IoEngine::SpawnCoroutine(io, [this, endpoint, &io, sslContext](asio::yield_context yc) {
|
IoEngine::SpawnCoroutine(io, [this, endpoint, &io](asio::yield_context yc) {
|
||||||
String host = endpoint->GetHost();
|
String host = endpoint->GetHost();
|
||||||
String port = endpoint->GetPort();
|
String port = endpoint->GetPort();
|
||||||
|
|
||||||
|
@ -470,7 +466,7 @@ void ApiListener::AddConnection(const Endpoint::Ptr& endpoint)
|
||||||
<< "Reconnecting to endpoint '" << endpoint->GetName() << "' via host '" << host << "' and port '" << port << "'";
|
<< "Reconnecting to endpoint '" << endpoint->GetName() << "' via host '" << host << "' and port '" << port << "'";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
auto sslConn (Shared<AsioTlsStream>::Make(io, *sslContext, endpoint->GetName()));
|
auto sslConn (Shared<AsioTlsStream>::Make(io, *m_SSLContext, endpoint->GetName()));
|
||||||
|
|
||||||
Connect(sslConn->lowest_layer(), host, port, yc);
|
Connect(sslConn->lowest_layer(), host, port, yc);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue