Log SSL errors, give common solutions

This commit is contained in:
Petr Mrázek 2013-12-24 23:38:37 +01:00
parent 027aafc3c1
commit 8d0ca72abb
6 changed files with 64 additions and 5 deletions

View File

@ -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,14 +881,29 @@ void MainWindow::doLaunch()
{
updateInstance(m_selectedInstance, account);
}
// revert from online to verified.
account->downgrade();
return;
else
{
if (!task->successful())
{
failReason = task->failReason();
}
if (loginWithPassword(account, tr("Your account is currently not logged in. Please enter "
"your password to log in again.")))
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();
}
}
bool MainWindow::loginWithPassword(MojangAccountPtr account, const QString &errorMsg)
{

View File

@ -15,6 +15,8 @@
#include "EditAccountDialog.h"
#include "ui_EditAccountDialog.h"
#include <QDesktopServices>
#include <QUrl>
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();

View File

@ -52,6 +52,9 @@ public:
PasswordField,
};
private slots:
void on_label_linkActivated(const QString &link);
private:
Ui::EditAccountDialog *ui;
};

View File

@ -19,6 +19,12 @@
<property name="text">
<string>Message label placeholder.</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item>

View File

@ -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<QSslError> 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("<b>SSL Handshake failed.</b><br/>There might be a few causes for it:<br/>"
"<ul>"
"<li>You use Windows XP and need to <a href=\"http://www.microsoft.com/en-us/download/details.aspx?id=38918\">update your root certificates</a></li>"
"<li>Some device on your network is interfering with SSL traffic. In that case, you have bigger worries than Minecraft not starting.</li>"
"<li>Possibly something else. Check the MultiMC log file for details</li>"
"</ul>"));
return;
}
// any network errors lead to offline mode right now
if (m_netReply->error() >= QNetworkReply::ConnectionRefusedError &&
m_netReply->error() <= QNetworkReply::UnknownNetworkError)

View File

@ -20,6 +20,7 @@
#include <QString>
#include <QJsonObject>
#include <QTimer>
#include <qsslerror.h>
#include "logic/auth/MojangAccount.h"
@ -99,6 +100,7 @@ slots:
void processReply();
void refreshTimers(qint64, qint64);
void heartbeat();
void sslErrors(QList<QSslError>);
public
slots: