错误:gnutls_handshake() 失败的 GIT 存储库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13524242/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
error: gnutls_handshake() failed GIT repository
提问by Arun Jayapal
The following error appears when I try to clone git repository. I have the rsa public keys configured properly as well.
当我尝试克隆 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
采纳答案by VonC
It could be used to a GnuTLs or pycurl bug
它可以用于GnuTL 或 pycurl 错误
The following is the new method for pycurl_7.19.0-4ubuntu3:
下面是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
回答by m0j0
I had this problem, and it took me a while to find the solution. I kept thinking that I was missing a package somewhere. I didn't want to recompile Git, since I was already using the latest version, and I was pretty sure that the problem wasn't Git itself.
我遇到了这个问题,我花了一段时间才找到解决方案。我一直在想我在某处丢失了一个包裹。我不想重新编译 Git,因为我已经在使用最新版本,而且我很确定问题不是 Git 本身。
My problem was my .gitconfig
file. The problem only occurred on an old Linux server that had been upgraded many times over the years. At some point, for some reason I don't recall, I had explicitly specified sslVersion = sslv3
in my .gitconfig
file.
我的问题是我的.gitconfig
文件。该问题仅发生在多年来多次升级的旧 Linux 服务器上。在某些时候,出于某种我不记得的原因,我已经sslVersion = sslv3
在我的.gitconfig
文件中明确指定了。
When I saw that, the lightbulb went on, since I know that SSL V3 has been deprecated due to security concerns, and that most people should be using TLS instead. For instance, see RFC 7568, https://tools.ietf.org/html/rfc7568
当我看到它时,灯泡亮了,因为我知道出于安全考虑,SSL V3 已被弃用,而且大多数人应该改用 TLS。例如,参见 RFC 7568,https://tools.ietf.org/html/rfc7568
So my fix involved either deleting the offending sslVersion = sslv3
line from my ~/.gitconfig
file, or changing this:
所以我的修复包括sslVersion = sslv3
从我的~/.gitconfig
文件中删除有问题的行,或者改变这个:
[httpd]
sslVersion = sslv3
to this:
对此:
[httpd]
sslVersion = tlsv1.2
Removing the line and letting Git/libcurl negotiate the encryption seemed like the best choice, since TLS v1.3 is in the works, and I don't want to encounter this problem again in the future!
删除该行并让 Git/libcurl 协商加密似乎是最好的选择,因为 TLS v1.3 正在开发中,我不想在将来再次遇到这个问题!
回答by 2NinerRomeo
In My case, It appears I was not using pycurl, so the above solution did not work for me. What DID work was a rebuild of git-core modified to use openssl instead of gnutls.
就我而言,看来我没有使用 pycurl,所以上述解决方案对我不起作用。所做的工作是重建 git-core 修改为使用 openssl 而不是 gnutls。
Instructions are here:
说明在这里:
https://askubuntu.com/questions/186847/error-gnutls-handshake-falied
https://askubuntu.com/questions/186847/error-gnutls-handshake-failed
I had substitute "git-core" for "git" in most places, the .dsc (package information file?) turned up as git-core_1.7.0.4-1ubuntu0.2.dsc, and the .deb package came out as git-core_1.7.0.4-1ubuntu0.2_i386.deb.
我在大多数地方用“git-core”代替了“git”,.dsc(包信息文件?)变成了 git-core_1.7.0.4-1ubuntu0.2.dsc,而 .deb 包作为git-core_1.7.0.4-1ubuntu0.2_i386.deb。
回答by simno
I've had the same problem when tried sudo git fetch
from a directory my own user didn't have enough rights to. I moved repository to /tmp
and continued my work.
sudo git fetch
从我自己的用户没有足够权限的目录中尝试时,我遇到了同样的问题。我将存储库移至/tmp
并继续我的工作。
Don't forget /tmp
gets erased after reboot.
不要忘记/tmp
在重新启动后被删除。
回答by Rick
For me, it ended up being that SSL certificate was self-signed. Give this a try
对我来说,最终是 SSL 证书是自签名的。试试这个
git config --global http.sslVerify false
git config --global http.sslVerify false
回答by onalbi
In my case worked, mixing the solutions of @Rick and @m0j0
在我的情况下,混合@Rick 和@m0j0 的解决方案
First execute these commands:
首先执行这些命令:
git config --global http.sslVerify false
git config --global http.sslVerify true
After add or modify ~/.gitconfig
添加或修改后 ~/.gitconfig
nano ~/.gitconfig
Set this:
设置这个:
[httpd]
sslVersion = sslv3