diff --git a/CMakeLists.txt b/CMakeLists.txt
index 75f023121781d1c7db1ca394337c69887d5b13eb..aa0c69b76f7893a7a716034934c68097f5702036 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -71,6 +71,8 @@ set(CXX_SOURCES
src/eventsmodel.cpp
src/locationprovider.cpp
src/main.cpp
+ src/requestutils.h
+ src/requestutils.cpp
src/all_countries.h
src/citiesloader.h
src/countriesloader.h
@@ -159,7 +161,8 @@ if(ANDROID)
endif()
else()
find_package(Qt5 COMPONENTS Core Quick Positioning QuickControls2 Sql REQUIRED)
- add_executable(RadarApp
+
+add_executable(RadarApp
${CXX_SOURCES}
translations.qrc
resources.qrc
diff --git a/src/citiesloader.cpp b/src/citiesloader.cpp
index cd0e93b14a5fd77590e27821d1db17adfc6f1cdd..57494a90bf9880bca0a7deb99a49e4774b4ab1b0 100644
--- a/src/citiesloader.cpp
+++ b/src/citiesloader.cpp
@@ -23,6 +23,7 @@
#include "all_countries.h"
#include "database.h"
+#include "requestutils.h"
#include <QJsonArray>
#include <QJsonParseError>
@@ -74,6 +75,7 @@ void CitiesLoader::loadCities()
QUrl requestUrl(m_requestUrlBase.arg(QLatin1String(countryCode)));
qDebug() << "Request URL:" << requestUrl.toString();
QNetworkRequest request;
+ configureRequestSSL(request);
request.setUrl(requestUrl);
request.setRawHeader(QByteArrayLiteral("User-Agent"), QByteArrayLiteral("Radar App 1.0"));
auto reply = m_networkAccessManager->get(request);
diff --git a/src/countriesloader.cpp b/src/countriesloader.cpp
index a66da4098bb87ae6cdc4feece0ee616dd56e313e..42571153e218ed3126e4782a49c389e1de219fc1 100644
--- a/src/countriesloader.cpp
+++ b/src/countriesloader.cpp
@@ -20,6 +20,8 @@
*/
#include "countriesloader.h"
+#include "requestutils.h"
+
#include <QJsonParseError>
#include <QNetworkReply>
@@ -47,6 +49,7 @@ void CountriesLoader::loadCountries()
QNetworkRequest request;
QUrl requestUrl(m_requestUrlBase, QUrl::ParsingMode::TolerantMode);
qDebug() << "requestUrl=" << requestUrl.toString();
+ configureRequestSSL(request);
request.setUrl(requestUrl);
request.setRawHeader(QByteArrayLiteral("User-Agent"), QByteArrayLiteral("Radar App 1.0"));
diff --git a/src/eventsloader.cpp b/src/eventsloader.cpp
index 33a4886dbdf42cda14cb8a94f4f6caaadc06c5d3..8da344ae5c1e1cad777b1f098260b7a3b01f9bee 100644
--- a/src/eventsloader.cpp
+++ b/src/eventsloader.cpp
@@ -21,6 +21,7 @@
#include "eventsloader.h"
#include "database.h"
+#include "requestutils.h"
EventsLoader::EventsLoader(QNetworkAccessManager &networkAccessManager,
DB &db,
@@ -62,6 +63,7 @@ void EventsLoader::loadEvents(const QUrlQuery &query)
requestUrl.setQuery(query);
qDebug() << "requestUrl=" << requestUrl.toString();
QNetworkRequest request;
+ configureRequestSSL(request);
request.setUrl(requestUrl);
request.setRawHeader(QByteArrayLiteral("User-Agent"), QByteArrayLiteral("Radar App 1.0"));
diff --git a/src/locationprovider.cpp b/src/locationprovider.cpp
index c68c3bd6b6a586d67ffad71ad0016cd039d05a59..f41ffb4a44bcec86df5c10ba8fe7db8993e63ff0 100644
--- a/src/locationprovider.cpp
+++ b/src/locationprovider.cpp
@@ -20,6 +20,7 @@
*/
#include "locationprovider.h"
#include "database.h"
+#include "requestutils.h"
#include <QJsonObject>
#include <QJsonParseError>
@@ -268,6 +269,7 @@ void LocationProvider::setLocationsToLoad(QSet< QUuid > &&locations, const QByte
if (!m_locationsToLoad.empty()) {
QUrl requestUrl(m_locationsInCity.arg(m_countryCode, m_city));
QNetworkRequest request(requestUrl);
+ configureRequestSSL(request);
request.setRawHeader(QByteArrayLiteral("User-Agent"), QByteArrayLiteral("Radar App 1.0"));
qDebug() << "[Network] Requesting locations for city:" << requestUrl;
auto reply = m_networkAccessManager.get(request);
@@ -280,6 +282,7 @@ QNetworkReply *LocationProvider::requestLocationByUUID(const QUuid &id)
QUrl requestUrl(QStringLiteral("%1%2.json?fields=address,direction,map,title,uuid")
.arg(m_locationUrlBase, id.toString(QUuid::WithoutBraces)));
QNetworkRequest request(requestUrl);
+ configureRequestSSL(request);
request.setRawHeader(QByteArrayLiteral("User-Agent"), QByteArrayLiteral("Radar App 1.0"));
qDebug() << "[Network] Requesting location " << id;
return m_networkAccessManager.get(request);
diff --git a/src/requestutils.cpp b/src/requestutils.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..de751fad532fe372da2701564bdb0094e6008cb0
--- /dev/null
+++ b/src/requestutils.cpp
@@ -0,0 +1,35 @@
+/*
+ * requestutils.cpp
+ *
+ * Copyright (c) 2024 Andy Ex
+ *
+ * This file is part of Radar-App.
+ *
+ * Radar-App is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Radar-App is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Radar-App. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+#include "requestutils.h"
+
+#include <qssl.h>
+
+#include <QSslConfiguration>
+#include <QNetworkRequest>
+
+void configureRequestSSL(QNetworkRequest &request)
+{
+ QSslConfiguration sslConfig{QSslConfiguration::defaultConfiguration()};
+ sslConfig.setProtocol(QSsl::AnyProtocol);
+
+ request.setSslConfiguration(sslConfig);
+}
diff --git a/src/requestutils.h b/src/requestutils.h
new file mode 100644
index 0000000000000000000000000000000000000000..b940ce01d53897628fdf52e6b017b836cb55813f
--- /dev/null
+++ b/src/requestutils.h
@@ -0,0 +1,26 @@
+/*
+ * requestutils.h
+ *
+ * Copyright (c) 2024 Andy Ex
+ *
+ * This file is part of Radar-App.
+ *
+ * Radar-App is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Radar-App is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Radar-App. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include <QNetworkRequest>
+
+void configureRequestSSL(QNetworkRequest &request);