我可以通过使用ssh的克隆项目推送,但它不工作时,我克隆项目与https。

它显示的错误信息是:

server certificate verification failed. CAfile: /etc/ssl/certs/cacertificates.crt CRLfile: none

当前回答

基于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

其他回答

sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates -y 
sudo update-ca-certificates

对我有用。

当我试图在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/

基于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

检查你的系统时钟,

美元的日期

如果不正确,证书检查将失败。要纠正系统时钟,

安装NTP

时钟应该自动同步。

最后再次输入clone命令。

我知道这是旧的,但有时错误再次弹出。如果您确信可以信任本地安装,那么只需在变量部分中添加:GIT_SSL_NO_VERIFY: "true"。通过这种方式,您只需禁用证书验证。

此解决方案与本文提出的解决方案类似,但它仅适用于当前git树,而不适用于全局git配置。