错误:gnutls_handshake()GIT存储库失败

时间:2012-11-23 06:41:21

标签: git github ubuntu-10.04

当我尝试克隆git存储库时出现以下错误。我也正确配置了rsa公钥。

$ git clone https://github.com/blah/blah.git
Initialized empty Git repository in /home/arun/.git/
error: gnutls_handshake() failed: A TLS packet with unexpected length was
       received. while accessing https://github.com/blah/blah.git/info/refs

fatal: HTTP request failed

6 个答案:

答案 0 :(得分:9)

它可以用于GnuTLs or pycurl bug

  

以下是pycurl_7.19.0-4ubuntu3的新方法:

sudo apt-get install build-essential fakeroot dpkg-dev
mkdir ~/python-pycurl-openssl
cd ~/python-pycurl-openssl
sudo apt-get source python-pycurl
sudo apt-get build-dep python-pycurl
sudo apt-get install libcurl4-openssl-dev
sudo dpkg-source -x pycurl_7.19.0-4ubuntu3.dsc
cd pycurl-7.19.0
# remove the HAVE_CURL_GNUTLS=1 in the following file
sudo vim debian/patches/10_setup.py.dpatch
# remove the HAVE_CURL_GNUTLS=1 in the following file
sudo vim setup.py
# replace all gnutls into openssl in the following file
sudo vim debian/control
sudo dpkg-buildpackage -rfakeroot -b
sudo dpkg -i ../python-pycurl_7.19.0-4ubuntu3_amd64.deb

答案 1 :(得分:5)

我遇到了这个问题,我花了一些时间才找到解决方案。我一直以为我在某个地方错过了一个包裹。我不想重新编译Git,因为我已经在使用最新版本了,我很确定问题不是Git本身。

我的问题是我的.gitconfig文件。问题只发生在多年来多次升级的旧Linux服务器上。在某些时候,由于某种原因,我不记得了,我在sslVersion = sslv3文件中明确指定了.gitconfig

当我看到它时,灯泡继续,因为我知道SSL V3因安全问题而被弃用,并且大多数人应该使用TLS。例如,请参阅RFC 7568,XSD element substitution group example

因此,我的修复包括从我的sslVersion = sslv3文件中删除有问题的~/.gitconfig行,或更改此行:

[httpd] 
    sslVersion = sslv3

到此:

[httpd]
    sslVersion = tlsv1.2

删除该行并让Git / libcurl协商加密似乎是最佳选择,因为TLS v1.3正在开发中,我不希望将来再次遇到此问题!

答案 2 :(得分:4)

在我的情况下,似乎我没有使用pycurl,所以上述解决方案对我不起作用。什么DID工作是重建git-core修改为使用openssl而不是gnutls。

说明在这里:

https://askubuntu.com/questions/186847/error-gnutls-handshake-falied

我在大多数地方用“git-core”代替“git”,.dsc(包信息文件?)显示为git-core_1.7.0.4-1ubuntu0.2.dsc和.deb包来自git-core_1.7.0.4-1ubuntu0.2_i386.deb。

答案 3 :(得分:1)

我从我自己的用户没有足够权限的目录中尝试sudo git fetch时遇到了同样的问题。我将存储库移至/tmp并继续我的工作。

重启后不要忘记/tmp被删除。

答案 4 :(得分:0)

对我来说,最终是SSL证书是自签名的。试一试

git config --global http.sslVerify false

答案 5 :(得分:0)

在我看来,将@Rick和@ m0j0的解决方案混合在一起

首先执行以下命令:

git config --global http.sslVerify false
git config --global http.sslVerify true

添加或修改~/.gitconfig

之后
nano ~/.gitconfig

设置此:

[httpd] 
    sslVersion = sslv3