When I try to connect to any HTTPS server with git
, it gives the following error:
error: gnutls_handshake() failed: A TLS packet with unexpected length was received. while accessing ...
fatal: HTTP request failed
I think that maybe some packages that are related to gnutls_handshake
have been broken. So, I want to reinstall those.
Which packages can be related to these errors? Or how do I fix this kind of error?
Got reason of the problem, it was
gnutls
package. It's working weird behind a proxy. Butopenssl
is working fine even in weak network. So workaround is that we should compilegit
withopenssl
. To do this, run the following commands:(Remember to replace
1.7.9.5
with the actual version of git in your system.)Then, edit
debian/control
file (run the command:gksu gedit debian/control
) and replace all instances oflibcurl4-gnutls-dev
withlibcurl4-openssl-dev
.Then build the package (if it's failing on test, you can remove the line
TEST=test
from the filedebian/rules
):Install new package:
i386:
sudo dpkg -i ../git_1.7.9.5-1_i386.deb
x86_64:
sudo dpkg -i ../git_1.7.9.5-1_amd64.deb
Inspired from here: https://github.com/xmendez/wfuzz/wiki/PyCurlSSLBug
For me, it ended up being that SSL certificate was self-signed. Give this a try
git config --global http.sslVerify false
This is mentioned in one of the comments to another answer but I feel it needs to be more visible https://askubuntu.com/users/177551/paul-nelson-baker has written a shell script which, for me, resolved this issue.
The script is available in his repository https://github.com/paul-nelson-baker/git-openssl-shellscript and re-compiles git with openssl instead of gnutls. Read the README for the whole story but it worked for me so thank you Paul.