refactor: secureSocket uniqueprt for Ssl object

based on: 89d8ce20b0
This commit is contained in:
sithlord48
2025-06-18 18:26:02 -04:00
committed by Nick Bolton
parent 90a651b409
commit 06a616ef42
2 changed files with 6 additions and 7 deletions

View File

@ -45,8 +45,8 @@ enum
struct Ssl
{
SSL_CTX *m_context;
SSL *m_ssl;
SSL_CTX *m_context = nullptr;
SSL *m_ssl = nullptr;
};
static int verifyIgnoreCertCallback(X509_STORE_CTX *, void *)
@ -289,9 +289,7 @@ void SecureSocket::initSsl(bool server)
{
std::scoped_lock ssl_lock{ssl_mutex_};
m_ssl = new Ssl();
m_ssl->m_context = nullptr;
m_ssl->m_ssl = nullptr;
m_ssl = std::make_unique<Ssl>();
initContext(server);
}
@ -407,7 +405,6 @@ void SecureSocket::freeSSL()
SSL_CTX_free(m_ssl->m_context);
m_ssl->m_context = nullptr;
}
delete m_ssl;
m_ssl = nullptr;
}
}

View File

@ -11,6 +11,8 @@
#include "net/SecurityLevel.h"
#include "net/TCPSocket.h"
#include "net/XSocket.h"
#include <memory>
#include <mutex>
class IEventQueue;
@ -91,7 +93,7 @@ private:
// by it.
std::mutex ssl_mutex_;
Ssl *m_ssl = nullptr;
std::unique_ptr<Ssl> m_ssl;
bool m_secureReady = false;
bool m_fatal = false;
SecurityLevel m_securityLevel = SecurityLevel::Encrypted;