add Http::verify_ssl(bool verify) method
This commit is contained in:
parent
c730b85629
commit
b1441366f4
|
@ -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 )
|
||||
{
|
||||
|
|
|
@ -151,6 +151,12 @@ public:
|
|||
*/
|
||||
void allow_redirects(bool allow_redirects);
|
||||
|
||||
/*
|
||||
* verify the peer's SSL certificate
|
||||
* default is true
|
||||
*/
|
||||
void verify_ssl(bool verify);
|
||||
|
||||
bool get(const wchar_t * url, std::wstring & out, bool clear_str = true);
|
||||
bool get(const std::wstring & url, std::wstring & out, bool clear_str = true);
|
||||
bool get(const pt::WTextStream & url, std::wstring & out, bool clear_str = true);
|
||||
|
@ -189,6 +195,7 @@ private:
|
|||
long debug_mode;
|
||||
pt::Space * debug_info;
|
||||
bool follow_location;
|
||||
bool verify_ssl_cert;
|
||||
|
||||
std::wstring temp_header;
|
||||
std::string temp_header_ascii;
|
||||
|
|
Loading…
Reference in New Issue