我可以通过使用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
当前回答
GIT_CURL_VERBOSE=1 git [clone|fetch]…
应该能告诉你问题在哪里。在我的例子中,这是因为cURL在基于NSS构建时不支持PEM证书,因为这种支持在NSS中不是主线(#726116 #804215 #402712等等)。
其他回答
TLDR:
hostname=XXX
port=443
trust_cert_file_location=`curl-config --ca`
sudo bash -c "echo -n | openssl s_client -showcerts -connect $hostname:$port -servername $hostname \
2>/dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' \
>> $trust_cert_file_location"
警告:正如gather的精彩回答中所指出的,这将添加所有证书,而不仅仅是根ca。 盲目地将所有(任何)证书添加到您的trustStore中而不进行尽职调查并不是最好的做法。
长回答
基本原因是您的计算机不相信对Gitlab服务器上使用的证书进行签名的证书颁发机构。这并不意味着证书是可疑的,但它可能是自签名的,也可能是由不在您的操作系统ca列表中的机构/公司签名的。要在计算机上规避这个问题,你必须告诉它信任这个证书——如果你没有任何理由怀疑它的话。
您需要检查gitLab服务器使用的web证书,并将其添加到</git_installation_folder>/bin/curl-ca-bundle.crt。
要检查克隆是否至少工作而不检查证书,您可以设置:
export GIT_SSL_NO_VERIFY=1
#or
git config --global http.sslverify false
但这只能用于测试,如“SSL适用于浏览器、wget和curl,但不适用于git”或这篇博文中所述。
检查你的GitLab设置,a在第4272期。
要获得证书(需要添加到curl-ca-bundle中)。CRT文件),输入a:
echo -n | openssl s_client -showcerts -connect yourserver.com:YourHttpsGitlabPort \
2>/dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p'
(“yourserver.com”是你的GitLab服务器名,yourhttpgitlabport是https端口,通常是443)
要查看CA(证书颁发机构颁发者),输入a:
echo -n | openssl s_client -showcerts -connect yourserver.com:YourHttpsGilabPort \
2>/dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' \
| openssl x509 -noout -text | grep "CA Issuers" | head -1
注意:Valeriy Katkov在评论中建议在openssl命令中添加-servername选项,否则在Valeriy的情况下,命令不会显示www.github.com的certificate。
Openssl s_client -showcerts -servername www.github.com -connect www.github.com:443
Findekano在评论中补充道:
来确定curl-ca-bundle的位置。Crt,你可以使用这个命令
curl-config --ca
此外,请参阅我最近的回答“github:服务器证书验证失败”:你可能必须重新安装这些证书:
sudo apt-get install --reinstall ca-certificates
sudo mkdir /usr/local/share/ca-certificates/cacert.org
sudo wget -P /usr/local/share/ca-certificates/cacert.org http://www.cacert.org/certs/root.crt http://www.cacert.org/certs/class3.crt
sudo update-ca-certificates
git config --global http.sslCAinfo /etc/ssl/certs/ca-certificates.crt
我知道已经有很多答案了。对于那些使用专用网络(如Zscaler等)的用户来说,如果需要更新rootcert,则可能会出现此错误。如果在Windows机器上使用WSL,这里有一个关于如何实现此更新的解决方案:
#!/usr/bin/bash
# I exported the Zscaler certifcate out of Microsoft Cert Manager. It was located under 'Trusted Root Certification > Certificates' as zscaler_cert.cer.
# Though the extension is '.cer' it really is a DER formatted file.
# I then copied that file into Ubuntu running in WSL.
# Convert DER encoded file to CRT.
openssl x509 -inform DER -in zscaler_cert.cer -out zscaler_cert.crt
# Move the CRT file to /usr/local/share/ca-certificates
sudo mv zscaler_cert.crt /usr/local/share/ca-certificates
# Inform Ubuntu of new cert.
sudo update-ca-certificates
导致这个问题的另一个原因可能是你的生物钟可能走错了。证书是时间敏感的。
查询当前系统时间。
date -R
您可以考虑安装NTP以从全局NTP池自动将系统时间与可信的internet时间服务器同步。例如,在Debian/Ubuntu上安装:
apt-get install ntp
也有同样的问题。由自己颁发的证书颁发机构引起。 通过在/usr/local/share/ca-certificates/中添加.pem文件解决 和调用
sudo update-ca-certificates
PS:“/share/ca-certificates”文件夹下的pem文件必须有扩展名。crt
当我试图在Dockerfile中克隆git时,我的工作是获取SSL证书并将其添加到本地证书列表:
openssl s_client -showcerts -servername git.mycompany.com -connect git.mycompany.com:443 </dev/null 2>/dev/null | sed -n -e '/BEGIN\ CERTIFICATE/,/END\ CERTIFICATE/ p' > git-mycompany-com.pem
cat git-mycompany-com.pem | sudo tee -a /etc/ssl/certs/ca-certificates.crt
学分:https://fabianlee.org/2019/01/28/git-client-error-server-certificate-verification-failed/