Use the certificateChain() in the SSL error dialog

This includes the self-signed certificate anyway, and the previous
behavior led to funny side-effects.
This commit is contained in:
Daniel Molkentin 2013-03-20 15:53:55 +01:00
parent db95e7291d
commit c633302f31
3 changed files with 4 additions and 17 deletions

View file

@ -65,9 +65,7 @@ void ownCloudInfo::setNetworkAccessManager( QNetworkAccessManager* qnam )
_manager = qnam; _manager = qnam;
MirallConfigFile cfg( _configHandle ); MirallConfigFile cfg( _configHandle );
QSettings settings( cfg.configFile(), QSettings::IniFormat); QSslSocket::addDefaultCaCertificates(QSslCertificate::fromData(cfg.caCerts()));
QByteArray certs = settings.value(QLatin1String("CaCertificates")).toByteArray();
QSslSocket::addDefaultCaCertificates(QSslCertificate::fromData(certs));
connect( _manager, SIGNAL( sslErrors(QNetworkReply*, QList<QSslError>)), connect( _manager, SIGNAL( sslErrors(QNetworkReply*, QList<QSslError>)),
this, SIGNAL(sslFailed(QNetworkReply*, QList<QSslError>)) ); this, SIGNAL(sslFailed(QNetworkReply*, QList<QSslError>)) );

View file

@ -14,14 +14,13 @@
#include "mirall/mirallconfigfile.h" #include "mirall/mirallconfigfile.h"
#include "mirall/utility.h" #include "mirall/utility.h"
#include "mirall/sslerrordialog.h" #include "mirall/sslerrordialog.h"
#include "mirall/owncloudinfo.h"
#include <QtGui> #include <QtGui>
#include <QtNetwork> #include <QtNetwork>
namespace Mirall namespace Mirall
{ {
#define CA_CERTS_KEY QLatin1String("CaCertificates")
SslErrorDialog::SslErrorDialog(QWidget *parent) : SslErrorDialog::SslErrorDialog(QWidget *parent) :
QDialog(parent), _allTrusted(false) QDialog(parent), _allTrusted(false)
{ {
@ -42,14 +41,6 @@ SslErrorDialog::SslErrorDialog(QWidget *parent) :
} }
} }
QList<QSslCertificate> SslErrorDialog::storedCACerts()
{
MirallConfigFile cfg( _customConfigHandle );
QList<QSslCertificate> cacerts = QSslCertificate::fromData(cfg.caCerts());
return cacerts;
}
QString SslErrorDialog::styleSheet() const QString SslErrorDialog::styleSheet() const
{ {
@ -68,12 +59,13 @@ QString SslErrorDialog::styleSheet() const
bool SslErrorDialog::setErrorList( QList<QSslError> errors ) bool SslErrorDialog::setErrorList( QList<QSslError> errors )
{ {
QList<QSslCertificate> ourCerts = storedCACerts(); QList<QSslCertificate> ourCerts = ownCloudInfo::instance()->certificateChain();
// check if unknown certs caused errors. // check if unknown certs caused errors.
_unknownCerts.clear(); _unknownCerts.clear();
QStringList errorStrings; QStringList errorStrings;
for (int i = 0; i < errors.count(); ++i) { for (int i = 0; i < errors.count(); ++i) {
if (ourCerts.contains(errors.at(i).certificate()) || if (ourCerts.contains(errors.at(i).certificate()) ||
_unknownCerts.contains(errors.at(i).certificate() )) _unknownCerts.contains(errors.at(i).certificate() ))
@ -191,9 +183,7 @@ void SslErrorDialog::accept()
QSslSocket::addDefaultCaCertificates(_unknownCerts); QSslSocket::addDefaultCaCertificates(_unknownCerts);
MirallConfigFile cfg( _customConfigHandle ); MirallConfigFile cfg( _customConfigHandle );
QByteArray certs = cfg.caCerts(); QByteArray certs = cfg.caCerts();
qDebug() << "Saving " << _unknownCerts.count() << " unknown certs."; qDebug() << "Saving " << _unknownCerts.count() << " unknown certs.";
foreach( const QSslCertificate& cert, _unknownCerts ) { foreach( const QSslCertificate& cert, _unknownCerts ) {
certs += cert.toPem() + '\n'; certs += cert.toPem() + '\n';

View file

@ -45,7 +45,6 @@ public slots:
void accept(); void accept();
private: private:
QList<QSslCertificate> storedCACerts();
QString styleSheet() const; QString styleSheet() const;
bool _allTrusted; bool _allTrusted;