summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authortastytea2020-01-12 13:37:53 +0100
committertastytea2020-01-12 13:37:53 +0100
commit97eb269865fb51ef55a9fcb59f3f1731b852a56b (patch)
tree7773de46292d423a510dc02ca700f38d7803a5f0 /src
parentcd31af94a68b2320b8d4bc0dc7377cdece50dc25 (diff)
downloadmastodonpp-97eb269865fb51ef55a9fcb59f3f1731b852a56b.tar
mastodonpp-97eb269865fb51ef55a9fcb59f3f1731b852a56b.tar.gz
mastodonpp-97eb269865fb51ef55a9fcb59f3f1731b852a56b.zip
Add Instance::set_cainfo().
Diffstat (limited to 'src')
-rw-r--r--src/connection.cpp4
-rw-r--r--src/curl_wrapper.cpp9
2 files changed, 13 insertions, 0 deletions
diff --git a/src/connection.cpp b/src/connection.cpp
index 8512097..0eba695 100644
--- a/src/connection.cpp
+++ b/src/connection.cpp
@@ -35,6 +35,10 @@ Connection::Connection(Instance &instance)
{
CURLWrapper::set_access_token(_instance.get_access_token());
}
+ if (!_instance.get_cainfo().empty())
+ {
+ CURLWrapper::set_cainfo(_instance.get_cainfo());
+ }
}
string Connection::endpoint_to_uri(const endpoint_variant &endpoint) const
diff --git a/src/curl_wrapper.cpp b/src/curl_wrapper.cpp
index d224ef5..4cfb9b5 100644
--- a/src/curl_wrapper.cpp
+++ b/src/curl_wrapper.cpp
@@ -223,6 +223,15 @@ void CURLWrapper::set_access_token(const string_view access_token)
debuglog << "Set authorization token.\n";
}
+void CURLWrapper::set_cainfo(string_view path)
+{
+ CURLcode code{curl_easy_setopt(_connection, CURLOPT_CAINFO, path.data())};
+ if (code != CURLE_OK)
+ {
+ throw CURLException{code, "Could not set CA info.", _curl_buffer_error};
+ }
+}
+
size_t CURLWrapper::writer_body(char *data, size_t size, size_t nmemb)
{
if(data == nullptr)