ArdourHttp, export API to set CA paths

Ideally all https requests would pass via ArdourCurl, instead
of custom libcurl usage, but that will require some major refactoring
This commit is contained in:
Robin Gareus 2022-05-20 21:36:24 +02:00
parent 5476a20fc4
commit 3caa58ba78
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
2 changed files with 20 additions and 13 deletions

View File

@ -52,6 +52,20 @@ using namespace ArdourCurl;
const char* HttpGet::ca_path = NULL;
const char* HttpGet::ca_info = NULL;
void
HttpGet::ca_setopt (CURL* c)
{
if (ca_info) {
curl_easy_setopt (c, CURLOPT_CAINFO, ca_info);
}
if (ca_path) {
curl_easy_setopt (c, CURLOPT_CAPATH, ca_path);
}
if (ca_info || ca_path) {
curl_easy_setopt (c, CURLOPT_SSL_VERIFYPEER, 1);
}
}
void
HttpGet::setup_certificate_paths ()
{
@ -162,15 +176,8 @@ HttpGet::HttpGet (bool p, bool ssl)
// cc= curl_easy_setopt (_curl, CURLOPT_FOLLOWLOCATION, 1); CCERR ("CURLOPT_FOLLOWLOCATION");
// by default use curl's default.
if (ssl && ca_info) {
curl_easy_setopt (_curl, CURLOPT_CAINFO, ca_info);
}
if (ssl && ca_path) {
curl_easy_setopt (_curl, CURLOPT_CAPATH, ca_path);
}
if (ssl && (ca_info || ca_path)) {
curl_easy_setopt (_curl, CURLOPT_SSL_VERIFYPEER, 1);
if (ssl) {
ca_setopt (_curl);
}
}

View File

@ -26,7 +26,7 @@
namespace ArdourCurl {
class HttpGet {
public:
public:
HttpGet (bool persist = false, bool ssl = true);
~HttpGet ();
@ -75,7 +75,9 @@ class HttpGet {
// called from fixup_bundle_environment
static void setup_certificate_paths ();
private:
static void ca_setopt (CURL*);
private:
CURL* _curl;
bool persist;
@ -94,8 +96,6 @@ class HttpGet {
char* http_get (const char* url, int* status, bool with_error_logging);
std::string http_get (const std::string& url, bool with_error_logging);
} // namespace
#endif /* __gtk_ardour_http_h__ */