CURLOPT_CAINFO(3)
π CURLOPT_CAINFO β like, the whole manual, but make it make sense
okay bestie so this is CURLOPT_CAINFO(3) from the Library Functions Manual, and it's genuinely one of those options you need to know if you're doing anything TLS. sit down, grab a strawberry drink π, and let me tell you about the file that holds your certificates β¨
β¨ NAME β¨
CURLOPT_CAINFO β literally the path to your Certificate Authority (CA) bundle π
πΈ SYNOPSIS πΈ
#include <curl/curl.h>
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CAINFO, char *path);
that's it. that's the whole vibe. you hand it a char * and it slays π
π¦ DESCRIPTION π¦
So you pass a char pointer to a null-terminated string that names a file β and that file is holding one or more certificates that you're gonna use to verify the peer with. that's the whole job, no cap π₯
now here's the little loophole π: if CURLOPT_SSL_VERIFYPEER(3) is zero and you're avoiding verifying the server's certificate anyway, then CURLOPT_CAINFO(3) doesn't even have to point at an accessible file. like, it can be pointing at nothing, bestie, because you already decided not to verify. do with that what you will π
by default this option is set to the system path where libcurl's CA certificate bundle is assumed to be stored β and that path was established at build time. so it's not magic, it's just... pre-agreed, iykyk.
(Schannel) okay Windows girlies listen up π«Ά β this option is supported for Schannel on Windows 7 or later, but we genuinely recommend not using it until Windows 8, since it works better starting then. and if the option is not set, curl just uses the certificates in the Windows' store of root certificates (that's the default for Schannel). iconic of it honestly π
the application does not have to keep the string around after setting this option. it doesn't need to babysit it, it's fine, it's independent now π§
if you use this option multiple times, the last set string overrides the previous ones. and if you set it to NULL, you disable its use again. so yes, you can undo it. slay.
and if you ever wanna know what the default value actually is, you can figure it out with CURLINFO_CAINFO(3) β that's literally what it's for β
π DEFAULT π
Built-in system specific. and when curl is built with Schannel, this option is not set by default π
π PROTOCOLS π
this functionality affects all TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. β etc!! the whole squad π
and good news: all TLS backends support this option. every single one. no backend erasure here π
π EXAMPLE π
here's the whole thing in action, don't touch the code, it's perfect:
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
curl_easy_setopt(curl, CURLOPT_CAINFO, "/etc/certs/cabundle.pem");
curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
}
the way that "/etc/certs/cabundle.pem" is just sitting there being the whole point of the page ππ«Ά
π§ HISTORY π§
Schannel support was added in libcurl 7.60. periodt.
β AVAILABILITY β
Added in curl 7.4.2 β yes, that's old old, it's been around forever, main character energy since day one π
π RETURN VALUE π
curl_easy_setopt(3) returns a CURLcode indicating success or error.
CURLE_OK(0) means everything was OK β the good ending πΈ- non-zero means an error occurred β and you can go look it up in
libcurl-errors(3)π
π₯ SEE ALSO π₯
CURLINFO_CAINFO(3)CURLOPT_CAINFO_BLOB(3)CURLOPT_CAPATH(3)CURLOPT_CA_CACHE_TIMEOUT(3)CURLOPT_SSL_VERIFYHOST(3)CURLOPT_SSL_VERIFYPEER(3)
all bangers, read them all, no skips π
ngl the takeaway is: give curl a path to your CA bundle, don't overthink it, and if you're on Schannel just... wait for Windows 8. trust π«Ά
and that's the page!! brought to you by libcurl, dated 2026-10-12, filed under CURLOPT_CAINFO(3) πβ¨ go forth and verify your peers, bestie π
π¦ where this page comes from
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms