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
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.
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.
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)
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"
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With