add Http::verify_ssl(bool verify) method

This commit is contained in:
2022-08-25 05:16:23 +02:00
parent c730b85629
commit b1441366f4
2 changed files with 15 additions and 0 deletions

View File

@@ -72,6 +72,7 @@ Http & Http::begin()
debug_mode = 0;
debug_info = nullptr;
follow_location = true;
verify_ssl_cert = true;
return *this;
}
@@ -414,6 +415,11 @@ void Http::allow_redirects(bool allow_redirects)
}
void Http::verify_ssl(bool verify)
{
this->verify_ssl_cert = verify;
}
void Http::initialize_curl_if_needed()
@@ -498,6 +504,8 @@ bool Http::fetch_internal(const char * url, const std::string * in, pt::TextStre
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, (follow_location) ? 1 : 0);
curl_easy_setopt(curl, CURLOPT_MAXREDIRS, 20);
curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, (verify_ssl_cert) ? 1 : 0);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, (verify_ssl_cert) ? 2 : 0); // set to 2: https://curl.se/libcurl/c/CURLOPT_SSL_VERIFYHOST.html
if( debug_mode == 1 )
{