mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 04:43:31 +02:00
proper cleanup of CA credentials on DTLSClientSession side
This commit is contained in:
parent
efcf506383
commit
69504b0a9d
4 changed files with 22 additions and 12 deletions
|
@ -33,7 +33,7 @@ AssignmentClient::AssignmentClient(int &argc, char **argv) :
|
||||||
QCoreApplication(argc, argv),
|
QCoreApplication(argc, argv),
|
||||||
_currentAssignment()
|
_currentAssignment()
|
||||||
{
|
{
|
||||||
gnutls_global_init();
|
DTLSClientSession::globalInit();
|
||||||
|
|
||||||
setOrganizationName("High Fidelity");
|
setOrganizationName("High Fidelity");
|
||||||
setOrganizationDomain("highfidelity.io");
|
setOrganizationDomain("highfidelity.io");
|
||||||
|
@ -110,7 +110,7 @@ AssignmentClient::AssignmentClient(int &argc, char **argv) :
|
||||||
}
|
}
|
||||||
|
|
||||||
AssignmentClient::~AssignmentClient() {
|
AssignmentClient::~AssignmentClient() {
|
||||||
gnutls_global_deinit();
|
DTLSClientSession::globalDeinit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssignmentClient::sendAssignmentRequest() {
|
void AssignmentClient::sendAssignmentRequest() {
|
||||||
|
|
|
@ -167,7 +167,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
|
||||||
_logger(new FileLogger(this))
|
_logger(new FileLogger(this))
|
||||||
{
|
{
|
||||||
// init GnuTLS for DTLS with domain-servers
|
// init GnuTLS for DTLS with domain-servers
|
||||||
gnutls_global_init();
|
DTLSClientSession::globalInit();
|
||||||
|
|
||||||
// read the ApplicationInfo.ini file for Name/Version/Domain information
|
// read the ApplicationInfo.ini file for Name/Version/Domain information
|
||||||
QSettings applicationInfo(Application::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat);
|
QSettings applicationInfo(Application::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat);
|
||||||
|
@ -396,7 +396,7 @@ Application::~Application() {
|
||||||
|
|
||||||
AccountManager::getInstance().destroy();
|
AccountManager::getInstance().destroy();
|
||||||
|
|
||||||
gnutls_global_deinit();
|
DTLSClientSession::globalDeinit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::restoreSizeAndPosition() {
|
void Application::restoreSizeAndPosition() {
|
||||||
|
|
|
@ -8,20 +8,26 @@
|
||||||
|
|
||||||
#include "DTLSClientSession.h"
|
#include "DTLSClientSession.h"
|
||||||
|
|
||||||
gnutls_certificate_credentials_t* DTLSClientSession::x509CACredentials() {
|
gnutls_certificate_credentials_t DTLSClientSession::_x509CACredentials;
|
||||||
static gnutls_certificate_credentials_t x509Credentials;
|
|
||||||
static bool credentialsInitialized = false;
|
void DTLSClientSession::globalInit() {
|
||||||
|
static bool initialized = false;
|
||||||
|
|
||||||
if (!credentialsInitialized) {
|
if (!initialized) {
|
||||||
gnutls_certificate_allocate_credentials(&x509Credentials);
|
gnutls_global_init();
|
||||||
|
gnutls_certificate_allocate_credentials(&_x509CACredentials);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DTLSClientSession::globalDeinit() {
|
||||||
|
gnutls_certificate_free_credentials(_x509CACredentials);
|
||||||
|
|
||||||
return &x509Credentials;
|
gnutls_global_deinit();
|
||||||
}
|
}
|
||||||
|
|
||||||
DTLSClientSession::DTLSClientSession(QUdpSocket& dtlsSocket, HifiSockAddr& destinationSocket) :
|
DTLSClientSession::DTLSClientSession(QUdpSocket& dtlsSocket, HifiSockAddr& destinationSocket) :
|
||||||
DTLSSession(GNUTLS_CLIENT, dtlsSocket, destinationSocket)
|
DTLSSession(GNUTLS_CLIENT, dtlsSocket, destinationSocket)
|
||||||
{
|
{
|
||||||
gnutls_priority_set_direct(_gnutlsSession, "PERFORMANCE", NULL);
|
gnutls_priority_set_direct(_gnutlsSession, "PERFORMANCE", NULL);
|
||||||
gnutls_credentials_set(_gnutlsSession, GNUTLS_CRD_CERTIFICATE, *x509CACredentials());
|
gnutls_credentials_set(_gnutlsSession, GNUTLS_CRD_CERTIFICATE, _x509CACredentials);
|
||||||
}
|
}
|
|
@ -15,7 +15,11 @@ class DTLSClientSession : public DTLSSession {
|
||||||
public:
|
public:
|
||||||
DTLSClientSession(QUdpSocket& dtlsSocket, HifiSockAddr& destinationSocket);
|
DTLSClientSession(QUdpSocket& dtlsSocket, HifiSockAddr& destinationSocket);
|
||||||
|
|
||||||
static gnutls_certificate_credentials_t* x509CACredentials();
|
static void globalInit();
|
||||||
|
static void globalDeinit();
|
||||||
|
|
||||||
|
static gnutls_certificate_credentials_t _x509CACredentials;
|
||||||
|
static bool _wasGloballyInitialized;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* defined(__hifi__DTLSClientSession__) */
|
#endif /* defined(__hifi__DTLSClientSession__) */
|
||||||
|
|
Loading…
Reference in a new issue