Skip to content

Commit 5e1562f

Browse files
committed
On Windows use the operating system's native CA store for certificate verification of https requests.
- Updated included headers to support compilation on Windows (using Visual C++)
1 parent 039d953 commit 5e1562f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/utils/https_client.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,14 @@
2020
#include <curl/curl.h>
2121
#endif
2222

23+
#ifndef WIN32
2324
#include <sys/socket.h>
2425
#include <sys/types.h>
2526
#include <netinet/in.h>
2627
#include <arpa/inet.h>
28+
#else
29+
#include <winsock2.h>
30+
#endif
2731
#include <string>
2832

2933
#include <fstream>
@@ -94,6 +98,11 @@ bool HttpsClient::download(const std::string &uri) {
9498
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 1);
9599
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 1);
96100

101+
#ifdef WIN32
102+
/* use the operating system's native CA store for certificate verification.*/
103+
curl_easy_setopt(curl, CURLOPT_SSL_OPTIONS, (long)CURLSSLOPT_NATIVE_CA);
104+
#endif
105+
97106
/* send all data to this function */
98107
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &HttpsClient::handle);
99108

0 commit comments

Comments
 (0)