我得到以下错误使用卷曲:
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
如何设置证书验证位置?
当前回答
我也有同样的问题。事实证明,我的/etc/ssl/certs/ca-certificates。CRT文件格式不正确。最后一个条目是这样的:
-----BEGIN CERTIFICATE-----
MIIEDTCCAvWgAwIBAgIJAN..lots of certificate text....AwIBAgIJAN-----END CERTIFICATE-----
在-----END CERTIFICATE-----前添加换行符后,curl就可以处理证书文件了。
这是非常恼人的发现,因为我的update-ca-certificates命令没有给我任何警告。
这可能是也可能不是一个特定版本的curl问题,所以这里是我的版本,只是为了完整性:
curl --version
# curl 7.51.0 (x86_64-alpine-linux-musl) libcurl/7.51.0 OpenSSL/1.0.2j zlib/1.2.8 libssh2/1.7.0
# Protocols: dict file ftp ftps gopher http https imap imaps pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp
# Features: IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP UnixSockets
其他回答
解决这个错误的最快方法是在curl请求中添加-k选项。该选项“允许连接到SSL引用而不需要证书”。(来自curl—help)
请注意,这可能意味着您并没有与您认为您正在与之通信的端点通信,因为它们正在提供一个没有由您信任的CA签名的证书。
例如:
$ curl -o /usr/bin/apt-cyg https://raw.github.com/cfg/apt-cyg/master/apt-cyg
给我以下错误响应:
curl: (77) error setting certificate verify locations:
CAfile: /usr/ssl/certs/ca-bundle.crt
CApath: none
我加了-k
curl -o /usr/bin/apt-cyg https://raw.github.com/cfg/apt-cyg/master/apt-cyg -k
并且没有错误消息。作为奖励,现在我已经安装了apt-cyg。和ca证书。
此错误与缺少一个包有关:ca-certificates。安装它。
在Ubuntu Linux(以及类似的发行版)中:
# apt-get install ca-certificates
通过Apt-Cyg在CygWin中
# apt-cyg install ca-certificates
在Arch Linux下(树莓派)
# pacman -S ca-certificates
文档告诉我们:
该包包含CA证书的PEM文件,允许基于SSL的应用程序检查SSL连接的真实性。
在Debian——压缩包ca-certificates的详细信息
把这个放到你的。bashrc中
# fix CURL certificates path
export CURL_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt
(见罗伯特的评论)
我也有这个问题。我的问题是这个文件:
/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://........