Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git error: gnutls_handshake() failed on push

Tags:

git

I have been using git for a while with no problems, then suddenly it started throwing this error when using git push:

error: gnutls_handshake() failed: A TLS packet with unexpected length was received. while accessing ... fatal: HTTP request failed

It was working fine, then suddenly it stopped.

What is the problem?

Thanks

like image 704
Wahtever Avatar asked Mar 27 '13 17:03

Wahtever


5 Answers

It seems there is a problem with the gnutls package. As a workaround, you can try to compile git with openssl. More info on how to accomplish this you can find here.

like image 108
niculare Avatar answered Oct 04 '22 15:10

niculare


The linked discussion on askubuntu references a version number for git that may not match up with your own. Instead of these two lines:

sudo dpkg-source -x git_1.7.9.5-1.dsc
cd git_1.7.9.5 8.

you need to account for the version of git you're using. In my case, it was 1.8.xxxxx.

sudo dpkg-source -x git_<git-version-number>.dsc
cd git_<git-version-number>

An easy way to get around this is to just copy the first part of the command and then hit Tab to autocomplete. This may not work perfectly if you have recompiled before.

like image 21
cardonator Avatar answered Oct 04 '22 14:10

cardonator


In my case same error was caused by completely different thing.

Debian was upgraded from Wheezy to Jessie, and thus apache was upgraded 2.2.22 to 2.4.10. git was trying to push to https://www.example.com and it stopped working with error: gnutls_handshake() failed: A TLS packet with unexpected length was received

Turns out, www.example.com was resolving to both IPv4 and IPv6 addresses, and apache config was having <Virtualhost x.y.w.z:443> IPv4 address only. Changing that to <Virtualhost _default_:443> fixed the problem.

(just so if it helps somebody else with same problem... only found it after the tedious recompile of git with openssl didn't change anything at all)

like image 39
Matija Nalis Avatar answered Oct 04 '22 14:10

Matija Nalis


This answer might help. I was surprised that the problems are nowhere to be linked together although the question is old.

Just to be sure the usefull info won't get lost, I copy a brief solution from the question:

hostname=XXX
port=443
trust_cert_file_location=`curl-config --ca`

sudo bash -c "echo -n | openssl s_client -showcerts -connect $hostname:$port 2>/dev/null  | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' >> $trust_cert_file_location"
like image 33
StSav012 Avatar answered Oct 04 '22 14:10

StSav012


I have also faced the same issue which was fixed later by disabling my Kaspersky antivirus in my local machine. I hope this may be helpful to others. error report and solution

like image 32
Ragubathi U Avatar answered Oct 04 '22 13:10

Ragubathi U