Try to sign-in after being signed-out due to SslHandshakeFailedError
authoralex-z <blackslayer4@gmail.com>
Thu, 16 Dec 2021 16:23:03 +0000 (18:23 +0200)
committeralex-z <blackslayer4@gmail.com>
Wed, 5 Jan 2022 08:01:13 +0000 (10:01 +0200)
Signed-off-by: alex-z <blackslayer4@gmail.com>
src/gui/accountstate.cpp
src/gui/accountstate.h
src/gui/application.cpp
src/gui/connectionvalidator.cpp

index 7521dac799a7619c3687d90ed114ab4b66b530fd..6100f70fc8b3c3af45cad7b15253ed1d30136fea 100644 (file)
@@ -221,6 +221,19 @@ void AccountState::setDesktopNotificationsAllowed(bool isAllowed)
     emit desktopNotificationsAllowedChanged();
 }
 
+AccountState::ConnectionStatus AccountState::lastConnectionStatus() const
+{
+    return _lastConnectionValidatorStatus;
+}
+
+void AccountState::trySignIn()
+{
+    if (isSignedOut() && account()) {
+        account()->resetRejectedCertificates();
+        signIn();
+    }
+}
+
 void AccountState::checkConnectivity()
 {
     if (isSignedOut() || _waitingForNewCredentials) {
@@ -285,6 +298,8 @@ void AccountState::slotConnectionValidatorResult(ConnectionValidator::Status sta
         return;
     }
 
+    _lastConnectionValidatorStatus = status;
+
     // Come online gradually from 503 or maintenance mode
     if (status == ConnectionValidator::Connected
         && (_connectionStatus == ConnectionValidator::ServiceUnavailable
index 7946e2f969f3145c2e80089fe73d51d58b2c31f9..e2b0a927d0eeed3d3cf21a811843c0e6d00d5011 100644 (file)
@@ -171,6 +171,10 @@ public:
     */
     void setDesktopNotificationsAllowed(bool isAllowed);
 
+    ConnectionStatus lastConnectionStatus() const;
+    
+    void trySignIn();
+
 public slots:
     /// Triggers a ping to the server to update state and
     /// connection status and errors.
@@ -205,6 +209,7 @@ private:
     AccountPtr _account;
     State _state;
     ConnectionStatus _connectionStatus;
+    ConnectionStatus _lastConnectionValidatorStatus = ConnectionStatus::Undefined;
     QStringList _connectionErrors;
     bool _waitingForNewCredentials;
     QDateTime _timeOfLastETagCheck;
index f153224b21fb1f5d212c4f4aad02fcd7d046766d..a7137743f4627729ffee4d54c3a26a712ee1f487 100644 (file)
@@ -465,6 +465,9 @@ void Application::slotCheckConnection()
         if (state != AccountState::SignedOut && state != AccountState::ConfigurationError
             && state != AccountState::AskingCredentials && !pushNotificationsAvailable) {
             accountState->checkConnectivity();
+        } else if (state == AccountState::SignedOut && accountState->lastConnectionStatus() == AccountState::ConnectionStatus::SslError) {
+            qCWarning(lcApplication) << "Account is signed out due to SSL Handshake error. Going to perform a sign-in attempt...";
+            accountState->trySignIn();
         }
     }
 
index 159333544c45b7e55e854d5032b250d617891c0b..14bc2617cb293084239a6f6b2a64c4dd30a10ccc 100644 (file)
@@ -136,7 +136,7 @@ void ConnectionValidator::slotStatusFound(const QUrl &url, const QJsonObject &in
 void ConnectionValidator::slotNoStatusFound(QNetworkReply *reply)
 {
     auto job = qobject_cast<CheckServerJob *>(sender());
-    qCWarning(lcConnectionValidator) << reply->error() << job->errorString() << reply->peek(1024);
+    qCWarning(lcConnectionValidator) << reply->error() << reply->errorString() << job->errorString() << reply->peek(1024);
     if (reply->error() == QNetworkReply::SslHandshakeFailedError) {
         reportResult(SslError);
         return;