GNURLOPT_CAPATH(3)

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

✨ GNURLOPT_CAPATH(3) ✨

bestie, welcome to the curl_easy_setopt options manual page β€” this one's all about pointing curl at a whole directory of CA certificates. πŸŽ€

🌸 NAME 🌸

CURLOPT_CAPATH β€” specify directory holding CA certificates.

πŸ¦‹ SYNOPSIS πŸ¦‹

#include <gnurl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CAPATH, char *capath);

πŸ’… DESCRIPTION πŸ’…

Okay so the move is: pass a char * to a null-terminated string naming a directory holding multiple CA certificates to verify the peer with. If libcurl is built against OpenSSL, the certificate directory must be prepared using the openssl c_rehash utility. This makes sense only when used in combination with the CURLOPT_SSL_VERIFYPEER(3) option.

⚠️ heads up: the CURLOPT_CAPATH(3) function apparently does not work in Windows due to some limitation in openssl. 😭

The application does not have to keep the string around after setting this option. 🫢

πŸŽ€ DEFAULT πŸŽ€

NULL β€” that's the default, no cap. πŸ’…

🌈 PROTOCOLS 🌈

All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. ✨

πŸ“ EXAMPLE πŸ“

CURL *curl = curl_easy_init();
if(curl) {
  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
  curl_easy_setopt(curl, CURLOPT_CAPATH, "/etc/cert-dir");
  ret = curl_easy_perform(curl);
  curl_easy_cleanup(curl);
}

🧚 AVAILABILITY 🧚

This option is supported by the OpenSSL, GnuTLS and mbedTLS (since 7.56.0) backends. The NSS backend provides the option only for backward compatibility.

πŸ‘‘ RETURN VALUE πŸ‘‘

CURLE_OK if supported; or an error such as:

  • CURLE_NOT_BUILT_IN β€” Not supported by the SSL backend
  • CURLE_UNKNOWN_OPTION
  • CURLE_OUT_OF_MEMORY

πŸ”₯ SEE ALSO πŸ”₯


source/version: libcurl 7.37.0 Β· date: 17 Jun 2014 Β· page: GNURLOPT_CAPATH(3) πŸ’–βœ¨

πŸ“¦ where this page comes from