Ntokozo
Ntokozo

Reputation: 21

C++ libcurl: schannel: Failed to import cert file cert.cer, last error is 0x80092002

I'm using libcurl libraries to call a rest endpoint and it fails on pulling the self signed cert with the error: schannel: Failed to import cert file sit.cer, last error is 0x80092002.

I'm not really that well versed on c++

curl_easy_setopt(curl, CURLOPT_CAINFO, "cacert.pem");
curl_easy_setopt(curl, CURLOPT_SSLCERT, "sit.crt");
curl_easy_setopt(curl, CURLOPT_SSLKEY, "sit.key");
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);

I am really stuck on this, please help.

Upvotes: 2

Views: 24538

Answers (3)

RamWill
RamWill

Reputation: 318

I received this error due to the windows 10 update in January 2022. Due to a security vulnerabilty they upgraded the version of curl from 7.55.1 to 7.79.1.

My previous curl commands that worked on 7.55.1 stopped working on 7.79.1 and gave me the same error as you. So in the interest of time I had to install a previous version of curl and amend my environment variable path to this previous version which resolved the error.

Upvotes: 2

Renis1235
Renis1235

Reputation: 4700

I had exactly the same problem. My Requests would work everywhere except through libcurl in c++. At first I thought that libcurl could not parse my generated certificates. I generated them through openssl in windows. And they worked everywhere (even through curl in command line).

What solved it was building and importing the libcurl with the openssl option.

I use vcpkg to handle my packages, so this is how I installed what was needed.

  1. ./vcpkg.exe install curl
  2. ./vcpkg.exe install curl[openssl] --recurse
  3. ./vcpkg.exe integrate install

After this, everything worked.

Upvotes: 0

peter
peter

Reputation: 11

The error means that the option CURLOPT_SSLCERT can not handle the given certificate (type): For schannel you should provide certificates as described here: https://curl.se/libcurl/c/CURLOPT_SSLCERT.html

Upvotes: 1

Related Questions