Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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 has been broken. So, I want to reinstall those packages, which packages can be related to these errors? Or how do I fix this kind of error?

share|improve this question
2  
This other question might help. –  Christopher Sep 12 '12 at 12:53

2 Answers 2

Got reason of the problem, it was gnutls package. It's working weird behind a proxy. But openssl is working fine even in weak network. So workaround is that we should compile git with openssl. To do this, run the following commands:

sudo apt-get install build-essential fakeroot dpkg-dev
mkdir ~/git-openssl
cd ~/git-openssl
sudo apt-get source git
sudo apt-get build-dep git
sudo apt-get install libcurl4-openssl-dev
sudo dpkg-source -x git_1.7.9.5-1.dsc
cd git_1.7.9.5 8.

Then, edit debian/control file (run the command: gksu gedit debian/control) and replace all instances of libcurl4-gnutls-dev with libcurl4-openssl-dev

sudo dpkg-buildpackage -rfakeroot -b

(if it's failing on test, you can remove the line TEST=test from the file debian/rules)

sudo dpkg -i ../git_1.7.9.5-1_i386.deb

Inspired from here http://code.google.com/p/wfuzz/wiki/PyCurlSSLBug

share|improve this answer
1  
Had this same issue after upgrading to Ubuntu 14.04. This solution worked great! –  vertti Apr 23 at 10:34
    
Worked with Linux Mint 16, you have to go to "Software Sources" and enable sources on official repositories. You must also uninstall libcurl4-gnutls-dev and replace by libcurl4-openssl-dev prior to compiling. –  Guillaume Perrot Jun 12 at 9:05

Might help the wondering minds. If you're using 'repo' to download a repository (say android source code) and come across the gnutls-handshake problem, @Nyambaa's answer works.

Repo is a script which depends on Git, so you should be good. Worked like magic on my Ubuntu 14.04 lts

share|improve this answer

protected by Community Oct 30 '13 at 17:17

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.