CURLOPT_CERTINFO(3)

πŸ’… CURLOPT_CERTINFO(3) β€” the libcurl girlies' guide ✨

Okay so bestie, you're reading a page from the libcurl manual β€” CURLOPT_CERTINFO(3), to be exact πŸŽ€ β€” and honestly? It's a good one. Let's get into it.


🌸 NAME 🌸

CURLOPT_CERTINFO β€” the option where you're literally asking for SSL certificate information πŸ¦‹

✨ SYNOPSIS ✨

#include <curl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CERTINFO, long certinfo);

πŸ’– DESCRIPTION πŸ’–

So here's the vibe: you pass a long set to 1 to turn on libcurl's certificate chain info gatherer πŸ‘‘. Like, you're telling it "girl, go collect the lore."

With this enabled, libcurl extracts lots of information and data about the certificates in the certificate chain used in the SSL connection πŸ”₯. It's giving detective energy, no cap.

Then, after the transfer is done, you can pull all that data back out using curl_easy_getinfo(3) and its option CURLINFO_CERTINFO(3) 🫢. The way that it's a two-step situation β€” first you set it, then you get it β€” iykyk.

πŸŽ€ DEFAULT πŸŽ€

0

(Yeah. Off. Not doing the thing. As it should be πŸ’…)

🌈 PROTOCOLS 🌈

This functionality affects all TLS based protocols, bestie β€” so we're talking HTTPS, FTPS, IMAPS, POP3S, SMTPS, etc. ⭐ The whole TLS friend group.

Heads up though: this option works only with the following TLS backends β€” GnuTLS, OpenSSL, Rustls and Schannel πŸ™ˆ. Everyone else is not invited to this particular party.

🧚 EXAMPLE 🧚

Okay this is the part where we actually do it. Look at her go:

int main(void)
{
  CURL *curl = curl_easy_init();
  if(curl) {
    CURLcode result;
    curl_easy_setopt(curl, CURLOPT_URL, "https://www.example.com/");

    /* connect to any HTTPS site, trusted or not */
    curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
    curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);

    curl_easy_setopt(curl, CURLOPT_CERTINFO, 1L);

    result = curl_easy_perform(curl);

    if(!result) {
      struct curl_certinfo *ci;
      result = curl_easy_getinfo(curl, CURLINFO_CERTINFO, &ci);

      if(!result) {
        int i;
        printf("%d certs!\n", ci->num_of_certs);

        for(i = 0; i < ci->num_of_certs; i++) {
          struct curl_slist *slist;

          for(slist = ci->certinfo[i]; slist; slist = slist->next)
            printf("%s\n", slist->data);
        }
      }
    }
    curl_easy_cleanup(curl);
  }
}

Note the comment in there β€” it connects to any HTTPS site, trusted or not 😭. That's the demo being a demo, bestie, don't ship that energy to prod.

πŸ¦‹ HISTORY πŸ¦‹

  • Schannel support added in 7.50.0 ✨
  • mbedTLS support added in 8.9.0 πŸ’œ

🌟 AVAILABILITY 🌟

Added in curl 7.19.1 β€” she's been iconic for a minute πŸ‘‘

πŸ”₯ RETURN VALUE πŸ”₯

curl_easy_setopt(3) returns a CURLcode indicating success or error, periodt.

CURLE_OK (0) means everything was OK πŸ’š. Non-zero means an error occurred β€” see libcurl-errors(3) for the whole breakdown.

πŸ’€ SEE ALSO πŸ’€


and that's the whole page, bestie 🫢 this cutie was brought to you by libcurl, dated 2026-10-12, and she's filed under CURLOPT_CERTINFO(3). go get those certs πŸ’…βœ¨

πŸ“¦ where this page comes from