Reputation: 77
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
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