gpt4 book ai didi

ssl - curl 中 --cacert 和 --capath 的区别?

转载 作者:太空宇宙 更新时间:2023-11-03 12:38:12 28 4
gpt4 key购买 nike

什么时候使用 --cacert 选项与 curl(即 CLI)中的 --capath 选项。

--cacert 似乎引用了包含多个 PEM 的整体文件。假设它通过扫描找到匹配的主机名?

--capath 似乎引用了多个文件所在的目录。 curl 是否选择适当的证书作为其中的文件名?

最佳答案

来自docs :

--cacert (HTTPS) Tells curl to use the specified certificate file to verify the peer. The file may contain multiple CA certificates. The certificate(s) must be in PEM format. If this option is used several times, the last one will be used.

--capath (HTTPS) Tells curl to use the specified certificate directory to verify the peer. The certificates must be in PEM format, and the directory must have been processed using the c_rehash utility supplied with openssl. Certificate directories are not supported under Windows (because c_rehash uses symbolink links to create them). Using --capath can allow curl to make https connections much more efficiently than using --cacert if the --cacert file contains many CA certificates. If this option is used several times, the last one will be used.

因此,如果您指定 --cacert,CA 证书将存储在指定的文件中。这些 CA 证书用于验证 cURL 连接到的远程服务器的证书。

--capath 选项用于指定包含 CA 证书的目录而不是单个文件。 c_rehash 实用程序应该用于准备目录,即创建必要的链接。使用 --capath 的主要好处似乎是它比--cacert 单文件方法,如果您有许多 CA 证书。

这是一个可能执行 c_rehash 功能的脚本:

for file in *.pem; do ln -s $file `openssl x509 -hash -noout -in $file`.0; done

对于这两个选项,您应该小心只包含来自您信任的 CA 的 CA 证书。例如,如果您知道应该始终向远程服务器颁发来自 YourCompanyCA 的证书,那么这是您应该包含的唯一 CA 证书。

关于ssl - curl 中 --cacert 和 --capath 的区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9879688/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com