GNURLINFO_CERTINFO(3)

πŸ“¦ version 7.72.0, in nixos 26.05, nixpkgs unstable

πŸ’– NAME πŸ’–

okay bestie, welcome to the GNURLINFO_CERTINFO(3) page β€” this is the curl_easy_getinfo options corner, and today’s main character is CURLINFO_CERTINFO, aka get the TLS certificate chain. periodt. πŸ’…

✨ SYNOPSIS ✨

       #include <gnurl/curl.h>

       CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_CERTINFO,
                                  struct curl_certinfo **chainp);

πŸŽ€ DESCRIPTION πŸŽ€

So here’s the vibe: you pass a pointer to a struct curl_certinfo * and you’ll get it set to point to a struct that holds a number of linked lists with info about the certificate chain β€” assuming you had CURLOPT_CERTINFO(3) enabled when the request was made. The struct reports how many certs it found, and then you can extract info for each of those certs by following the linked lists. The info chain is provided in a series of data in the format "name:content" where the content is for the specific named data. Also go peek at the certinfo.c example, iykyk. πŸ¦‹

🌈 PROTOCOLS 🌈

All TLS-based. That’s it, that’s the protocol tea. πŸ’…

πŸ”₯ EXAMPLE πŸ”₯

       curl = curl_easy_init();
       if(curl) {
         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);

         res = curl_easy_perform(curl);

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

           if (!res) {
             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);
       }

⭐ AVAILABILITY ⭐

This option is only working in libcurl built with OpenSSL, NSS, Schannel or GSKit support. Schannel support added in 7.50.0. Added in 7.19.1. slay. ✨

πŸ’€ RETURN VALUE πŸ’€

Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. no cap. 🫢

πŸ‘‘ SEE ALSO πŸ‘‘


xoxo, your Unix bestie πŸ’– β€” this GNURLINFO_CERTINFO(3) page is from libcurl 7.44.0, dated 12 Sep 2015. mwah. πŸŽ€

πŸ“¦ where this page comes from