[neon/kde/kdepim-runtime/Neon/release] debian/patches: add patch to fix pop3 https://bugs.kde.org/show_bug.cgi?id=446751 https://invent.kde.org/pim/kdepim-runtime/-/merge_requests/63/diffs?commit_id=f14fabcefb45790175e209ef8ae394def4a805e9 https://bugs.kde.org/show_bug.cgi?id=447008

Jonathan Riddell null at kde.org
Wed Dec 15 14:30:43 GMT 2021


Git commit 303cec401b504e4f69b211e4035ed1f2486b6a90 by Jonathan Riddell.
Committed on 15/12/2021 at 14:30.
Pushed by jriddell into branch 'Neon/release'.

add patch to fix pop3 https://bugs.kde.org/show_bug.cgi?id=446751 https://invent.kde.org/pim/kdepim-runtime/-/merge_requests/63/diffs?commit_id=f14fabcefb45790175e209ef8ae394def4a805e9 https://bugs.kde.org/show_bug.cgi?id=447008

A  +121  -0    debian/patches/pop3-ssl-connections.diff
A  +1    -0    debian/patches/series

https://invent.kde.org/neon/kde/kdepim-runtime/commit/303cec401b504e4f69b211e4035ed1f2486b6a90

diff --git a/debian/patches/pop3-ssl-connections.diff b/debian/patches/pop3-ssl-connections.diff
new file mode 100644
index 0000000..0a1e68c
--- /dev/null
+++ b/debian/patches/pop3-ssl-connections.diff
@@ -0,0 +1,121 @@
+commit f14fabcefb45790175e209ef8ae394def4a805e9
+Author: Albert Astals Cid <aacid at kde.org>
+Date:   Fri Dec 10 21:55:13 2021 +0100
+
+    POP3: Fix SSL connections
+    
+    We need to go into ssl before trying to read from the socket, otherwise
+    nothing works
+    
+    BUGS: 446751
+
+diff --git a/resources/pop3/pop3protocol.cpp b/resources/pop3/pop3protocol.cpp
+index c2d01d33a..15971919e 100644
+--- a/resources/pop3/pop3protocol.cpp
++++ b/resources/pop3/pop3protocol.cpp
+@@ -535,6 +535,39 @@ Result POP3Protocol::loginPASS()
+     return Result::pass();
+ }
+ 
++Result POP3Protocol::startSsl()
++{
++    mSocket->ignoreSslErrors(); // Don't worry, errors are handled manually below
++    mSocket->startClientEncryption();
++    const bool encryptionStarted = mSocket->waitForEncrypted(s_connectTimeout);
++
++    const QSslCipher cipher = mSocket->sessionCipher();
++    const QList<QSslError> errors = mSocket->sslHandshakeErrors();
++    if (!encryptionStarted || !errors.isEmpty() || !mSocket->isEncrypted() || cipher.isNull() || cipher.usedBits() == 0) {
++        QString errorString = std::accumulate(errors.begin(), errors.end(), QString(), [](QString cur, const QSslError &error) {
++            if (!cur.isEmpty())
++                cur += QLatin1Char('\n');
++            cur += error.errorString();
++            return cur;
++        });
++
++        qCDebug(POP3_LOG) << "Initial SSL handshake failed. cipher.isNull() is" << cipher.isNull() << ", cipher.usedBits() is" << cipher.usedBits()
++                          << ", the socket says:" << mSocket->errorString() << "and the SSL errors are:" << errorString;
++        mContinueAfterSslError = false;
++        Q_EMIT sslError(KSslErrorUiData(mSocket));
++        if (!mContinueAfterSslError) {
++            if (errorString.isEmpty())
++                errorString = mSocket->errorString();
++            qCDebug(POP3_LOG) << "TLS setup has failed. Aborting." << errorString;
++            closeConnection();
++            return Result::fail(ERR_SSL_FAILURE, i18n("SSL/TLS error: %1", errorString));
++        }
++    } else {
++        qCDebug(POP3_LOG) << "TLS has been enabled.";
++    }
++    return Result::pass();
++}
++
+ Result POP3Protocol::openConnection()
+ {
+     m_try_apop = mSettings.authenticationMethod() == MailTransport::Transport::EnumAuthenticationType::APOP;
+@@ -560,6 +593,13 @@ Result POP3Protocol::openConnection()
+             return Result::fail(mSocket->error(), errorString);
+         }
+ 
++        if (mSettings.useSSL()) {
++            const Result res = startSsl();
++            if (!res.success) {
++                return res;
++            }
++        }
++
+         mConnected = true;
+ 
+         greeting_buf = new char[GREETING_BUF_LEN];
+@@ -608,35 +648,9 @@ Result POP3Protocol::openConnection()
+                                          "was unsuccessful.\nYou can "
+                                          "disable TLS in the POP account settings dialog."));
+             }
+-        }
+-        if (mSettings.useSSL() || mSettings.useTLS()) {
+-            mSocket->ignoreSslErrors(); // Don't worry, errors are handled manually below
+-            mSocket->startClientEncryption();
+-            const bool encryptionStarted = mSocket->waitForEncrypted(s_connectTimeout);
+-
+-            const QSslCipher cipher = mSocket->sessionCipher();
+-            const QList<QSslError> errors = mSocket->sslHandshakeErrors();
+-            if (!encryptionStarted || !errors.isEmpty() || !mSocket->isEncrypted() || cipher.isNull() || cipher.usedBits() == 0) {
+-                QString errorString = std::accumulate(errors.begin(), errors.end(), QString(), [](QString cur, const QSslError &error) {
+-                    if (!cur.isEmpty())
+-                        cur += QLatin1Char('\n');
+-                    cur += error.errorString();
+-                    return cur;
+-                });
+-
+-                qCDebug(POP3_LOG) << "Initial SSL handshake failed. cipher.isNull() is" << cipher.isNull() << ", cipher.usedBits() is" << cipher.usedBits()
+-                                  << ", the socket says:" << mSocket->errorString() << "and the SSL errors are:" << errorString;
+-                mContinueAfterSslError = false;
+-                Q_EMIT sslError(KSslErrorUiData(mSocket));
+-                if (!mContinueAfterSslError) {
+-                    if (errorString.isEmpty())
+-                        errorString = mSocket->errorString();
+-                    qCDebug(POP3_LOG) << "TLS setup has failed. Aborting." << errorString;
+-                    closeConnection();
+-                    return Result::fail(ERR_SSL_FAILURE, i18n("SSL/TLS error: %1", errorString));
+-                }
+-            } else {
+-                qCDebug(POP3_LOG) << "TLS has been enabled.";
++            const Result res = startSsl();
++            if (!res.success) {
++                return res;
+             }
+         }
+ 
+diff --git a/resources/pop3/pop3protocol.h b/resources/pop3/pop3protocol.h
+index 9b40b334f..d01f7ab7a 100644
+--- a/resources/pop3/pop3protocol.h
++++ b/resources/pop3/pop3protocol.h
+@@ -127,6 +127,8 @@ private:
+      */
+     Q_REQUIRED_RESULT Result loginPASS();
+ 
++    Q_REQUIRED_RESULT Result startSsl();
++
+     const Settings &mSettings;
+     QSslSocket *const mSocket;
+     unsigned short int m_iPort;
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..eb1b932
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1 @@
+pop3-ssl-connections.diff


More information about the Neon-commits mailing list