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

它显示的错误信息是:

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

当前回答

或者简单地运行这个注释来添加服务器证书到你的数据库:

echo $(echo -n | openssl s_client -showcerts -connect yourserver.com:YourHttpGilabPort 2>/dev/null  | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p') >> /etc/ssl/certs/ca-certificates.crt

然后再做git克隆。

其他回答

最后,添加http。Sslverify到你的.git/config。

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
[remote "origin"]
    url = https://server/user/project.git
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
    remote = origin
    merge = refs/heads/master
[http]
        sslVerify = false

注意:这具有重大的安全影响。

打开终端,执行以下命令:

export GIT_SSL_NO_VERIFY=1

它为我工作,我使用Linux系统。

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

我在老旧的Ubuntu 16.04和GitLab上也遇到了同样的问题(其他电脑运行得很好)。

这个问题实际上是Git内部使用的旧版本的gnutls库。这个旧的库对服务器端的证书顺序很敏感——这个问题中有更多信息。最终的解决方案很简单:

apt-get update
apt-get upgrade libgnutls*

我搞砸了我的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'