From 8d0ca72abb10b0cb77816d44f3f768865cc23aef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Tue, 24 Dec 2013 23:38:37 +0100 Subject: [PATCH] Log SSL errors, give common solutions --- gui/MainWindow.cpp | 27 ++++++++++++++++++++++----- gui/dialogs/EditAccountDialog.cpp | 7 +++++++ gui/dialogs/EditAccountDialog.h | 3 +++ gui/dialogs/EditAccountDialog.ui | 6 ++++++ logic/auth/YggdrasilTask.cpp | 24 ++++++++++++++++++++++++ logic/auth/YggdrasilTask.h | 2 ++ 6 files changed, 64 insertions(+), 5 deletions(-) diff --git a/gui/MainWindow.cpp b/gui/MainWindow.cpp index 179f881f..4fb4489f 100644 --- a/gui/MainWindow.cpp +++ b/gui/MainWindow.cpp @@ -865,6 +865,8 @@ void MainWindow::doLaunch() if (!account.get()) return; + QString failReason = tr("Your account is currently not logged in. Please enter " + "your password to log in again."); // do the login. if the account has an access token, try to refresh it first. if (account->accountStatus() != NotVerified) { @@ -879,13 +881,28 @@ void MainWindow::doLaunch() { updateInstance(m_selectedInstance, account); } - // revert from online to verified. + else + { + if (!task->successful()) + { + failReason = task->failReason(); + } + if (loginWithPassword(account, failReason)) + updateInstance(m_selectedInstance, account); + } + // in any case, revert from online to verified. + account->downgrade(); + } + else + { + if (loginWithPassword(account, failReason)) + { + updateInstance(m_selectedInstance, account); + account->downgrade(); + } + // in any case, revert from online to verified. account->downgrade(); - return; } - if (loginWithPassword(account, tr("Your account is currently not logged in. Please enter " - "your password to log in again."))) - updateInstance(m_selectedInstance, account); } bool MainWindow::loginWithPassword(MojangAccountPtr account, const QString &errorMsg) diff --git a/gui/dialogs/EditAccountDialog.cpp b/gui/dialogs/EditAccountDialog.cpp index dd3f0523..a1bd5591 100644 --- a/gui/dialogs/EditAccountDialog.cpp +++ b/gui/dialogs/EditAccountDialog.cpp @@ -15,6 +15,8 @@ #include "EditAccountDialog.h" #include "ui_EditAccountDialog.h" +#include +#include EditAccountDialog::EditAccountDialog(const QString &text, QWidget *parent, int flags) : QDialog(parent), ui(new Ui::EditAccountDialog) @@ -33,6 +35,11 @@ EditAccountDialog::~EditAccountDialog() delete ui; } +void EditAccountDialog::on_label_linkActivated(const QString &link) +{ + QDesktopServices::openUrl(QUrl(link)); +} + QString EditAccountDialog::username() const { return ui->userTextBox->text(); diff --git a/gui/dialogs/EditAccountDialog.h b/gui/dialogs/EditAccountDialog.h index be3a88d8..83f25124 100644 --- a/gui/dialogs/EditAccountDialog.h +++ b/gui/dialogs/EditAccountDialog.h @@ -52,6 +52,9 @@ public: PasswordField, }; +private slots: + void on_label_linkActivated(const QString &link); + private: Ui::EditAccountDialog *ui; }; diff --git a/gui/dialogs/EditAccountDialog.ui b/gui/dialogs/EditAccountDialog.ui index 1a8f9dba..5f727bd4 100644 --- a/gui/dialogs/EditAccountDialog.ui +++ b/gui/dialogs/EditAccountDialog.ui @@ -19,6 +19,12 @@ Message label placeholder. + + Qt::RichText + + + Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + diff --git a/logic/auth/YggdrasilTask.cpp b/logic/auth/YggdrasilTask.cpp index 573dd57a..3ba53bd7 100644 --- a/logic/auth/YggdrasilTask.cpp +++ b/logic/auth/YggdrasilTask.cpp @@ -48,6 +48,7 @@ void YggdrasilTask::executeTask() connect(m_netReply, &QNetworkReply::finished, this, &YggdrasilTask::processReply); connect(m_netReply, &QNetworkReply::uploadProgress, this, &YggdrasilTask::refreshTimers); connect(m_netReply, &QNetworkReply::downloadProgress, this, &YggdrasilTask::refreshTimers); + connect(m_netReply, &QNetworkReply::sslErrors, this, &YggdrasilTask::sslErrors); timeout_keeper.setSingleShot(true); timeout_keeper.start(timeout_max); counter.setSingleShot(false); @@ -75,10 +76,33 @@ void YggdrasilTask::abort() m_netReply->abort(); } +void YggdrasilTask::sslErrors(QList errors) +{ + int i = 1; + for(auto error: errors) + { + QLOG_ERROR() << "LOGIN SSL Error #" << i << " : " << error.errorString(); + auto cert = error.certificate(); + QLOG_ERROR() << "Certificate in question:\n" << cert.toText(); + i++; + } +} + void YggdrasilTask::processReply() { setStatus(getStateMessage(STATE_PROCESSING_RESPONSE)); + if (m_netReply->error() == QNetworkReply::SslHandshakeFailedError) + { + emitFailed(tr("SSL Handshake failed.
There might be a few causes for it:
" + "
    " + "
  • You use Windows XP and need to update your root certificates
  • " + "
  • Some device on your network is interfering with SSL traffic. In that case, you have bigger worries than Minecraft not starting.
  • " + "
  • Possibly something else. Check the MultiMC log file for details
  • " + "
")); + return; + } + // any network errors lead to offline mode right now if (m_netReply->error() >= QNetworkReply::ConnectionRefusedError && m_netReply->error() <= QNetworkReply::UnknownNetworkError) diff --git a/logic/auth/YggdrasilTask.h b/logic/auth/YggdrasilTask.h index 1f81a2d0..85f5a1e1 100644 --- a/logic/auth/YggdrasilTask.h +++ b/logic/auth/YggdrasilTask.h @@ -20,6 +20,7 @@ #include #include #include +#include #include "logic/auth/MojangAccount.h" @@ -99,6 +100,7 @@ slots: void processReply(); void refreshTimers(qint64, qint64); void heartbeat(); + void sslErrors(QList); public slots: