From 18d2bfcd8b8417a4a0698b219c41ae6543c97f1c Mon Sep 17 00:00:00 2001 From: James Turner Date: Thu, 25 Jun 2020 16:12:40 +0100 Subject: [PATCH] HTTP: allow CAINFO to be set Env var is SIMGEAR_TLS_CERT_PATH --- simgear/io/HTTPClient.cxx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/simgear/io/HTTPClient.cxx b/simgear/io/HTTPClient.cxx index 86eeb6bc..a860daf3 100644 --- a/simgear/io/HTTPClient.cxx +++ b/simgear/io/HTTPClient.cxx @@ -105,6 +105,8 @@ public: unsigned int bytesTransferred; unsigned int lastTransferRate; uint64_t totalBytesDownloaded; + + SGPath tlsCertificatePath; }; Client::Client() : @@ -120,6 +122,8 @@ Client::Client() : d->maxPipelineDepth = 5; setUserAgent("SimGear-" SG_STRINGIZE(SIMGEAR_VERSION)); + d->tlsCertificatePath = SGPath::fromEnv("SIMGEAR_TLS_CERT_PATH"); + static bool didInitCurlGlobal = false; static std::mutex initMutex; @@ -285,6 +289,11 @@ void Client::makeRequest(const Request_ptr& r) curl_easy_setopt(curlRequest, CURLOPT_FOLLOWLOCATION, 1); + if (!d->tlsCertificatePath.isNull()) { + const auto utf8 = d->tlsCertificatePath.utf8Str(); + curl_easy_setopt(curlRequest, CURLOPT_CAINFO, utf8.c_str()); + } + if (!d->proxy.empty()) { curl_easy_setopt(curlRequest, CURLOPT_PROXY, d->proxy.c_str()); curl_easy_setopt(curlRequest, CURLOPT_PROXYPORT, d->proxyPort);