在设置了http.sslCAInfo之后无法克隆Github仓库

4
我需要管理一个私有的git repo,所以我创建了一个 .pem 文件并将 http.sslCAInfo 设置为 .pem 文件的路径。但现在我无法从Github的仓库中克隆代码了:
致命错误:无法访问 'https://github.com/KidSysco/jquery-ui-month-picker/':服务器证书验证失败。 CAfile:/home/marco/sources/git_certs/cert.pem CRLfile:none http.sslCAInfo 的默认值是什么?我尝试将其设置为空字符串,但现在我收到以下错误:
致命错误:无法访问 'https://github.com/KidSysco/jquery-ui-month-picker/':SSL CA 证书存在问题(路径?访问权限?)
4个回答

6

Ok, I solved with

git config --global http.sslCAInfo /etc/ssl/certs/ca-certificates.crt

您可以使用以下方式配置当前仓库:
git config http.sslCAInfo path/to/local.pem

3
你也可以在 Linux/Git Bash 中运行以下命令以获取 OpenSSL 正在使用的“正确”目录。此命令将输出带引号的目录,因此您无需执行任何特殊操作即可处理空格,并且可以将其直接传递给另一个命令。
因此,您可以使用以下命令修复您的 git 配置:
```git config --global http.sslCAInfo $(openssl version -d | awk '{ print $2 }')```

你需要稍微使用 sed,但感谢你的提示。 - Marco Sulla
谢谢提醒,我忘记了它在输出中显示环境变量名称,我会考虑为未来的访问者修复这个问题。 - dragon788
@MarcoSulla 感谢您的提醒,现在应该会更好了。 - dragon788

2

我在Windows上使用SourceTree时遇到了同样的问题。

  1. Not recommended, but easy solution:

    Disable certificate check
    git config --system http.sslverify false
    
  2. Add your certificate to ca-bundle.crt (it is located at: c:\Users\\AppData\Local\Atlassian\SourceTree\git_local\mingw32\ssl\certs\ca-bundle.crt)

如果您已经将http.sslCAInfo设置为自签名证书,并希望将其恢复为原始设置:

    git config --global http.sslCAInfo /mingw32/ssl/certs/ca-bundle.crt 

1
我发现在Windows用户账户的根目录下有.gitconfig文件。你可能需要在Windows资源管理器或Linux中打开“显示隐藏文件”以查看.(点)文件。
然后,我删除了这两行以将sslCAInfo还原为默认值:
[http]
    sslCAInfo = *whatever you set here*

我建议按照以下说明 https://mattferderer.com/fix-git-self-signed-certificate-in-certificate-chain-on-windows 进行操作。

基本上,将证书导出为Base64格式的证书,在git安装目录中找到ca-bundle.crt文件,通过将导出的Base64证书文本复制到ca-bundle.crt底部来编辑该文件。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接