【问题标题】:Git stopped working over SSL on WindowsGit 停止在 Windows 上通过 SSL 工作
【发布时间】:2017-05-29 01:11:59
【问题描述】:

我们在本地设置了新的 TFS 2017 服务器。我的系统管理员设置了 https 并生成了一个自签名证书。使用 Visual Studio 的内置 git 工具一切正常。当我尝试从 CLI 执行任何操作时,我收到以下错误:SSL certificate problem: unable to get local issuer certificate

我尝试过的:

  • 在我的客户端计算机上的受信任的根证书颁发机构存储中安装了证书(它也安装在服务器上)。要安装它,我只需双击提供给我的 .pfx 文件,输入密码,然后选择 Trusted Root 存储。

  • 经过一些故障排除后,我将本地证书导出为 Base-64 编码的 x.509 (.CER) 文件,并将其附加到 ca-bundle.crt

  • 仔细检查了我的 git 配置以确保 http.sslcainfo 指向正确的 ca-bundle.crt 文件。

  • 使用 openssl 连接到我的服务器。这给了我两个错误消息: verify error:num=20:unable to get local issuer certificate verify return:1 depth=0 OU = Created by Team Foundation Server, CN = my.company.com verify error:num=21:unable to verify the first certificate verify return:1 Certificate chain 0 s:/OU=Created by Team Foundation Server/CN=my.company.com i:/OU=Created by Team Foundation Server/CN=my.company.com

  • 尝试使用其他机器的 CLI 通过 https 进行连接,结果相同。

更新

让这个工作仍然没有运气,但很好奇自签名证书是用私钥签名的事实是否与我们的问题有关。

【问题讨论】:

标签: git ssl tfs https


【解决方案1】:

您的问题似乎与 TFS 无关,但您的自签名证书无法验证。可以查看解决方案here

解决方法

使用全局选项告诉 git 不要执行证书验证:

git config --global http.sslVerify false

分辨率

之前有几种方法解决了这个问题:

A.确保根证书已添加到 git.exe 的证书存储区,如 here 所述。

B.通过运行告诉 Git 在哪里可以找到 CA 包:

git config --system http.sslCAPath /absolute/path/to/git/certificates

或将 CA 包复制到 /bin 目录并将以下内容添加到 gitconfig 文件中:

sslCAinfo = /bin/curl-ca-bundle.crt

C.重新安装 Git。

D.确保存在完整的 CA,包括根证书。

解决 SSL 问题后,你可以参考以下案例,以防你在命令行中遇到 Authentication 问题:

Using Git with TFS 2017 - Works in Visual studio but not Command Line

【讨论】:

  • 我感觉证书本身存在问题(我的系统管理员为我创建的)。今天要和他一起转圈,并会报告我发现的任何东西。
  • 能够通过创建新的 CA 证书并使用 makecert 签署新的服务器证书来实现此功能
  • http.sslVerify 似乎不适用于 2.19.x 中的 Windows
【解决方案2】:

最终发现问题出在 IIS 生成的证书上。

我找到了关于这个 SO 问题的解决方案: Unable to resolve "unable to get local issuer certificate" using git on Windows with self-signed certificate

查看使用 makecert 生成服务器证书的公认答案

【讨论】:

    猜你喜欢
    • 2019-01-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-13
    相关资源
    最近更新 更多