我已经用OpenSSL为Windows OpenSSL构建了libcurl。如果我使用libcurl命令指定CA Info,如下所示,我可以通过https发布数据。
curl_easy_setopt(curl_handle, CURLOPT_CAINFO, "C:\\cacert.pem");
我的问题是在这里找到的“证书验证”标题下的选项3:https://curl.haxx.se/docs/sslcerts.html
3)将服务器的CA证书添加到现有的默认CA证书存储区。默认CA证书存储可以在编译时使用以下配置选项进行更改: -with- CA -bundle= file :使用指定的文件作为CA证书存储区。CA证书需要以PEM格式连接到此文件中。 -with- CA - path =path:使用指定的路径作为CA证书存储区。CA证书需要作为单独的PEM文件存储在此目录中。您可能需要在添加文件之后运行c_rehash。
这些设置是否仅适用于命令行,还是可以在编译时配置为始终使用相同的CA信息?
谢谢!
发布于 2018-01-25 01:42:14
这些设置是否仅适用于命令行,还是可以在编译时配置为始终使用相同的CA信息?
cURL具有相同的编译时设置。更准确地说,它们是Autotools选项。
curl-7.57.0$ ./configure --help
`configure' configures curl - to adapt to many kinds of systems.
Usage: ./configure [OPTION]... [VAR=VALUE]...
...
--with-ca-bundle=FILE Path to a file containing CA certificates (example:
/etc/ca-bundle.crt)
--without-ca-bundle Don't use a default CA bundle
--with-ca-path=DIRECTORY
Path to a directory containing CA certificates
stored individually, with their filenames in a hash
format. This option can be used with OpenSSL, GnuTLS
and PolarSSL backends. Refer to OpenSSL c_rehash for
details. (example: /etc/certificates)
--without-ca-path Don't use a default CA path
--with-ca-fallback Use the built in CA store of the SSL library
--without-ca-fallback Don't use the built in CA store of the SSL library我有时构建cURL是为了在CentOS 5这样的旧系统上进行测试,我发现下载一个更新的cacert.pem,然后使用--with-ca-bundle是最容易的。
如果您想使用--with-ca-path,那么这就是每个证书都被散列的地方。因此,您将有一个包含120或150个文件的目录。这些文件将有NNNNNNNN.0、NNNNNNNN.1等名称。NNNNNNNN将是一个散列,冲突通过递增后缀来解决。
我保留了在Build-ScrippsBuild-curl.sh网上构建Build-ScrippsBuild-curl.sh的脚本。
https://stackoverflow.com/questions/48433182
复制相似问题