diff --git a/src/gui/sslbutton.cpp b/src/gui/sslbutton.cpp index 640b5dc215..9c5bad0b1a 100644 --- a/src/gui/sslbutton.cpp +++ b/src/gui/sslbutton.cpp @@ -188,7 +188,7 @@ void SslButton::updateAccountState(AccountState *accountState) if (account->url().scheme() == QLatin1String("https")) { QPixmap pm(Theme::hidpiFileName(":/client/resources/lock-https.png")); setIcon(QIcon(pm)); - QSslCipher cipher = account->sslConfiguration().sessionCipher(); + QSslCipher cipher = account->_sessionCipher; setToolTip(tr("This connection is encrypted using %1 bit %2.\n").arg(cipher.usedBits()).arg(cipher.name())); setMenu(_menu); } else { @@ -208,19 +208,19 @@ void SslButton::slotUpdateMenu() { AccountPtr account = _accountState->account(); if (account->url().scheme() == QLatin1String("https")) { - QString sslVersion = account->sslConfiguration().sessionCipher().protocolString() - + ", " + account->sslConfiguration().sessionCipher().authenticationMethod() - + ", " + account->sslConfiguration().sessionCipher().keyExchangeMethod() - + ", " + account->sslConfiguration().sessionCipher().encryptionMethod(); + QString sslVersion = account->_sessionCipher.protocolString() + + ", " + account->_sessionCipher.authenticationMethod() + + ", " + account->_sessionCipher.keyExchangeMethod() + + ", " + account->_sessionCipher.encryptionMethod(); _menu->addAction(sslVersion)->setEnabled(false); #if QT_VERSION > QT_VERSION_CHECK(5, 2, 0) - if (account->sslConfiguration().sessionTicket().isEmpty()) { + if (account->_sessionTicket.isEmpty()) { _menu->addAction(tr("No support for SSL session tickets/identifiers"))->setEnabled(false); } #endif - QList chain = account->sslConfiguration().peerCertificateChain(); + QList chain = account->_peerCertificateChain; if (chain.isEmpty()) { qWarning() << "empty certificate chain"; diff --git a/src/libsync/account.h b/src/libsync/account.h index 60e096d813..c64ea3f572 100644 --- a/src/libsync/account.h +++ b/src/libsync/account.h @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include "utility.h" @@ -111,6 +112,12 @@ public: QSslConfiguration getOrCreateSslConfig(); QSslConfiguration sslConfiguration() const { return _sslConfiguration; } void setSslConfiguration(const QSslConfiguration &config); + // Because of bugs in Qt, we use this to store info needed for the SSL Button + QSslCipher _sessionCipher; + QByteArray _sessionTicket; + QList _peerCertificateChain; + + /** The certificates of the account */ QList approvedCerts() const { return _approvedCerts; } void setApprovedCerts(const QList certs); diff --git a/src/libsync/networkjobs.cpp b/src/libsync/networkjobs.cpp index ea516c4d4d..c0c684e31b 100644 --- a/src/libsync/networkjobs.cpp +++ b/src/libsync/networkjobs.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -362,6 +363,7 @@ void CheckServerJob::start() setReply(getRequest(path())); setupConnections(reply()); connect(reply(), SIGNAL(metaDataChanged()), this, SLOT(metaDataChangedSlot())); + connect(reply(), SIGNAL(encrypted()), this, SLOT(encryptedSlot())); AbstractNetworkJob::start(); } @@ -391,10 +393,28 @@ bool CheckServerJob::installed(const QVariantMap &info) return info.value(QLatin1String("installed")).toBool(); } +static void mergeSslConfigurationForSslButton(const QSslConfiguration &config, AccountPtr account) +{ + if (config.peerCertificateChain().length() > 0) { + account->_peerCertificateChain = config.peerCertificateChain(); + } + if (!config.sessionCipher().isNull()) { + account->_sessionCipher = config.sessionCipher(); + } + if (config.sessionTicket().length() > 0) { + account->_sessionTicket = config.sessionTicket(); + } +} + +void CheckServerJob::encryptedSlot() +{ + mergeSslConfigurationForSslButton(reply()->sslConfiguration(), account()); +} + void CheckServerJob::metaDataChangedSlot() { - // We used to have this in finished(), but because of a bug in Qt this did not always have the cipher etc. account()->setSslConfiguration(reply()->sslConfiguration()); + mergeSslConfigurationForSslButton(reply()->sslConfiguration(), account()); } @@ -408,6 +428,8 @@ bool CheckServerJob::finished() } #endif + mergeSslConfigurationForSslButton(reply()->sslConfiguration(), account()); + // The serverInstalls to /owncloud. Let's try that if the file wasn't found // at the original location if ((reply()->error() == QNetworkReply::ContentNotFoundError) && (!_subdirFallback)) { diff --git a/src/libsync/networkjobs.h b/src/libsync/networkjobs.h index 56acef7812..5a8dc90181 100644 --- a/src/libsync/networkjobs.h +++ b/src/libsync/networkjobs.h @@ -167,6 +167,7 @@ private slots: virtual bool finished() Q_DECL_OVERRIDE; virtual void slotTimeout() Q_DECL_OVERRIDE; virtual void metaDataChangedSlot(); + virtual void encryptedSlot(); private: bool _subdirFallback;