Git无法在公司代理中进行身份验证

时间:2015-02-06 08:48:29

标签: git authentication curl proxy libcurl

我正在尝试使用以下命令克隆Git存储库

git clone http://github.com/apache/hive.git 

我已正确设置http.proxy变量:

http.proxy=http://user:password@proxy:8080

但结果我收到以下消息:

fatal: unable to access 'http://github.com/apache/hive.git/': The requested URL returned error: 407

当我打开curl verbose模式时,我得到以下

* Couldn't find host github.com in the .netrc file; using defaults
* Hostname was NOT found in DNS cache
*   Trying corpproxy...
* Connected to corpproxy (corpproxy) port 8080 (#0)
> GET http://github.com/apache/hive.git/info/refs?service=git-upload-pack HTTP/1.1
User-Agent: git/2.2.2
Host: github.com
Accept: */*
Accept-Encoding: gzip
Proxy-Connection: Keep-Alive
Pragma: no-cache
< HTTP/1.1 407 Proxy Authentication Required ( Forefront TMG requires authorization to fulfill the request. Access to the Web Proxy filter is denied.  )
< Via: 1.1 TMG
< Proxy-Authenticate: Negotiate
< Proxy-Authenticate: Kerberos
< Proxy-Authenticate: NTLM
< Proxy-Authenticate: Basic realm="corpproxy-realm"
< Connection: Keep-Alive
< Proxy-Connection: Keep-Alive
< Pragma: no-cache
< Cache-Control: no-cache
< Content-Type: text/html
< Content-Length: 4126  
< 
* Ignoring the response-body
* Connection #0 to host corpproxy left intact
* Issue another request to this URL: 'http://github.com/apache/hive.git/info/refs?service=git-upload-pack'
* Couldn't find host github.com in the .netrc file; using defaults
* Found bundle for host github.com: 0xdb7550
* Re-using existing connection! (#0) with host corpproxy
* Connected to corpproxy (corpproxy) port 8080 (#0)
> GET http://github.com/apache/hive.git/info/refs?service=git-upload-pack HTTP/1.1
User-Agent: git/2.2.2
Host: github.com
Accept: */*
Accept-Encoding: gzip
Proxy-Connection: Keep-Alive
Pragma: no-cache
< HTTP/1.1 407 Proxy Authentication Required ( Forefront TMG requires authorization to fulfill the request. Access to the Web Proxy filter is denied.  )
< Via: 1.1 TMG
* gss_init_sec_context() failed: : No Kerberos credentials available
< Proxy-Authenticate: Negotiate
< Proxy-Authenticate: Kerberos
< Proxy-Authenticate: NTLM
< Proxy-Authenticate: Basic realm="corpproxy-realm"
< Connection: Keep-Alive
< Proxy-Connection: Keep-Alive
< Pragma: no-cache
< Cache-Control: no-cache
< Content-Type: text/html
< Content-Length: 4126  
< 
* Connection #0 to host corpproxy left intact
fatal: unable to access 'http://github.com/apache/hive.git/': The requested URL returned error: 407

下面一行对我来说很奇怪

* gss_init_sec_context() failed: : No Kerberos credentials available

所以我决定强制Git使用基本身份验证。 我从

更改了http.c(Git)中的源代码
curl_easy_setopt(result, CURLOPT_PROXYAUTH, CURLAUTH_ANY);

curl_easy_setopt(result, CURLOPT_PROXYAUTH, CURLAUTH_BASIC | CURLAUTH_NTLM | CURLAUTH_DIGEST);

之后一切顺利。 所以问题是 - 它是Git bug还是CURL?或者可能根本不是一个错误?

工具版本:

libcurl 7.43.0
git version 2.5.0

0 个答案:

没有答案