克隆我的回购协议是可行的,而推回回购协议则不行。
第一次克隆不起作用:

git clone https://github.com/slimsnerdy/testy.git
Cloning into 'testy'...
fatal: unable to access 'https://github.com/slimsnerdy/testy.git/': SSL certificate problem: self signed certificate in
certificate chain

因此,我将以下自定义证书添加到.gitconfig文件中:
[http]
    sslCAInfo = U:/ca-bundle.crt

现在克隆工作:
Cloning into 'testy'...
remote: Counting objects: 25, done.
remote: Compressing objects: 100% (22/22), done.
remote: Total 25 (delta 8), reused 6 (delta 1), pack-reused 0
Unpacking objects: 100% (25/25), done.

好,现在按:
new-item test.txt
git add *
git commit -m "push test"
git push
Username for 'https://github.com': slimsnerdy
Password for 'https://slimsnerdy@github.com':
remote: Anonymous access to slimsnerdy/testy.git denied.
fatal: Authentication failed for 'https://github.com/slimsnerdy/testy.git/'

当我试图用我的手机通过一个私人火锅(避开公司防火墙)时,它会很好地推动。
为什么使用自定义证书而不是使用自定义证书?
我想在不使用ssh的情况下解决这个问题。

最佳答案

您公司的防火墙安装了一个代理,其作用是man in the middle。为此,它为您访问的站点(如github.com)创建证书。这些证书显然有一个不同的颁发者(您公司的内部CA),在默认情况下,Git客户端不信任它。关闭sslVerify将强制Git客户端接受来自任何颁发者的任何证书。这有潜在的危险。将贵公司的CA添加到Git客户端信任的发行者列表中,您的原始方法是imho允许您的Git客户端在公司防火墙后面与GitHub.com对话的更好方法。
那么,为什么这个设置不允许您push?到目前为止,其他海报忽略的是,本例中的错误不是SSL错误。只有您的客户才能看到您公司的证书。如果解决了,就解决了。GitHub未看到此证书。因此,使用SSL设置进行任何进一步的调整都不会有帮助。
我可以复制您的案例,直到我第一次看到ssl自签名证书问题,当我将代理的证书添加到sslCAInfo时,这个问题就消失了。坏消息是:我无法重现身份验证失败的错误。对Github的推动刚刚奏效。好消息是:可以从类似于您的设置中推到GitHub。
如果这不是一个SSL问题,那么它只能由代理引起。因为代理向客户机提供了自己的证书,所以它能够解密SSL流量并对交换的数据进行深入检查。代理有权禁用某些命令、限制对特定站点的访问或从请求中删除用户名/密码。
请与您公司的IT安全人员交谈。他们应该能够澄清代理是否对github或某些git命令施加访问限制。
更新
通过fiddler路由git web流量可以如下所示(从命令行使用git):
跑小提琴手
在git bash中,将cd添加到工作目录,并将选项-c http.sslVerify=false -c http.proxy=127.0.0.1:8888添加到git命令中。
例子:

$ git -c http.sslVerify=false -c http.proxy=127.0.0.1:8888 push

在Fiddler中,您现在应该看到如下内容:
2   200 HTTP    Tunnel to   github.com:443  0           git-remote-https:6512
3   401 HTTPS   github.com  /xxx/xxxx.git/info/refs?service=git-receive-pack [...]
4   200 HTTPS   github.com  /xxx/xxxx.git/info/refs?service=git-receive-pack [...]

或者,使用“简要摘要”(ctrl/shift/t)导出:
CONNECT http://github.com:443
200 Connection Established ()

GET https://github.com/xxx/xxxx.git/info/refs?service=git-receive-pack
401 Authorization Required (text/plain)

GET https://github.com/xxx/xxxx.git/info/refs?service=git-receive-pack
200 OK (application/x-git-receive-pack-advertisement)

在Fiddler Web调试器的右窗格中,可以进一步调查交换的数据。特别是对于上面显示的三个请求中的最后一个,您应该在“headers”选项卡中看到类似的内容:
GET /xxx/xxxx/info/refs?service=git-receive-pack HTTP/1.1
Host: github.com
Authorization: Basic XyzzY1337qQ=
User-Agent: git/2.13.0.windows.1
Accept: */*
Accept-Encoding: gzip
Pragma: no-cache

因此,您可以证明您的客户确实发送了授权信息。如果没有,我会对结果非常感兴趣。

关于git - git clone有效,但在更换防火墙后面的SSL证书后不会推送,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/50493545/

10-14 16:19
查看更多