Git over HTTPS can do ls-list but cannot clone via

2019-08-06 00:12发布

问题:

This is a common question/problem, however I am having slightly different problems than others. I am trying to use git via my http proxy at work. I have already configured my proxy settings in git:

C:\Program Files (x86)\Git\bin>git config --global -l
http.proxy=https://c172635b4:password@p01.proxy.local:8080

When I issue git ls-remote https://eric@git.assembla.com/myproj.git, it asks me for the password and provides the expected result. This confirms that git is authenticating via the proxy properly.

However, when I try to do a git clone, I get the following error.

error: RPC failed; result=22, HTTP code = 0
fatal: The remote end hung up unexpectedly

I've run it with GIT_CURL_VERBOSE=1 to see the log and I am able to see it authenticating to the NTLM proxy properly until the end:

< HTTP/1.1 407 Proxy Authentication Required
< Proxy-Authenticate: NTLM TlRMTVNTUAACAAAABgAGADgAAAA1goniA432smdf3mwAAAAAAAAAALAAsAA+AAAABgByFwAAAA9SAEUAUwACAAYAUgBFAFMAAQAYAFcAUwBQAEkAQwBCAEMAQQBBAEEAMAAxAAQAHAByAGUAcwAuAGIAbgBnAGYALgBsAG8AYwBhAGwAAwA2AFcAUwBQAEkAQwBCAEMAQQBBAEEAMAAxAC4AcgBlAHMALgBiAG4AZwBmAC4AbABvAGMAYQBsAAUAHAByAGUAcwAuAGIAbgBnAGYALgBsAG8AYwBhAGwABwAIAGq6JY+ND84BAAAAAA==
< Cache-Control: no-cache
< Pragma: no-cache
< Content-Type: text/html; charset=utf-8
< Proxy-Connection: Keep-Alive
< Set-Cookie: BCSI-CS-dcfa3879f83cfd49=2; Path=/
< Connection: Keep-Alive
< Content-Length: 3742
< 
* Ignore 3742 bytes of response-body
* NTLM send, close instead of sending 2531 bytes
* Received HTTP code 407 from proxy after CONNECT
* About to connect() to proxy p01.proxy.local port 8080 (#0)
*   Trying 172.31.132.18... * connected
* Connected to p01.proxy.local (172.31.132.18) port 8080 (#0)
* Establish HTTP proxy tunnel to git.assembla.com:443
* Proxy auth using NTLM with user 'c172635b4'
* Server auth using Basic with user 'eric'
> CONNECT git.assembla.com:443 HTTP/1.1
Host: git.assembla.com:443
Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAIIAAAAYABgAmgAAAAYABgBYAAAAEAAQAF4AAAAUABQAbgAAABAAEACyAAAANYKI4gYBsR0AAAAPN9Y0OSiIbF7a4dr8yIqv9WwAYgBnAGMANgAxADIANwAxAGIANAAyAFUAQQAxADMAOAAxAEQAUwA1ADKgzMJlkKLlAAAAAAAAAAAAAAAAAAAAAHVtirzD6urrzJLWZ73HGWxFUEd926He985LMc+KepdWBDDgQQBESv8=
User-Agent: git/1.7.10.5997.gaa4aa
Proxy-Connection: Keep-Alive
Content-Type: application/x-git-upload-pack-request
Accept: application/x-git-upload-pack-result
Content-Encoding: gzip

< HTTP/1.1 407 Proxy Authentication Required
< Proxy-Authenticate: NTLM
* Authentication problem. Ignoring this.
< Cache-Control: no-cache
< Pragma: no-cache
< Content-Type: text/html; charset=utf-8
< Proxy-Connection: close
< Set-Cookie: BCSI-CS-dcfa3879f83cfd49=2; Path=/
< Connection: close
< Content-Length: 3742
< 
* Closing connection #0
* HTTP response code said error

I am running:

git version 1.7.10.msysgit.1

curl 7.21.1 (i686-pc-mingw32) libcurl/7.21.1 OpenSSL/0.9.8r zlib/1.2.3
Protocols: dict file ftp ftps http https imap imaps ldap ldaps pop3 pop3s rtsp smtp smtps telnet tftp
Features: Largefile NTLM SSL SSPI libz

I did find one other posting on SO, and this is as close to a duplicate as possible of that question, but there is no accepted solution there, nor are any of the suggestions applicable either.

Does anyone have any suggestions how to further debug the issue and/or get this working?

回答1:

After trying multiple versions of Curl and/or git, I finally installed a local proxy server and tunnel git through there. I ended up using cntlm but there are a few different ones that could have worked.

I still don't know why curl is having trouble with my proxy server, but using cntlm as a middleman works fine.