From 4d51079ea8cb7bfdadfac0b374b6c97bc0205705 Mon Sep 17 00:00:00 2001 From: Acts1631 Date: Mon, 7 Sep 2026 14:51:47 -0400 Subject: [PATCH] Use HTTPS for infra DNS when supported Select the metadata URL based on the platform HTTPS capability so legacy platforms continue using HTTP while capable platforms avoid downgradeable transport. Keep cache lookup and invalidation on the same URL. --- Core/HLE/sceNet.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Core/HLE/sceNet.cpp b/Core/HLE/sceNet.cpp index 060c9e2bdc..e105c453bc 100644 --- a/Core/HLE/sceNet.cpp +++ b/Core/HLE/sceNet.cpp @@ -31,6 +31,7 @@ #include "Common/Serialize/SerializeFuncs.h" #include "Common/Serialize/SerializeMap.h" #include "Common/Data/Format/JSONReader.h" +#include "Common/System/System.h" #include "Core/HLE/HLE.h" #include "Core/HLE/ErrorCodes.h" #include "Core/HLE/FunctionWrappers.h" @@ -382,10 +383,15 @@ bool LoadAutoDNS(std::string_view json) { std::shared_ptr g_infraDL; -static const std::string_view jsonUrl = "https://metadata.ppsspp.org/infra-dns.json"; +static constexpr std::string_view jsonUrlHttp = "http://metadata.ppsspp.org/infra-dns.json"; +static constexpr std::string_view jsonUrlHttps = "https://metadata.ppsspp.org/infra-dns.json"; + +static std::string_view GetInfraDNSUrl() { + return System_GetPropertyBool(SYSPROP_SUPPORTS_HTTPS) ? jsonUrlHttps : jsonUrlHttp; +} void DeleteAutoDNSCacheFile() { - File::Delete(g_DownloadManager.UrlToCachePath(jsonUrl)); + File::Delete(g_DownloadManager.UrlToCachePath(GetInfraDNSUrl())); } void StartInfraJsonDownload() { @@ -399,7 +405,7 @@ void StartInfraJsonDownload() { if (!g_Config.bDontDownloadInfraJson) { const char * const acceptMime = "application/json, text/*; q=0.9, */*; q=0.8"; - g_infraDL = g_DownloadManager.StartDownload(jsonUrl, Path(), http::RequestFlags::Cached24H, acceptMime); + g_infraDL = g_DownloadManager.StartDownload(GetInfraDNSUrl(), Path(), http::RequestFlags::Cached24H, acceptMime); } } @@ -444,7 +450,7 @@ bool PollInfraJsonDownload(std::string *jsonOutput) { // First, fall back to cache if it exists. Could build this functionality into the download manager // but it would be a bit awkward. std::string json; - if (File::ReadBinaryFileToString(g_DownloadManager.UrlToCachePath(jsonUrl), &json) && !json.empty()) { + if (File::ReadBinaryFileToString(g_DownloadManager.UrlToCachePath(GetInfraDNSUrl()), &json) && !json.empty()) { WARN_LOG(Log::sceNet, "Failed to download infra-dns.json, falling back to cached file"); *jsonOutput = json; LoadAutoDNS(*jsonOutput);