diff --git a/include/settings.hpp b/include/settings.hpp index 7c46dd26..75375335 100644 --- a/include/settings.hpp +++ b/include/settings.hpp @@ -78,6 +78,7 @@ extern bool skipLoadOnLaunch; extern std::list recentPatchPaths; extern std::vector cableColors; extern bool autoCheckUpdates; +extern bool verifyHttpsCerts; extern bool showTipsOnLaunch; extern int tipIndex; enum BrowserSort { diff --git a/src/network.cpp b/src/network.cpp index 9da83245..e01e0dda 100644 --- a/src/network.cpp +++ b/src/network.cpp @@ -7,6 +7,7 @@ #include #include #include +#include namespace rack { @@ -35,9 +36,13 @@ static CURL* createCurl() { // So tell curl not to signal. curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1); + // Load root certificates std::string caPath = asset::system("cacert.pem"); curl_easy_setopt(curl, CURLOPT_CAINFO, caPath.c_str()); + // Don't verify HTTPS certificates if verifyHttpsCerts is false + curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, settings::verifyHttpsCerts); + return curl; } diff --git a/src/settings.cpp b/src/settings.cpp index b88be2c0..384071e9 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -61,6 +61,7 @@ std::vector cableColors = { color::fromHexString("#8b4ade"), // purple }; bool autoCheckUpdates = true; +bool verifyHttpsCerts = true; bool showTipsOnLaunch = true; int tipIndex = -1; BrowserSort browserSort = BROWSER_SORT_UPDATED; @@ -187,6 +188,8 @@ json_t* toJson() { json_object_set_new(rootJ, "autoCheckUpdates", json_boolean(autoCheckUpdates)); + json_object_set_new(rootJ, "verifyHttpsCerts", json_boolean(verifyHttpsCerts)); + json_object_set_new(rootJ, "showTipsOnLaunch", json_boolean(showTipsOnLaunch)); json_object_set_new(rootJ, "tipIndex", json_integer(tipIndex)); @@ -411,6 +414,10 @@ void fromJson(json_t* rootJ) { if (autoCheckUpdatesJ) autoCheckUpdates = json_boolean_value(autoCheckUpdatesJ); + json_t* verifyHttpsCertsJ = json_object_get(rootJ, "verifyHttpsCerts"); + if (verifyHttpsCertsJ) + verifyHttpsCerts = json_boolean_value(verifyHttpsCertsJ); + json_t* showTipsOnLaunchJ = json_object_get(rootJ, "showTipsOnLaunch"); if (showTipsOnLaunchJ) showTipsOnLaunch = json_boolean_value(showTipsOnLaunchJ);