添加自签名SSL证书而不禁用权限签名的证书

时间:2014-05-22 12:50:10

标签: git ssl github

我有一个使用自签名证书通过https工作的公司git服务器。本地克隆包含两个遥控器 - 指向该服务器的原点,另一个指向github。 默认情况下,从原点拉出会失败:

$ git pull
fatal: unable to access 'https://user@code.example.com/git/fizzbuzz.git/': SSL certificate problem: self signed certificate

github遥控器工作正常。

有两种经常提出的解决方案:

git config http.sslVerify false

这是一个坏主意,而configure Git to accept a particular self-signed server certificate for a particular https remote建议的那个:

git config http.sslCAInfo <downloaded certificate>.pem

修复了从原点拉动,但是打破了github remote:

$ git pull github
fatal: unable to access 'https://github.com/user/fizzbuzz.git/': SSL certificate problem: unable to get local issuer certificate

如何在不破坏github的情况下从公司服务器上工作?

2 个答案:

答案 0 :(得分:46)

如果您使用的是git 1.8.5 +(2013年8月),则可以specify http directives per url(!)

在你的情况下:

git config http."https://code.example.com/".sslVerify false

这将取消ssl验证,仅针对code.example.com网址,而不取代其他网址。

或者:

git config http."https://code.example.com/".sslCAInfo <downloaded certificate>.pem

同样的想法:sslCAInfo仅针对<downloaded certificate>.pem网址指向code.example.com

可以在git系统证书存储区中添加您的证书,C:\path\to\PortableGit-2.6.1-64-bit\usr\ssl\certs\ca-bundle.crt位于{{1}}。 但这不是最好的做法,除非您必须分发带有内部证书的git发行版。

答案 1 :(得分:3)

自Git for Windows v2.5.0(git-for-windows.github.io)起,已安装的证书文件已移至“C:\ Program Files(x86)\ Git \ mingw32 \ ssl \ certs \ ca” -bundle.crt”。您必须将证书添加到此文件中。

相关问题