我在Windows上使用Git。我安装了msysGit包。我的测试存储库在服务器上有一个自签名证书。我可以毫无问题地使用HTTP访问和使用存储库。移动到HTTPS会出现以下错误:

SSL证书问题:无法获得本地颁发者证书。

我在Windows 7客户端机器的受信任根证书颁发机构中安装了自签名证书。我可以在Internet Explorer中浏览到HTTPS存储库URL,而不会出现错误消息。

Philip Kelley的这篇博客文章解释了cURL不使用客户端机器的证书存储。我按照博客文章的建议创建了curl-ca-bundle的私有副本。然后配置Git使用它。我确定Git正在使用我的副本。如果我重命名副本;Git抱怨文件丢失。

我粘贴了我的证书,正如博客文章中提到的,我仍然得到“无法获得本地发行人证书”的消息。

我通过HTTPS克隆GitHub仓库来验证Git仍然在工作。

我看到的唯一不同于博客文章的地方是我的证书是根证书——没有链可以到达它。我的证书最初来自点击IIS8 IIS管理器链接“创建自签名证书”。也许这使得证书在某种程度上与cURL所期望的有所不同。

如何让Git/cURL接受自签名证书?


当前回答

You might have a DNS issue and not a certificate issue, so before you disable SSL verification in your Git shell you should rule out a DNS problem. Cases such as these have been mentioned in Q&A forums such as https-issues-possibly-related-to-dns. If you are using WSL on Windows as your terminal, then you can try running sudo echo nameserver 8.8.8.8 > /etc/resolv.conf and then issue the git commands to see if that makes a difference. This does not seem to be a permanent DNS fix (lasting only the lifetime of your terminal session), but it could help you determine whether it is a DNS issue and not a certificate issue. You could also check this document on configuring your network to use a public DNS. Again, this is only to help you determine if your DNS settings might need adjusting in order to help resolve the certificate issues.

其他回答

这对我很有用。我打开cmd行并运行以下命令。又拉了一下。

Git配置——global http。sslVerify假

下载并安装本地证书。它可能在你的公司网站上发布。例如,*。cer文件。

右键单击它并选择安装证书。将出现“证书导入向导”。选择本地机器。按Next,确认。 选择“将所有证书放入以下存储区”,按“浏览”并选择“受信任的根证书颁发机构”,“确定”,“完成”。

此外,您还可以检查其他应用程序是否可以获取、拉取或推送数据。例如,在Android Studio或IDEA中,你应该在设置中选择这个复选框:使用凭证帮助。

在运行composer update/install之前使用此命令:

git config --global http.sslverify false

在我的例子中,因为我已经为windows 7安装了ConEmu终端,它在C:\Program Files\Git\mingw64\ssl\certs.的安装过程中创建了ca-bundle

因此,我必须在终端上运行以下命令才能使其工作:

$ git config --global http.sslbackend schannel
$ git config --global http.sslcainfo /mingw64/ssl/certs/ca-bundle.crt

因此,我的C:\Program Files\Git\etc\gitconfig包含以下内容:

[http]
    sslBackend = schannel
    sslCAinfo = /mingw64/ssl/certs/ca-bundle.crt

另外,在安装Git时,我选择了与这里提到的相同的选项。

希望有帮助!

当我试图“克隆”项目时,我得到了这个错误。一个解决办法是只使用网页上的“下载压缩文件”,这对我来说,实现了我想做的事情。