我使用curl得到以下错误:
curl: (77) error setting certificate verify locations: CAfile: /etc/ssl/certs/ca-certificates.crt CApath: none
如何设置此证书验证位置?谢谢.
Sco*_*ons 147
我还安装了最新版本的ca-certificates,但仍然收到错误:
curl: (77) error setting certificate verify locations:
CAfile: /etc/pki/tls/certs/ca-bundle.crt
CApath: none
Run Code Online (Sandbox Code Playgroud)
问题是卷曲期望证书在路径上/etc/pki/tls/certs/ca-bundle.crt但是找不到它,因为它在路径上/etc/ssl/certs/ca-certificates.crt.
通过运行将我的证书复制到预期目标
sudo cp /etc/ssl/certs/ca-certificates.crt /etc/pki/tls/certs/ca-bundle.crt
Run Code Online (Sandbox Code Playgroud)
为我工作.如果目标目标不存在,则需要为目标目标创建文件夹
sudo mkdir -p /etc/pki/tls/certs
Run Code Online (Sandbox Code Playgroud)
如果需要,修改上面的命令以使目标文件名与curl期望的路径匹配,即替换/etc/pki/tls/certs/ca-bundle.crt为错误消息中"CAfile:"后面的路径.
Yau*_*ich 80
把它放进你的 .bashrc
# fix CURL certificates path
export CURL_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt
Run Code Online (Sandbox Code Playgroud)
(见Robert的评论)
Rub*_*zzo 72
此错误与缺少的包有关:ca-certificates.安装它.
在Ubuntu Linux(和类似的发行版)中:
# apt-get install ca-certificates
Run Code Online (Sandbox Code Playgroud)
在CygWin通过Apt-Cyg
# apt-cyg install ca-certificates
Run Code Online (Sandbox Code Playgroud)
在Arch Linux(Raspberry Pi)中
# pacman -S ca-certificates
Run Code Online (Sandbox Code Playgroud)
文档告诉:
此程序包包含CA证书的PEM文件,以允许基于SSL的应用程序检查SSL连接的真实性.
如下所示:Debian - squeeze中包ca-certificates的详细信息
pra*_*esh 28
创建~/.curlrc包含以下内容的文件
cacert=/etc/ssl/certs/ca-certificates.crt
Run Code Online (Sandbox Code Playgroud)
10g*_*tic 18
解决错误的最快方法是在curl请求中的某处添加-k选项.该选项"允许连接到没有证书的SSL引用".(来自curl --help)
请注意,这可能意味着您没有与您认为自己所在的终端进行通信,因为他们提供的证书并非由您信任的CA签署.
例如:
$ curl -o /usr/bin/apt-cyg https://raw.github.com/cfg/apt-cyg/master/apt-cyg
Run Code Online (Sandbox Code Playgroud)
给了我以下错误回复:
curl: (77) error setting certificate verify locations:
CAfile: /usr/ssl/certs/ca-bundle.crt
CApath: none
Run Code Online (Sandbox Code Playgroud)
我在-k上添加了:
curl -o /usr/bin/apt-cyg https://raw.github.com/cfg/apt-cyg/master/apt-cyg -k
Run Code Online (Sandbox Code Playgroud)
并没有错误信息.作为奖励,现在我安装了apt-cyg.和ca证书.
Har*_*ath 13
@roens是正确的.这会影响所有Anaconda用户,并出现以下错误
curl: (77) error setting certificate verify locations:
CAfile: /etc/pki/tls/certs/ca-bundle.crt
CApath: none
解决方法是使用默认的系统卷曲并避免弄乱前面的Anaconda PATH变量.你也可以
重命名Anaconda curl二进制文件:)
mv /path/to/anaconda/bin/curl /path/to/anaconda/bin/curl_anaconda
或删除Anaconda卷曲
conda remove curl
$ which curl
/usr/bin/curl
[0] Anaconda Ubuntu curl Github问题 https://github.com/conda/conda-recipes/issues/352
Mic*_*tan 13
如果有人仍然遇到问题,请尝试这个,它对我有用。删除目录中的文件/etc/ssl/certs/,然后重新安装 ca 证书:
sudo apt install ca-certificates --reinstall
Run Code Online (Sandbox Code Playgroud)
当我尝试安装 Linuxbrew 时就是这样做的。
小智 12
来自$ 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.
Run Code Online (Sandbox Code Playgroud)
我有同样的问题。事实证明,我的/etc/ssl/certs/ca-certificates.crt文件格式错误。最后一个条目显示如下:
-----BEGIN CERTIFICATE-----
MIIEDTCCAvWgAwIBAgIJAN..lots of certificate text....AwIBAgIJAN-----END CERTIFICATE-----
Run Code Online (Sandbox Code Playgroud)
在之前添加换行符后-----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
Run Code Online (Sandbox Code Playgroud)
小智 6
这对我有用
sudo apt-get install ca-certificates
Run Code Online (Sandbox Code Playgroud)
然后进入证书文件夹
sudo cd /etc/ssl/certs
Run Code Online (Sandbox Code Playgroud)
然后你将ca-certificates.crt文件复制到 /etc/pki/tls/certs
sudo cp ca-certificates.crt /etc/pki/tls/certs
Run Code Online (Sandbox Code Playgroud)
解决此问题的另一种方法是禁用证书验证:
echo insecure >> ~/.curlrc
Run Code Online (Sandbox Code Playgroud)
curlSSL默认执行证书验证,使用“捆绑”Certificate Authority (CA)公钥(CA 证书)。默认包名为 curl-ca-bundle.crt;您可以使用 --cacert 选项指定备用文件。
如果此HTTPS服务器使用由捆绑中表示的 CA 签名的证书,则证书验证可能会因证书问题而失败(它可能已过期,或者名称可能与 URL 中的域名不匹配)。
如果您想关闭 curl 对证书的验证,请使用 -k(或--insecure)选项。
例如
curl --insecure http://........
Run Code Online (Sandbox Code Playgroud)
对于在Windows上运行在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
Run Code Online (Sandbox Code Playgroud)
然后复制到文件https://curl.haxx.se/ca/cacert.pem并重命名为curl-ca-bundle.crt并将其放在\ xampp路径下(我无法使curl.capath工作) .我还发现cURL站点上的CAbundle对于我连接的远程站点来说还不够,所以在http://winampplugins.co.uk上使用了一个预编译的Windows版本的curl 7.47.1 . /卷曲/
| 归档时间: |
|
| 查看次数: |
174602 次 |
| 最近记录: |