user3202934
user3202934

Reputation: 77

How to read Server Certificate using curl in C/C++

I have a requirement where I need to read the contents of the certificate that the server (say gmail.com) sends to me. I am using Curl in C.

Please let me know how to do this.

Upvotes: 1

Views: 2195

Answers (1)

AndreyM
AndreyM

Reputation: 17

libcurl provides curl_easy_getinfo() function with that can be used with CURLINFO_CERTINFO argument to read information about certificates returned by the HTTPS server. See this page for more information about the mentioned function.

This page shows a simple example (certificate.c file) how to print information about certificates.

If you need to work with content of the certificate(s), you probably need to extract the content between "-----BEGIN CERTIFICATE-----" and "-----END CERTIFICATE-----" markers.

Upvotes: 2

Related Questions