Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git : HTTP request failed

Tags:

I have a remote repository with HTTPS access.

git status lists only one entry: master

git remote -v lists two entries to the same address: one for fetch, one for push

But when I do git remote show origin, or other operations, like fetch, I get :

error: while accessing https:... fatal: HTTP request failed 

I am behind a proxy, but as it is set in my .gitconfig (sslVerify = no) and the cloning is OK, I don't think the problem comes from that.

BUT... my OS (CentOS) has been reinstalled.

like image 391
Oodini Avatar asked Dec 27 '11 12:12

Oodini


2 Answers

If you're using https: rather than git: for your clone, it's possible that it's barfing on the CA certificate, i.e. you don't have a copy of the intermediate certificate to verify your SSL connection. I've run into this on a couple of different occasions. Usually with debian-based Linux distributions. Try

git config --global http.sslVerify false 

and then the clone again. If the clone works, that's what's happening. However this is a bad solution, as of course turns off SSL verification, which makes using HTTPS somewhat pointless, and leaves you vulnerable to man-in-the-middle attacks.

What you need to do is download the CA Certificates package for whatever OS you're on, under Linux (well Debian/Ubuntu) it'll probably be something like

apt-get install ca-certificates 

then

git config --global http.sslVerify true git config --global http.sslCAinfo /etc/ssl/certs/ca-certificates.crt 

although your path to your certificate file might be different depending on OS version.

This should get it working.

like image 144
Alasdair Allan Avatar answered Oct 01 '22 14:10

Alasdair Allan


I had set the http proxy in the http_proxy environment variable (Git Bash on Windows), but only setting the proxy in my %HOME%/.gitconfig worked:

[http]     proxy = http://USERNAME:PASWORD@URL:PORT 
like image 45
Joachim Werner Avatar answered Oct 01 '22 14:10

Joachim Werner