Properly follow StartupVerify setting

develop
kaetemi 3 years ago committed by Nimetu
parent 5fcaafbc60
commit 8f839dc9c7

@ -34,7 +34,7 @@ class CCurlHttpClient
public: public:
/// Constructor /// Constructor
CCurlHttpClient() : _CurlStruct(NULL) {} CCurlHttpClient() : _CurlStruct(NULL), m_Verify(true) {}
/// Connect to an http server (string by val is intended). If you specify a whole URL, an attempt will be made to determine the server. /// Connect to an http server (string by val is intended). If you specify a whole URL, an attempt will be made to determine the server.
bool connect(const std::string &server); bool connect(const std::string &server);
@ -82,6 +82,8 @@ private:
std::string _Auth; // must be kept here because curl only stores the char pointer std::string _Auth; // must be kept here because curl only stores the char pointer
std::vector<char> m_ErrorBuf; std::vector<char> m_ErrorBuf;
bool m_Verify;
}; };
extern CCurlHttpClient CurlHttpClient; extern CCurlHttpClient CurlHttpClient;

@ -75,8 +75,9 @@ static const std::string CAFilename = "cacert.pem"; // https://curl.haxx.se/docs
// *************************************************************************** // ***************************************************************************
bool CCurlHttpClient::verifyServer(bool verify) bool CCurlHttpClient::verifyServer(bool verify)
{ {
curl_easy_setopt(_Curl, CURLOPT_SSL_VERIFYHOST, verify ? 2 : 0); m_Verify = verify;
curl_easy_setopt(_Curl, CURLOPT_SSL_VERIFYPEER, verify ? 1 : 0); curl_easy_setopt(_Curl, CURLOPT_SSL_VERIFYPEER, verify ? 1 : 0);
curl_easy_setopt(_Curl, CURLOPT_SSL_VERIFYHOST, verify ? 2 : 0);
// specify custom CA certs // specify custom CA certs
CCurlCertificates::addCertificateFile(CAFilename); CCurlCertificates::addCertificateFile(CAFilename);
@ -97,8 +98,8 @@ bool CCurlHttpClient::sendRequest(const std::string& methodWB, const std::string
curl_easy_setopt(_Curl, CURLOPT_URL, url.c_str()); curl_easy_setopt(_Curl, CURLOPT_URL, url.c_str());
if (url.length() > 8 && (url[4] == 's' || url[4] == 'S')) // 01234 https if (url.length() > 8 && (url[4] == 's' || url[4] == 'S')) // 01234 https
{ {
curl_easy_setopt(_Curl, CURLOPT_SSL_VERIFYPEER, 1L); curl_easy_setopt(_Curl, CURLOPT_SSL_VERIFYPEER, m_Verify ? 1L : 0);
curl_easy_setopt(_Curl, CURLOPT_SSL_VERIFYHOST, 2L); curl_easy_setopt(_Curl, CURLOPT_SSL_VERIFYHOST, m_Verify ? 2L : 0);
} }
// Authentication // Authentication

Loading…
Cancel
Save