我得到以下错误使用卷曲:
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
如何设置证书验证位置?
当前回答
另一个解决这个问题的方法是禁用证书验证:
echo insecure >> ~/.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.
我也有同样的问题。事实证明,我的/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
我还安装了最新版本的ca-certificates,但仍然出现错误:
curl: (77) error setting certificate verify locations:
CAfile: /etc/pki/tls/certs/ca-bundle.crt
CApath: none
问题是curl希望证书位于/etc/pki/tls/certs/ca-bundle.路径下但是无法找到它,因为它位于/etc/ssl/certs/ca-certificates.crt路径下。
通过运行将我的证书复制到预期的目的地
sudo cp /etc/ssl/certs/ca-certificates.crt /etc/pki/tls/certs/ca-bundle.crt
为我工作。如果目标目的地不存在文件夹,则需要运行命令为其创建文件夹
sudo mkdir -p /etc/pki/tls/certs
如果需要,修改上面的命令,使目标文件名与curl期望的路径匹配,即替换/etc/pki/tls/certs/ca-bundle.在错误消息中使用“CAfile:”后面的路径。
这对我很有效
sudo apt-get install ca-certificates
然后进入证书文件夹
sudo cd /etc/ssl/certs
然后复制ca-certificates。CRT文件进入/etc/pki/tls/certs
sudo cp ca-certificates.crt /etc/pki/tls/certs
如果没有“tls/certs”文件夹,请创建一个“tls/certs”文件夹,并使用chmod 777 -R folderNAME修改权限