【libcurl】CURLOPT_CAPATH CURLOPT_CAINFO

     CURLOPT_CAPATH:
    If you have a CA cert for the server stored someplace else than in the
     * default bundle, then the CURLOPT_CAPATH option might come handy for
     * you.

https://curl.haxx.se/libcurl/c/CURLOPT_SSL_VERIFYPEER.html

CURLOPT_CAPATH explained

Related:
easy options
getinfo options
multi options
API overview
File a bug about this page
View man page source

NAME

CURLOPT_CAPATH - specify directory holding CA certificates

SYNOPSIS

#include <curl/curl.h>

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

DESCRIPTION

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 option.

The CURLOPT_CAPATH 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

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

CURLOPT_CAINFO(3), CURLOPT_STDERR(3), CURLOPT_DEBUGFUNCTION(3),

 

CURLOPT_CAINFO explained

Related:
easy options
getinfo options
multi options
API overview
File a bug about this page
View man page source

NAME

CURLOPT_CAINFO - path to Certificate Authority (CA) bundle

SYNOPSIS

#include <curl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CAINFO, char *path);

DESCRIPTION

Pass a char * to a null-terminated string naming a file holding one or more certificates to verify the peer with.

If CURLOPT_SSL_VERIFYPEER is zero and you avoid verifying the server's certificate, CURLOPT_CAINFO need not even indicate an accessible file.

This option is by default set to the system path where libcurl's cacert bundle is assumed to be stored, as established at build time.

If curl is built against the NSS SSL library, the NSS PEM PKCS#11 module (libnsspem.so) needs to be available for this option to work properly. Starting with curl-7.55.0, if both CURLOPT_CAINFO and CURLOPT_CAPATH are unset, NSS-linked libcurl tries to load libnssckbi.so, which contains a more comprehensive set of trust information than supported by nss-pem, because libnssckbi.so also includes information about distrusted certificates.

(iOS and macOS) When curl uses Secure Transport this option is supported. If the option is not set, then curl will use the certificates in the system and user Keychain to verify the peer.

(Schannel) This option is supported for Schannel in Windows 7 or later but we recommend not using it until Windows 8 since it works better starting then. If the option is not set, then curl will use the certificates in the Windows' store of root certificates (the default for Schannel).

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

DEFAULT

Built-in system specific. When curl is built with Secure Transport or Schannel, this option is not set by default.

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_CAINFO, "/etc/certs/cabundle.pem");
  ret = curl_easy_perform(curl);
  curl_easy_cleanup(curl);
}

AVAILABILITY

For the SSL engines that don't support certificate files the CURLOPT_CAINFO option is ignored. Schannel support added in libcurl 7.60.

RETURN VALUE

Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or CURLE_OUT_OF_MEMORY if there was insufficient heap space.

SEE ALSO

CURLOPT_CAPATH(3), CURLOPT_SSL_VERIFYPEER(3), CURLOPT_SSL_VERIFYHOST(3),

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值