1

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.

user3202934
  • 77
  • 2
  • 9

1 Answers1

2

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.

AndreyM
  • 17
  • 5