commit 1315873ac92a6c7800118cc0e481094634b6dc6a
parent 30f661acd330dff77c3bd64a2540d3efcb97aa1c
Author: cfillion <cfillion@users.noreply.github.com>
Date: Sat, 18 Jun 2016 22:26:23 -0400
add a setting for SSL certificate verification
Diffstat:
7 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/src/config.cpp b/src/config.cpp
@@ -39,6 +39,7 @@ static const auto_char *TYPEFILTER_KEY = AUTO_STR("typefilter");
static const auto_char *NETWORK_GRP = AUTO_STR("network");
static const auto_char *PROXY_KEY = AUTO_STR("proxy");
+static const auto_char *VERIFYPEER_KEY = AUTO_STR("verifyPeer");
static const auto_char *SIZE_KEY = AUTO_STR("size");
@@ -62,7 +63,7 @@ void Config::resetOptions()
{
m_install = {false, false};
m_browser = {0};
- m_network = {""};
+ m_network = {"", true};
}
void Config::restoreSelfRemote()
@@ -136,6 +137,8 @@ void Config::read(const Path &path)
TYPEFILTER_KEY, m_browser.typeFilter);
m_network.proxy = getString(NETWORK_GRP, PROXY_KEY, m_network.proxy);
+ m_network.verifyPeer = getUInt(NETWORK_GRP,
+ VERIFYPEER_KEY, m_network.verifyPeer) > 0;
readRemotes();
restoreSelfRemote();
@@ -152,6 +155,7 @@ void Config::write()
setUInt(BROWSER_GRP, TYPEFILTER_KEY, m_browser.typeFilter);
setString(NETWORK_GRP, PROXY_KEY, m_network.proxy);
+ setUInt(NETWORK_GRP, VERIFYPEER_KEY, m_network.verifyPeer);
writeRemotes();
}
diff --git a/src/config.hpp b/src/config.hpp
@@ -36,6 +36,7 @@ struct BrowserOpts {
struct NetworkOpts {
std::string proxy;
+ bool verifyPeer;
};
class Config {
diff --git a/src/download.cpp b/src/download.cpp
@@ -105,10 +105,13 @@ DWORD WINAPI Download::Worker(void *ptr)
#endif
"ReaPack/%s (REAPER v%s)", "1.0", GetAppVersion());
+ const NetworkOpts &opts = download->options();
+
CURL *curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_URL, download->url().c_str());
curl_easy_setopt(curl, CURLOPT_USERAGENT, userAgent);
- curl_easy_setopt(curl, CURLOPT_PROXY, download->options().proxy.c_str());
+ curl_easy_setopt(curl, CURLOPT_PROXY, opts.proxy.c_str());
+ curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, opts.verifyPeer ? 1 : 0);
curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 1);
curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, DOWNLOAD_TIMEOUT);
diff --git a/src/manager.cpp b/src/manager.cpp
@@ -496,6 +496,10 @@ void NetworkConfig::onInit()
{
m_proxy = getControl(IDC_PROXY);
SetWindowText(m_proxy, make_autostring(m_opts->proxy).c_str());
+
+ m_verifyPeer = getControl(IDC_VERIFYPEER);
+ SendMessage(m_verifyPeer, BM_SETCHECK,
+ m_opts->verifyPeer ? BST_CHECKED : BST_UNCHECKED, 0);
}
void NetworkConfig::onCommand(const int id, int)
@@ -513,4 +517,6 @@ void NetworkConfig::onCommand(const int id, int)
void NetworkConfig::apply()
{
m_opts->proxy = getText(m_proxy);
+ m_opts->verifyPeer = SendMessage(m_verifyPeer,
+ BM_GETCHECK, 0, 0) == BST_CHECKED;
}
diff --git a/src/manager.hpp b/src/manager.hpp
@@ -91,6 +91,7 @@ private:
NetworkOpts *m_opts;
HWND m_proxy;
+ HWND m_verifyPeer;
};
#endif
diff --git a/src/resource.hpp b/src/resource.hpp
@@ -67,5 +67,6 @@
#define IDC_ACTIONS 229
#define IDC_BROWSE 230
#define IDC_PROXY 231
+#define IDC_VERIFYPEER 232
#endif
diff --git a/src/resource.rc b/src/resource.rc
@@ -109,6 +109,8 @@ BEGIN
EDITTEXT IDC_PROXY, 40, 5, 185, 14, ES_AUTOHSCROLL
LTEXT "Example: host:port, [ipv6]:port or scheme://host:port",
IDC_LABEL2, 40, 22, 190, 10
+ CHECKBOX "&Verify the authenticity of SSL certificates", IDC_VERIFYPEER,
+ 5, 35, 220, 14, BS_AUTOCHECKBOX | WS_TABSTOP
DEFPUSHBUTTON "&OK", IDOK, 142, 35, 40, 14
PUSHBUTTON "&Cancel", IDCANCEL, 185, 35, 40, 14
END