/***************************************************************************
- * Copyright (C) 2005-08 by the Quassel Project *
+ * Copyright (C) 2005-2020 by the Quassel Project *
* devel@quassel-irc.org *
* *
* This program is free software; you can redistribute it and/or modify *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#include "clientidentity.h"
#include "client.h"
#include "signalproxy.h"
-CertIdentity::CertIdentity(IdentityId id, QObject *parent)
- : Identity(id, parent)
-#ifdef HAVE_SSL
- , _certManager(0),
- _isDirty(false)
-#endif
-{
-}
-
-CertIdentity::CertIdentity(const Identity &other, QObject *parent)
- : Identity(other, parent)
-#ifdef HAVE_SSL
- , _certManager(0),
- _isDirty(false)
-#endif
-{
-}
+CertIdentity::CertIdentity(IdentityId id, QObject* parent)
+ : Identity(id, parent)
+{}
-CertIdentity::CertIdentity(const CertIdentity &other, QObject *parent)
- : Identity(other, parent)
-#ifdef HAVE_SSL
- , _certManager(0),
- _isDirty(other._isDirty),
- _sslKey(other._sslKey),
- _sslCert(other._sslCert)
-#endif
-{
-}
+CertIdentity::CertIdentity(const Identity& other, QObject* parent)
+ : Identity(other, parent)
+{}
-#ifdef HAVE_SSL
-void CertIdentity::enableEditSsl(bool enable) {
- if(!enable || _certManager)
- return;
+CertIdentity::CertIdentity(const CertIdentity& other, QObject* parent)
+ : Identity(other, parent)
+ , _isDirty(other._isDirty)
+ , _sslKey(other._sslKey)
+ , _sslCert(other._sslCert)
+{}
- _certManager = new ClientCertManager(id(), this);
- if(isValid()) { // this means we are not a newly created Identity but have a proper Id
- Client::signalProxy()->synchronize(_certManager);
- connect(_certManager, SIGNAL(updated(const QVariantMap &)), this, SLOT(markClean()));
- connect(_certManager, SIGNAL(initDone()), this, SLOT(markClean()));
- }
+void CertIdentity::enableEditSsl(bool enable)
+{
+ if (!enable || _certManager)
+ return;
+
+ _certManager = new ClientCertManager(id(), this);
+ if (isValid()) { // this means we are not a newly created Identity but have a proper Id
+ Client::signalProxy()->synchronize(_certManager);
+ connect(_certManager, &SyncableObject::updated, this, &CertIdentity::markClean);
+ connect(_certManager, &SyncableObject::initDone, this, &CertIdentity::markClean);
+ }
}
-void CertIdentity::setSslKey(const QSslKey &key) {
- if(key.toPem() == _sslKey.toPem())
- return;
- _sslKey = key;
- _isDirty = true;
+void CertIdentity::setSslKey(const QSslKey& key)
+{
+ if (key.toPem() == _sslKey.toPem())
+ return;
+ _sslKey = key;
+ _isDirty = true;
}
-void CertIdentity::setSslCert(const QSslCertificate &cert) {
- if(cert.toPem() == _sslCert.toPem())
- return;
- _sslCert = cert;
- _isDirty = true;
+void CertIdentity::setSslCert(const QSslCertificate& cert)
+{
+ if (cert.toPem() == _sslCert.toPem())
+ return;
+ _sslCert = cert;
+ _isDirty = true;
}
-void CertIdentity::requestUpdateSslSettings() {
- if(!_certManager)
- return;
+void CertIdentity::requestUpdateSslSettings()
+{
+ if (!_certManager)
+ return;
- _certManager->requestUpdate(_certManager->toVariantMap());
+ _certManager->requestUpdate(_certManager->toVariantMap());
}
-void CertIdentity::markClean() {
- _isDirty = false;
- emit sslSettingsUpdated();
+void CertIdentity::markClean()
+{
+ _isDirty = false;
+ emit sslSettingsUpdated();
}
// ========================================
// ClientCertManager
// ========================================
-void ClientCertManager::setSslKey(const QByteArray &encoded) {
- QSslKey key(encoded, QSsl::Rsa);
- if(key.isNull())
- key = QSslKey(encoded, QSsl::Dsa);
- _certIdentity->setSslKey(key);
+void ClientCertManager::setSslKey(const QByteArray& encoded)
+{
+ QSslKey key(encoded, QSsl::Rsa);
+ if (key.isNull() && Client::isCoreFeatureEnabled(Quassel::Feature::EcdsaCertfpKeys))
+ key = QSslKey(encoded, QSsl::Ec);
+ if (key.isNull())
+ key = QSslKey(encoded, QSsl::Dsa);
+ _certIdentity->setSslKey(key);
}
-void ClientCertManager::setSslCert(const QByteArray &encoded) {
- _certIdentity->setSslCert(QSslCertificate(encoded));
+void ClientCertManager::setSslCert(const QByteArray& encoded)
+{
+ _certIdentity->setSslCert(QSslCertificate(encoded));
}
-
-
-#endif // HAVE_SSL