git - git clone 有效,但在防火墙后面替换 SSL 证书后推送无效
问题描述
克隆我的回购作品;推回它没有。
第一次克隆不起作用:
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/'
当我尝试使用我的手机(绕过公司防火墙)通过个人火锅推送时,它可以正常推送。
为什么clone
使用自定义证书而不使用push
?我想在不使用 ssh 的情况下解决这个问题。
解决方案
贵公司的防火墙安装了一个代理,充当中间人。为此,它会为您访问的站点创建证书,例如 github.com。这些证书显然有一个不同的颁发者(您公司的内部 CA),默认情况下 git 客户端不会信任该颁发者。关闭sslVerify
会强制 git 客户端接受来自任何颁发者的任何证书。这是有潜在危险的。您最初的方法是将您公司的 CA 添加到 git 客户端信任的发行者列表中,恕我直言,这是允许您的 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 Debugger 的右窗格中,您可以进一步调查交换的数据。特别是对于上面显示的三个请求中的最后一个,您应该在“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
因此,您可以证明您的客户确实发送了授权信息。如果没有,我会对结果非常感兴趣。
推荐阅读
- python - Selenium 和 python3 在不输入值的情况下激活文本框
- powershell - Get regkey based on search, then add new entry to that key
- python-3.5 - Django 自定义管理命令作为 Windows 计划任务
- gradle - PhoneGap - 无法解析 com.android.tools.build:gradle:3.0.1
- javascript - Fire event when mesh position updated in Babylon.JS
- vue.js - Issues with importing vue resource
- javascript - 地理位置 watchPostion 每秒触发一次
- kubernetes - k8s PodSecurityPolicy. Drop all capabilities except one
- excel - How to populate ComboBoxes from ListBox selection?
- django - 无效的块标签:“render_field”,预期为“空”或“endfor”。您是否忘记注册或加载此标签?