mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 03:44:02 +02:00
perform cleanup of GnuTLS structures across targets
This commit is contained in:
parent
85933545cd
commit
fd8e32190e
7 changed files with 35 additions and 15 deletions
|
@ -109,6 +109,10 @@ AssignmentClient::AssignmentClient(int &argc, char **argv) :
|
|||
this, &AssignmentClient::handleAuthenticationRequest);
|
||||
}
|
||||
|
||||
AssignmentClient::~AssignmentClient() {
|
||||
gnutls_global_deinit();
|
||||
}
|
||||
|
||||
void AssignmentClient::sendAssignmentRequest() {
|
||||
if (!_currentAssignment) {
|
||||
NodeList::getInstance()->sendAssignment(_requestAssignment);
|
||||
|
|
|
@ -17,6 +17,7 @@ class AssignmentClient : public QCoreApplication {
|
|||
Q_OBJECT
|
||||
public:
|
||||
AssignmentClient(int &argc, char **argv);
|
||||
~AssignmentClient();
|
||||
private slots:
|
||||
void sendAssignmentRequest();
|
||||
void readPendingDatagrams();
|
||||
|
|
|
@ -78,6 +78,20 @@ DomainServer::DomainServer(int argc, char* argv[]) :
|
|||
}
|
||||
}
|
||||
|
||||
DomainServer::~DomainServer() {
|
||||
if (_x509Credentials) {
|
||||
gnutls_certificate_free_credentials(*_x509Credentials);
|
||||
gnutls_priority_deinit(*_priorityCache);
|
||||
gnutls_dh_params_deinit(*_dhParams);
|
||||
|
||||
delete _x509Credentials;
|
||||
delete _priorityCache;
|
||||
delete _dhParams;
|
||||
delete _cookieKey;
|
||||
}
|
||||
gnutls_global_deinit();
|
||||
}
|
||||
|
||||
bool DomainServer::optionallySetupDTLS() {
|
||||
if (readX509KeyAndCertificate()) {
|
||||
if (_x509Credentials) {
|
||||
|
|
|
@ -31,6 +31,7 @@ class DomainServer : public QCoreApplication, public HTTPRequestHandler {
|
|||
Q_OBJECT
|
||||
public:
|
||||
DomainServer(int argc, char* argv[]);
|
||||
~DomainServer();
|
||||
|
||||
bool handleHTTPRequest(HTTPConnection* connection, const QUrl& url);
|
||||
|
||||
|
|
|
@ -393,6 +393,8 @@ Application::~Application() {
|
|||
delete _glWidget;
|
||||
|
||||
AccountManager::getInstance().destroy();
|
||||
|
||||
gnutls_global_deinit();
|
||||
}
|
||||
|
||||
void Application::restoreSizeAndPosition() {
|
||||
|
|
|
@ -8,20 +8,17 @@
|
|||
|
||||
#include "DTLSClientSession.h"
|
||||
|
||||
gnutls_certificate_credentials_t* DTLSClientSession::x509CACredentials() {
|
||||
static gnutls_certificate_credentials_t x509Credentials;
|
||||
static bool credentialsInitialized = false;
|
||||
|
||||
if (!credentialsInitialized) {
|
||||
gnutls_certificate_allocate_credentials(&x509Credentials);
|
||||
}
|
||||
|
||||
return &x509Credentials;
|
||||
}
|
||||
|
||||
DTLSClientSession::DTLSClientSession(QUdpSocket& dtlsSocket, HifiSockAddr& destinationSocket) :
|
||||
DTLSSession(GNUTLS_CLIENT, dtlsSocket, destinationSocket)
|
||||
{
|
||||
// _x509 as a member variable and not global/static assumes a single DTLSClientSession per client
|
||||
gnutls_certificate_allocate_credentials(&_x509Credentials);
|
||||
|
||||
gnutls_priority_set_direct(_gnutlsSession, "PERFORMANCE", NULL);
|
||||
gnutls_credentials_set(_gnutlsSession, GNUTLS_CRD_CERTIFICATE, *x509CACredentials());
|
||||
}
|
||||
gnutls_credentials_set(_gnutlsSession, GNUTLS_CRD_CERTIFICATE, _x509Credentials);
|
||||
}
|
||||
|
||||
DTLSClientSession::~DTLSClientSession() {
|
||||
gnutls_certificate_free_credentials(_x509Credentials);
|
||||
}
|
||||
|
||||
|
|
|
@ -14,8 +14,9 @@
|
|||
class DTLSClientSession : public DTLSSession {
|
||||
public:
|
||||
DTLSClientSession(QUdpSocket& dtlsSocket, HifiSockAddr& destinationSocket);
|
||||
|
||||
static gnutls_certificate_credentials_t* x509CACredentials();
|
||||
~DTLSClientSession();
|
||||
private:
|
||||
gnutls_certificate_credentials_t _x509Credentials;
|
||||
};
|
||||
|
||||
#endif /* defined(__hifi__DTLSClientSession__) */
|
||||
|
|
Loading…
Reference in a new issue