Skip to content

Instantly share code, notes, and snippets.

@brandonweeks
Created June 4, 2021 00:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brandonweeks/6eb5d668b93d19f6e06022497d6fe232 to your computer and use it in GitHub Desktop.
Save brandonweeks/6eb5d668b93d19f6e06022497d6fe232 to your computer and use it in GitHub Desktop.
An example of how to use libcurl with a client certificate on Windows
#include <iostream>
#include "curl/curl.h"
int main()
{
CURL* req = curl_easy_init();
CURLcode res;
if (req)
{
curl_easy_setopt(req, CURLOPT_URL, "certauth.idrix.fr");
curl_easy_setopt(req, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(req, CURLOPT_SSLCERT, "LocalMachine\\MY\\ee91848df230cec6cd8ce5be2811379f2ae91005");
curl_easy_setopt(req, CURLOPT_VERBOSE, 1L);
res = curl_easy_perform(req);
if (res != CURLE_OK)
{
fprintf(stderr, "curl_easy_operation() failed : %s\n", curl_easy_strerror(res));
}
}
curl_easy_cleanup(req);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment