]> granicus.if.org Git - icinga2/commitdiff
Fix some deadlocks in the TlsStream class.
authorGunnar Beutner <gunnar.beutner@netways.de>
Tue, 12 Mar 2013 10:56:14 +0000 (11:56 +0100)
committerGunnar Beutner <gunnar.beutner@netways.de>
Tue, 12 Mar 2013 10:56:14 +0000 (11:56 +0100)
lib/base/tlsstream.cpp
lib/remoting/endpointmanager.cpp

index f2de819380520cdd767a70fcba2d9ef47debcd93..eae8e5eaaf4a9aacd975472ca6e9e8a96212e9f4 100644 (file)
@@ -42,8 +42,6 @@ TlsStream::TlsStream(const Stream::Ptr& innerStream, TlsRole role, shared_ptr<SS
 
 void TlsStream::Start(void)
 {
-       ObjectLock olock(this);
-
        m_SSL = shared_ptr<SSL>(SSL_new(m_SSLContext.get()), SSL_free);
 
        m_SSLContext.reset();
@@ -54,7 +52,7 @@ void TlsStream::Start(void)
                    << errinfo_openssl_error(ERR_get_error()));
        }
 
-       if (!GetClientCertificate())
+       if (!m_SSL)
                BOOST_THROW_EXCEPTION(logic_error("No X509 client certificate was specified."));
 
        if (!m_SSLIndexInitialized) {
index fc09b10134c6771a9a04862a9ad6899d842117ee..001921a5cf75284da91c83d6ca8703d5f2c2dd95 100644 (file)
@@ -111,7 +111,7 @@ void EndpointManager::AddListener(const String& service)
 {
        ObjectLock olock(this);
 
-       shared_ptr<SSL_CTX> sslContext = GetSSLContext();
+       shared_ptr<SSL_CTX> sslContext = m_SSLContext;
 
        if (!sslContext)
                BOOST_THROW_EXCEPTION(logic_error("SSL context is required for AddListener()"));
@@ -140,7 +140,7 @@ void EndpointManager::AddListener(const String& service)
 void EndpointManager::AddConnection(const String& node, const String& service) {
        ObjectLock olock(this);
 
-       shared_ptr<SSL_CTX> sslContext = GetSSLContext();
+       shared_ptr<SSL_CTX> sslContext = m_SSLContext;
 
        if (!sslContext)
                BOOST_THROW_EXCEPTION(logic_error("SSL context is required for AddConnection()"));
@@ -160,7 +160,7 @@ void EndpointManager::NewClientHandler(const Socket::Ptr& client, TlsRole role)
        ObjectLock olock(this);
 
        String peerAddress = client->GetPeerAddress();
-       TlsStream::Ptr tlsStream = boost::make_shared<TlsStream>(client, role, GetSSLContext());
+       TlsStream::Ptr tlsStream = boost::make_shared<TlsStream>(client, role, m_SSLContext);
        tlsStream->Start();
 
        m_PendingClients.insert(tlsStream);