From 6dacd1359d264ca68a3022a5b44991723c37d686 Mon Sep 17 00:00:00 2001 From: Alexandre Lision <alexandre.lision@savoirfairelinux.com> Date: Mon, 28 Sep 2015 17:13:52 -0400 Subject: [PATCH] tls: fix crash setting tls password we now check if certificate exists before trying to set the password on it. Issue: #80458 Change-Id: I059627e46329498639594c185cbc1fb3ee61eeb1 --- src/account.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/account.cpp b/src/account.cpp index 646e45b7..49d0d792 100644 --- a/src/account.cpp +++ b/src/account.cpp @@ -1435,7 +1435,10 @@ void Account::setPassword(const QString& detail) ///Set the TLS (encryption) password void Account::setTlsPassword(const QString& detail) { - tlsCertificate()->setPrivateKeyPassword(detail); + auto cert = tlsCertificate(); + if (!cert) + return; + cert->setPrivateKeyPassword(detail); d_ptr->setAccountProperty(DRing::Account::ConfProperties::TLS::PASSWORD, detail); d_ptr->regenSecurityValidation(); } @@ -2352,14 +2355,15 @@ void AccountPrivate::reload() if (!ca.isEmpty()) q_ptr->setTlsCaListCertificate(ca); - if (!cert.isEmpty()) + // Set the pvk file and password only if there is a certificate + if (!cert.isEmpty()) { q_ptr->setTlsCertificate(cert); - - if (!key.isEmpty()) - q_ptr->setTlsPrivateKey(key); - - if (!pass.isEmpty()) - q_ptr->setTlsPassword(pass); + if (!key.isEmpty()) { + q_ptr->setTlsPrivateKey(key); + if (!pass.isEmpty()) + q_ptr->setTlsPassword(pass); + } + } m_RemoteEnabledState = q_ptr->isEnabled(); } -- GitLab