From c72a0d24d350c41224128184393ee7b4e846a71c Mon Sep 17 00:00:00 2001 From: Sukender Date: Tue, 27 Aug 2024 08:02:31 +0200 Subject: [PATCH] Added option to disable SSL verification for self-signed certificates or certificates not locally installed. --- include/slacking/slacking.hpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/slacking/slacking.hpp b/include/slacking/slacking.hpp index 0f647b4..14c30b4 100644 --- a/include/slacking/slacking.hpp +++ b/include/slacking/slacking.hpp @@ -109,6 +109,12 @@ class Session { if (nullptr != curl_) curl_easy_setopt(curl_, CURLOPT_PROXY, proxy_url_.c_str()); } + /// Enables or disables SSL certificate verification for this session. + /// This may be useful when using HTTPS with self-signed certificates, for instance. + void enableSSLVerify(bool status) { + if (nullptr != curl_) curl_easy_setopt(curl_, CURLOPT_SSL_VERIFYPEER, status ? 1L : 0L); + } + void SetBody(const std::string& data); Response Get(); Response Post(); @@ -355,6 +361,9 @@ class Slacking { Slacking& operator=(const Slacking&) = delete; void set_proxy(const std::string& url) { session_.SetProxyUrl(url); } + /// Enables or disables SSL certificate verification for this session. + /// This may be useful when using HTTPS with self-signed certificates, for instance. + void enableSSLVerify(bool status) { session_.enableSSLVerify(status); } void change_token(const std::string& token) { token_ = token; };