From 12fbe0566e403f8959827a61037a964664f64134 Mon Sep 17 00:00:00 2001 From: mistic100 Date: Sun, 5 Feb 2017 12:31:35 +0100 Subject: [PATCH] Download new version over HTTPS --- installer/README.md | 2 ++ src/constants.h | 2 +- src/gui/newversiondialog.cpp | 11 +++++++++-- src/versionchecker.h | 17 ++++++++++++++++- 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/installer/README.md b/installer/README.md index 2fcc772..a490cac 100644 --- a/installer/README.md +++ b/installer/README.md @@ -11,6 +11,8 @@ Put these files in `data` directory before running `setup.iss` or `package.bat`: * Qt5Network.dll * Qt5Widgets.dll * Qt5Xml.dll +* libeay32.dll +* ssleay32.dll * imageformats/qgif.dll * imageformats/qjpeg.dll * platforms/qwindows.dll diff --git a/src/constants.h b/src/constants.h index c46c210..845661a 100644 --- a/src/constants.h +++ b/src/constants.h @@ -20,7 +20,7 @@ #define APP_HOMEPAGE "https://www.strangeplanet.fr/work/umwp-autochanger" #define APP_DOCUMENTATION_URL "https://www.strangeplanet.fr/work/umwp-autochanger/#help" -#define APP_VERSION_URL "http://www.strangeplanet.fr/work/umwp-autochanger/last-version.txt" +#define APP_VERSION_URL "https://www.strangeplanet.fr/work/umwp-autochanger/last-version.txt" #define APP_ISSUES_URL "https://github.com/mistic100/UMWP-Autochanger/issues" #define APP_INSTALLER_SIZE 12000000 diff --git a/src/gui/newversiondialog.cpp b/src/gui/newversiondialog.cpp index 415f811..8e6043b 100644 --- a/src/gui/newversiondialog.cpp +++ b/src/gui/newversiondialog.cpp @@ -60,7 +60,14 @@ void NewVersionDialog::on_updateButton_clicked() QLOG_DEBUG() << "Download" << m_version.link; QNetworkAccessManager* manager = new QNetworkAccessManager(); - m_reply = manager->get(QNetworkRequest(QUrl(m_version.link))); + + QNetworkRequest request(QUrl(m_version.link)); + if (m_version.link.startsWith("https")) + { + request.setSslConfiguration(QSslConfiguration::defaultConfiguration()); + } + + m_reply = manager->get(request); connect(m_reply, SIGNAL(readyRead()), this, SLOT(onDataReady())); connect(m_reply, SIGNAL(finished()), this, SLOT(onDownloadFinished())); @@ -114,7 +121,7 @@ void NewVersionDialog::onDownloadFinished() if (m_reply->error() != QNetworkReply::NoError) { - QLOG_ERROR() << "Network error"; + QLOG_ERROR() << m_reply->errorString(); m_file.remove(); errorMessage(); diff --git a/src/versionchecker.h b/src/versionchecker.h index 61c101d..e016546 100644 --- a/src/versionchecker.h +++ b/src/versionchecker.h @@ -23,7 +23,14 @@ public slots: { QNetworkAccessManager* manager = new QNetworkAccessManager(); connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(downloadFinished(QNetworkReply*))); - manager->get(QNetworkRequest(QUrl(APP_VERSION_URL))); + + QNetworkRequest request(QUrl(APP_VERSION_URL)); + if (QString(APP_VERSION_URL).startsWith("https")) + { + request.setSslConfiguration(QSslConfiguration::defaultConfiguration()); + } + + manager->get(request); } private slots: @@ -35,6 +42,10 @@ private slots: version.code = _reply->readLine().trimmed(); version.link = _reply->readLine().trimmed(); version.hash = _reply->readLine().trimmed(); + if (QString(APP_VERSION_URL).startsWith("https")) + { + version.link = version.link.replace("http://", "https://"); + } if (version.code.compare(APP_VERSION) > 0) { @@ -42,6 +53,10 @@ private slots: emit newVersionAvailable(version); } } + else + { + QLOG_ERROR() << _reply->errorString(); + } _reply->manager()->deleteLater(); _reply->deleteLater();