CURLINFO_CAINFO(3)

πŸ’… CURLINFO_CAINFO β€” ok so this is your built-in CA cert path bestie

Hey bestie, welcome to the CURLINFO_CAINFO page, from the Library Functions Manual era of libcurl. This little cutie is the default built-in CA certificate path getter, and honestly? Underrated. Let's get into it πŸŽ€

✨ SYNOPSIS ✨

#include <curl/curl.h>

CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_CAINFO, char **path);

πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so picture this: you pass in a pointer to a char pointer, right? And libcurl fills it with a pointer to a null-terminated string β€” that string holds the default built-in path that gets used for the CURLOPT_CAINFO(3) option, unless the user goes and sets it themselves. Very "here's the default, do with it what you will" energy πŸ’…

⚠️ Now pay attention because this is the plot twist: if libcurl was built to support multiple TLS libraries, this option might return a string even if the specific TLS library currently set to be used does not support CURLOPT_CAINFO(3). Like, the string shows up anyway. Awkward but true. 😭

Also important, bestie: this is a path identifying a single file containing CA certificates. One file. Not a directory vibe. πŸ—‚οΈ

And if there's just no default path at all? The path pointer gets set to NULL. Nothing. Nada. πŸ«₯

🌸 PROTOCOLS 🌸

This functionality affects all TLS based protocols β€” and I mean all of them, slay:

  • HTTPS
  • FTPS
  • IMAPS
  • POP3S
  • SMTPS
  • etc. (yes, the "etc." is doing a lot of heavy lifting here and we love her for it πŸ’œ)

And the best part? All TLS backends support this option. Every single one. No gatekeeping. Periodt. πŸ‘‘

🧚 EXAMPLE 🧚

Look at this little guy go β€” icon behavior, honestly:

int main(void)
{
  CURL *curl = curl_easy_init();
  if(curl) {
    char *cainfo = NULL;
    curl_easy_getinfo(curl, CURLINFO_CAINFO, &cainfo);
    if(cainfo) {
      printf("default ca info path: %s\n", cainfo);
    }
    curl_easy_cleanup(curl);
  }
}

Note the if(cainfo) check β€” because like we said, it could be NULL, and we are not about to printf a null pointer in this house πŸ™ˆ

⭐ AVAILABILITY ⭐

Added in curl 7.84.0 πŸŽ€ (so if you're on something ancient, this is your sign to update, ngl)

πŸ’€ RETURN VALUE πŸ’€

curl_easy_getinfo(3) returns a CURLcode telling you success or error. Groundbreaking, I know.

  • CURLE_OK (0) β€” everything was OK, we ate, no crumbs left πŸ“
  • non-zero β€” an error occurred 😭 see libcurl-errors(3) for the full lore

πŸ‘‘ SEE ALSO πŸ‘‘

Go read these too, they're all connected, iykyk:


✨ and that's the whole page, bestie ✨ this was libcurl, dated 2026-10-12, sitting pretty under the CURLINFO_CAINFO(3) title. go forth and fetch your CA info responsibly πŸ«ΆπŸ’–

πŸ“¦ where this page comes from