我可以通过使用ssh的克隆项目推送,但它不工作时,我克隆项目与https。
它显示的错误信息是:
server certificate verification failed. CAfile: /etc/ssl/certs/cacertificates.crt CRLfile: none
我可以通过使用ssh的克隆项目推送,但它不工作时,我克隆项目与https。
它显示的错误信息是:
server certificate verification failed. CAfile: /etc/ssl/certs/cacertificates.crt CRLfile: none
当前回答
将证书和bundle复制到一个.crt文件中,并确保文件中的证书之间有一个空行。
在互联网上尝试了所有方法之后,我在GitLab服务器上使用了这个方法。
其他回答
我搞砸了我的CA文件,而我设置goagent代理。不能从github拉数据,并得到相同的警告:
服务器证书验证失败。CAfile: /etc/ssl/certs/ca-certificates。crt CRLfile:无
使用Vonc的方法,从github获取证书,并将其放入/etc/ssl/certs/ca-certificates。Crt,问题解决了。
echo -n | openssl s_client -showcerts -connect github.com:443 2>/dev/null | sed -ne '/- begin CERTIFICATE-/,/- end CERTIFICATE-/p'
基于VonC给出的非常好的答案,我刚刚创建了一个bash脚本,将缺失的x509证书安装到证书包中。它适用于基于debian的linux发行版。
#!/bin/bash
CERTIFICATE_PEM=certificate.pem
CERTIFICATE_CRT=certificate.crt
# get certificate
echo -n | openssl s_client -showcerts -connect gitlab.sehlat.io:443 \
2>/dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' \
> $CERTIFICATE_PEM
# format certificate from PEM (human-readable) to CRT
openssl x509 -in $CERTIFICATE_PEM -out $CERTIFICATE_CRT
# move it to ca-certificates folder & update the bundle file
sudo mv ./$CERTIFICATE_CRT /usr/local/share/ca-certificates/
sudo update-ca-certificates
# configuring git
git config --global http.sslCAinfo /etc/ssl/certs/ca-certificates.crt
我知道这是旧的,但有时错误再次弹出。如果您确信可以信任本地安装,那么只需在变量部分中添加:GIT_SSL_NO_VERIFY: "true"。通过这种方式,您只需禁用证书验证。
此解决方案与本文提出的解决方案类似,但它仅适用于当前git树,而不适用于全局git配置。
我在老旧的Ubuntu 16.04和GitLab上也遇到了同样的问题(其他电脑运行得很好)。
这个问题实际上是Git内部使用的旧版本的gnutls库。这个旧的库对服务器端的证书顺序很敏感——这个问题中有更多信息。最终的解决方案很简单:
apt-get update
apt-get upgrade libgnutls*
GIT_CURL_VERBOSE=1 git [clone|fetch]…
应该能告诉你问题在哪里。在我的例子中,这是因为cURL在基于NSS构建时不支持PEM证书,因为这种支持在NSS中不是主线(#726116 #804215 #402712等等)。