Skip to content

Commit cfd303d

Browse files
committed
fix for windows
1 parent 99edc2d commit cfd303d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/session.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,17 @@ static std::string http_get(const std::string& url, const std::string& auth = ""
1717
curl_easy_setopt(c, CURLOPT_WRITEFUNCTION, curl_cb);
1818
curl_easy_setopt(c, CURLOPT_WRITEDATA, &resp);
1919
curl_easy_setopt(c, CURLOPT_TIMEOUT, 10L);
20+
#ifdef _WIN32
21+
// On Windows the deployed binary is outside the MSYS2 tree, so
22+
// OpenSSL cannot find a CA bundle. CURLSSLOPT_NATIVE_CA (curl
23+
// 8.2.0+) tells curl to fall back to the Windows certificate store.
24+
#ifdef CURLSSLOPT_NATIVE_CA
25+
curl_easy_setopt(c, CURLOPT_SSL_OPTIONS, (long)CURLSSLOPT_NATIVE_CA);
26+
#else
27+
// Older curl: try a bundled cacert.pem next to the executable
28+
curl_easy_setopt(c, CURLOPT_CAINFO, "cacert.pem");
29+
#endif
30+
#endif
2031
struct curl_slist* hdrs = nullptr;
2132
if (!auth.empty()) { hdrs = curl_slist_append(hdrs, ("Authorization: " + auth).c_str()); curl_easy_setopt(c, CURLOPT_HTTPHEADER, hdrs); }
2233
CURLcode rc = curl_easy_perform(c); long code = 0; curl_easy_getinfo(c, CURLINFO_RESPONSE_CODE, &code);

0 commit comments

Comments
 (0)