我得到以下错误使用卷曲:

curl: (77) error setting certificate verify locations:
  CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: none

如何设置证书验证位置?


当前回答

我在Ubuntu 20.04 localhost上试图访问运行在docker容器中的elasticsearch时遇到了这个curl 77问题。集装箱启动后:

Check curl without ssl: curl --cacert http_ca.crt -u elastic https://localhost:9200 -k lowercase -k for insecure connection. Check curl configs: curl-config --configure, noticed what is ca-bundle: --with-ca-bundle=/etc/ssl/certs/ca-certificates.crt. Copy http_ca.crt file from container to:/usr/local/share/ca-certificates/, original command is here. Run update on ca-certificates: sudo update-ca-certificates. Run curl: curl -u elastic:<password> https://localhost:9201. Finally got response with "tagline" : "You Know, for Search".

将<password>修改为运行Docker Image时生成的密码。 还要注意,在我的机器上,弹性是在端口9201上启动的(不知道为什么:sudo ss -tlpn | grep 9200给我什么都没有),我已经找到了端口:sudo netstat -ntlp和程序名称是docker-proxy。

其他回答

只要找到适合我的解决方案。

echo’cacert = / etc / ssl / certs / ca-certificates。欧洲委员会

我从这里找到了解

把这个放到你的。bashrc中

# fix CURL certificates path
export CURL_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt

(见罗伯特的评论)

我也有同样的问题。事实证明,我的/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 

这对我很有效

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修改权限

我也有这个问题。我的问题是这个文件:

/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