22

当我尝试克隆 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
4

6 回答 6

8

它可以用于GnuTLs 或 pycurl 错误

以下是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
于 2012-11-23T06:57:50.037 回答
7

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

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

当我看到这一点时,灯泡亮了,因为我知道 SSL V3 出于安全考虑已被弃用,并且大多数人应该改用 TLS。例如,参见 RFC 7568,https: //www.rfc-editor.org/rfc/rfc7568

所以我的修复涉及sslVersion = sslv3从我的~/.gitconfig文件中删除有问题的行,或者改变这个:

[httpd] 
    sslVersion = sslv3

对此:

[httpd]
    sslVersion = tlsv1.2

删除这条线并让 Git/libcurl 协商加密似乎是最好的选择,因为 TLS v1.3 正在开发中,我不想以后再遇到这个问题!

于 2017-03-08T18:16:19.013 回答
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。

于 2013-02-26T22:32:19.170 回答
1

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

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

于 2015-01-27T12:03:45.167 回答
-2

在我的情况下,混合@Rick 和@m0j0 的解决方案

首先执行这些命令:

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

添加或修改后~/.gitconfig

nano ~/.gitconfig

设置这个:

[httpd] 
    sslVersion = sslv3
于 2018-08-01T08:37:37.863 回答
-3

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

git config --global http.sslVerify false

于 2018-02-25T23:15:46.040 回答