git clone timed out when used through https proxy

2019-03-16 09:55发布

问题:

The command "git clone https://github.com/user/project.git" times out when being used through an https proxy.

I've successfully had git functioning behind a proxy before, and have read other stackoverflow related to git and proxy usage. Now I've configured it on a host in my current organization to use a non-authenticating proxy, but it's timing out.

  • the proxy is squid, non-authenticating
  • directly connecting via TCP-443 is not an option
  • I've confirmed that git is contacting the proxy
  • Git issues the command "CONNECT github.com:443 HTTP/1.1"
  • The proxy allows the request and connects to github.com on port 443
  • libcurl verifies github's cert and establishes an SSL connection (SSL_RSA_WITH_RC4_128_SHA)
  • git proceeds to sit there, waiting for something that never happens
  • timeout occurs

Has anyone experienced this before? Have any tips?

Here's the system version:

$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.4 (Santiago)

Here's the git version and update information (latest available in RH)

$ git --version
git version 1.7.11.3

$ sudo yum check-update git    
Loaded plugins: downloadonly, rhnplugin, security
This system is receiving updates from RHN Classic or RHN Satellite.

Here's the relevant environmental variables:

$ export | grep http
declare -x http_proxy="http://proxy.hostname:3128/"
declare -x https_proxy="http://proxy.hostname:3128/"

Here's my .gitconfig (for redundancy):

$ cat ~/.gitconfig
[http]
        proxy = http://proxy.hostname:3128/
[https]
        proxy = http://proxy.hostname:3128/

Here's an example of git running (and eventually timing out):

$ GIT_CURL_VERBOSE=1 GIT_DEBUG_LOOKUP=1 GIT_TRANSLOOP_DEBUG=1 GIT_TRANSPORT_HELPER_DEBUG=1 git clone https://github.com/user/project.git 2>&1
Cloning into 'project'...
Debug: Remote helper: -> capabilities
Debug: Remote helper: Waiting...
Debug: Remote helper: <- fetch
Debug: Got cap fetch
Debug: Remote helper: Waiting...
Debug: Remote helper: <- option
Debug: Got cap option
Debug: Remote helper: Waiting...
Debug: Remote helper: <- push
Debug: Got cap push
Debug: Remote helper: Waiting...
Debug: Remote helper: <- 
Debug: Capabilities complete.
Debug: Remote helper: Waiting...
* Couldn't find host github.com in the .netrc file; using defaults
* About to connect() to proxy proxy.hostname 3128 (#0)
*   Trying 10.22.74.73... * Connected to proxy.hostname (x.x.x.x) port 3128 (#0)
* Establish HTTP proxy tunnel to github.com:443
> CONNECT github.com:443 HTTP/1.1
Host: github.com:443
User-Agent: git/1.7.11.3
Proxy-Connection: Keep-Alive
Pragma: no-cache

< HTTP/1.0 200 Connection established
< 
* Proxy replied OK to CONNECT request
* Initializing NSS with certpath: sql:/etc/pki/nssdb
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* SSL connection using SSL_RSA_WITH_RC4_128_SHA
* Server certificate:
*   subject: CN=github.com,O="GitHub, Inc.",L=San Francisco,ST=California,C=US,serialNumber=C3268102,incorporationState=California,incorporationCountry=US,businessCategory=Private Organization
*   start date: May 27 00:00:00 2011 GMT
*   expire date: Jul 29 12:00:00 2013 GMT
*   common name: github.com
*   issuer: CN=DigiCert High Assurance EV CA-1,OU=www.digicert.com,O=DigiCert Inc,C=US
* Connected to proxy.hostname (x.x.x.x) port 3128 (#0)

Here's the squid log:

1367957877.701  60148 x.x.x.x TCP_MISS/200 3765 CONNECT github.com:443 - DIRECT/204.232.175.90 -

So, what's going on here? Does anyone have any ideas?

回答1:

I had the EXACT same problem with git version 1.7.11.3 from rpmforge extra repository under CentOS

Downgrading to an older version (I tested with 1.7.3.4) solved the issue.

To downgrade you can do something like this

yum --showduplicates list git

This will show all available versions for package git

Uninstall previously installed git version:

yum remove git

Install an older version:

yum install git-1.7.3.4


回答2:

I don't know if your issue is resolved. If not then perhaps my answer might be of some help. I was getting similar issue with my Visual studio 2017 during Git cloning, and in my case, I tried the “Credential Manager” of windows and look for the generic credential for git. Here, you can either delete those existing Git credentials or edit them(reset the credential).

On account of above steps, VS 2017 will prompt the user for credentials the next time you are doing something with Team explorer and GIT. Even from GIT bash, I can do cloning from Seems like, when I edit the settings through Credential manager then it would've update the GIT setting of my local system. I tried this approach and it helped me to finally get the things from GIT.



标签: git github proxy