我得到以下错误使用卷曲:
curl: (77) error setting certificate verify locations: CAfile: /etc/ssl/certs/ca-certificates.crt CApath: none
如何设置证书验证位置?
我得到以下错误使用卷曲:
curl: (77) error setting certificate verify locations: CAfile: /etc/ssl/certs/ca-certificates.crt CApath: none
如何设置证书验证位置?
当前回答
创建一个文件~/。使用以下内容进行Curlrc
cacert=/etc/ssl/certs/ca-certificates.crt
如下
echo "cacert=/etc/ssl/certs/ca-certificates.crt" >> ~/.curlrc
其他回答
似乎您的卷曲指向一个不存在的文件与CA证书或类似。
有关CA certs与curl的主要参考,请参见:https://curl.haxx.se/docs/sslcerts.html
从$ man curl:
--cert-type <type>
(SSL) Tells curl what certificate type the provided certificate
is in. PEM, DER and ENG are recognized types. If not specified,
PEM is assumed.
If this option is used several times, the last one will be used.
--cacert <CA certificate>
(SSL) 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. Normally curl is built to
use a default file for this, so this option is typically used to
alter that default file.
对于在XAMPP上运行的PHP代码,我发现我需要编辑PHP .ini以包括以下内容
[curl]
; A default value for the CURLOPT_CAINFO option. This is required to be an
; absolute path.
curl.cainfo = curl-ca-bundle.crt
然后复制到一个文件https://curl.haxx.se/ca/cacert.pem并重命名为curl-ca-bundle。crt并将其放置在\xampp路径下(我无法获得curl。卡帕特工作)。我还发现cURL站点上的CAbundle对于我正在连接的远程站点来说是不够的,所以使用了http://winampplugins.co.uk/curl/上列出的预编译的Windows版本的cURL 7.47.1
我也有这个问题。我的问题是这个文件:
/usr/ssl/certs/ca-bundle.crt
默认情况下只是一个空文件。因此,即使它存在,您仍然会得到错误,因为它不包含任何证书。你可以像这样生成它们:
p11-kit extract --overwrite --format pem-bundle /usr/ssl/certs/ca-bundle.crt
https://github.com/msys2/MSYS2-packages/blob/master/ca-certificates/ca-certificates.install
curl默认使用“bundle”执行SSL证书验证 的证书颁发机构公钥(CA certs)。默认的 Bundle名为curl-ca-bundle.crt;您可以指定一个备用文件 使用——cacert选项。
如果此HTTPS服务器使用由中表示的CA签名的证书 ,证书验证可能失败,由于 证书的问题(它可能过期了,或者名称可能过期了 不匹配URL中的域名)。
如果您想关闭curl对证书的验证,请使用 -k(或——insecure)选项。
例如
curl --insecure http://........