[Pkg-owncloud-commits] [owncloud-client] 35/120: SslButton: Fix harder #3534 #3536

Sandro Knauß hefee-guest at moszumanska.debian.org
Mon Aug 24 00:02:41 UTC 2015


This is an automated email from the git hooks/post-receive script.

hefee-guest pushed a commit to branch master
in repository owncloud-client.

commit bd71fdc388d2daf0e241d55745858c4ea677debe
Author: Markus Goetz <markus at woboq.com>
Date:   Tue Aug 11 12:18:25 2015 +0200

    SslButton: Fix harder #3534 #3536
---
 src/gui/sslbutton.cpp       | 14 +++++++-------
 src/libsync/account.h       |  7 +++++++
 src/libsync/networkjobs.cpp | 24 +++++++++++++++++++++++-
 src/libsync/networkjobs.h   |  1 +
 4 files changed, 38 insertions(+), 8 deletions(-)

diff --git a/src/gui/sslbutton.cpp b/src/gui/sslbutton.cpp
index 640b5dc..9c5bad0 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<QSslCertificate> chain = account->sslConfiguration().peerCertificateChain();
+        QList<QSslCertificate> chain = account->_peerCertificateChain;
 
         if (chain.isEmpty()) {
             qWarning() << "empty certificate chain";
diff --git a/src/libsync/account.h b/src/libsync/account.h
index 60e096d..c64ea3f 100644
--- a/src/libsync/account.h
+++ b/src/libsync/account.h
@@ -22,6 +22,7 @@
 #include <QSslSocket>
 #include <QSslCertificate>
 #include <QSslConfiguration>
+#include <QSslCipher>
 #include <QSslError>
 #include <QSharedPointer>
 #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<QSslCertificate> _peerCertificateChain;
+
+
     /** The certificates of the account */
     QList<QSslCertificate> approvedCerts() const { return _approvedCerts; }
     void setApprovedCerts(const QList<QSslCertificate> certs);
diff --git a/src/libsync/networkjobs.cpp b/src/libsync/networkjobs.cpp
index ea516c4..c0c684e 100644
--- a/src/libsync/networkjobs.cpp
+++ b/src/libsync/networkjobs.cpp
@@ -18,6 +18,7 @@
 #include <QNetworkReply>
 #include <QNetworkRequest>
 #include <QSslConfiguration>
+#include <QSslCipher>
 #include <QBuffer>
 #include <QXmlStreamReader>
 #include <QStringList>
@@ -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 56acef7..5a8dc90 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;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git



More information about the Pkg-owncloud-commits mailing list