我有一个公司 git 服务器,使用自签名证书通过 https 工作。本地克隆包含两个遥控器 - 一个指向该服务器的源,另一个指向 github。
默认情况下,从原点拉取失败:
$ git pull
fatal: unable to access 'https://[email protected] /cdn-cgi/l/email-protection/git/fizzbuzz.git/': SSL certificate problem: self signed certificate
github 远程工作正常。
有两种经常建议的解决方案:
git config http.sslVerify false
这是一个坏主意,有人建议配置 Git 以接受特定 https 远程的特定自签名服务器证书 https://stackoverflow.com/questions/9072376/configure-git-to-accept-a-particular-self-signed-server-certificate-for-a-partic:
git config http.sslCAInfo <downloaded certificate>.pem
它修复了从原点拉取的问题,但破坏了 github 远程:
$ git pull github
fatal: unable to access 'https://github.com/user/fizzbuzz.git/': SSL certificate problem: unable to get local issuer certificate
如何在不中断 github 拉取的情况下从公司服务器拉取?
如果您使用的是 Git 1.8.5+(2013 年 8 月),您可以为每个 URL 指定 http 指令(!) https://stackoverflow.com/a/18712501/6309.
在你的情况下:
git config --global http."https://code.example.com/".sslVerify false
#
# or, if not on default 443 port:
#
git config --global http."https://code.example.com:<aPort>/".sslVerify false
这只会禁用 SSL 验证code.example.com
,不适用于其他 URL。
Or:
git config --global http."https://code.example.com/".sslCAInfo <downloaded certificate>.pem
同样的想法:sslCAInfo
会指向<downloaded certificate>.pem
仅适用于code.example.com
URLs.
可以将您的证书添加到 Git 系统证书存储中,其中包含git for windows https://github.com/git-for-windows/git/, 将在C:\path\to\PortableGit-2.6.1-64-bit\usr\ssl\certs\ca-bundle.crt
.
但这不是最佳实践,除非您必须分发带有内部证书的 Git 发行版。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)