From c633302f31fc050b52328583467b8379586a2823 Mon Sep 17 00:00:00 2001 From: Daniel Molkentin Date: Wed, 20 Mar 2013 15:53:55 +0100 Subject: [PATCH] Use the certificateChain() in the SSL error dialog This includes the self-signed certificate anyway, and the previous behavior led to funny side-effects. --- src/mirall/owncloudinfo.cpp | 4 +--- src/mirall/sslerrordialog.cpp | 16 +++------------- src/mirall/sslerrordialog.h | 1 - 3 files changed, 4 insertions(+), 17 deletions(-) diff --git a/src/mirall/owncloudinfo.cpp b/src/mirall/owncloudinfo.cpp index afea09fe5..5bdae810e 100644 --- a/src/mirall/owncloudinfo.cpp +++ b/src/mirall/owncloudinfo.cpp @@ -65,9 +65,7 @@ void ownCloudInfo::setNetworkAccessManager( QNetworkAccessManager* qnam ) _manager = qnam; MirallConfigFile cfg( _configHandle ); - QSettings settings( cfg.configFile(), QSettings::IniFormat); - QByteArray certs = settings.value(QLatin1String("CaCertificates")).toByteArray(); - QSslSocket::addDefaultCaCertificates(QSslCertificate::fromData(certs)); + QSslSocket::addDefaultCaCertificates(QSslCertificate::fromData(cfg.caCerts())); connect( _manager, SIGNAL( sslErrors(QNetworkReply*, QList)), this, SIGNAL(sslFailed(QNetworkReply*, QList)) ); diff --git a/src/mirall/sslerrordialog.cpp b/src/mirall/sslerrordialog.cpp index 589e29aea..ec6fb3a21 100644 --- a/src/mirall/sslerrordialog.cpp +++ b/src/mirall/sslerrordialog.cpp @@ -14,14 +14,13 @@ #include "mirall/mirallconfigfile.h" #include "mirall/utility.h" #include "mirall/sslerrordialog.h" +#include "mirall/owncloudinfo.h" #include #include namespace Mirall { -#define CA_CERTS_KEY QLatin1String("CaCertificates") - SslErrorDialog::SslErrorDialog(QWidget *parent) : QDialog(parent), _allTrusted(false) { @@ -42,14 +41,6 @@ SslErrorDialog::SslErrorDialog(QWidget *parent) : } } -QList SslErrorDialog::storedCACerts() -{ - MirallConfigFile cfg( _customConfigHandle ); - - QList cacerts = QSslCertificate::fromData(cfg.caCerts()); - - return cacerts; -} QString SslErrorDialog::styleSheet() const { @@ -68,12 +59,13 @@ QString SslErrorDialog::styleSheet() const bool SslErrorDialog::setErrorList( QList errors ) { - QList ourCerts = storedCACerts(); + QList ourCerts = ownCloudInfo::instance()->certificateChain(); // check if unknown certs caused errors. _unknownCerts.clear(); QStringList errorStrings; + for (int i = 0; i < errors.count(); ++i) { if (ourCerts.contains(errors.at(i).certificate()) || _unknownCerts.contains(errors.at(i).certificate() )) @@ -191,9 +183,7 @@ void SslErrorDialog::accept() QSslSocket::addDefaultCaCertificates(_unknownCerts); MirallConfigFile cfg( _customConfigHandle ); - QByteArray certs = cfg.caCerts(); - qDebug() << "Saving " << _unknownCerts.count() << " unknown certs."; foreach( const QSslCertificate& cert, _unknownCerts ) { certs += cert.toPem() + '\n'; diff --git a/src/mirall/sslerrordialog.h b/src/mirall/sslerrordialog.h index 640babb09..28463c010 100644 --- a/src/mirall/sslerrordialog.h +++ b/src/mirall/sslerrordialog.h @@ -45,7 +45,6 @@ public slots: void accept(); private: - QList storedCACerts(); QString styleSheet() const; bool _allTrusted;