git clone 错误:gnutls_handshake() 失败:收到了意外的 TLS 数据包

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/51088635/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 05:18:24  来源:igfitidea点击:

git clone error: gnutls_handshake() failed: An unexpected TLS packet was received

gitubuntu-18.04

提问by Rock

I am running Ubuntu 18.04 LTS on armv7l. I am running git clone inside a proxy (I got the proxy variables set properly), but now I get this;

我在 armv7l 上运行 Ubuntu 18.04 LTS。我在代理中运行 git clone (我正确设置了代理变量),但现在我明白了;

fatal: unable to access '<my_git>.git/': gnutls_handshake() failed: An unexpected TLS packet was received.

fatal: unable to access '<my_git>.git/': gnutls_handshake() failed: An unexpected TLS packet was received.

It used to work in Ubuntu 16.04. I have checked this solutionbut it does not work for me. All I am trying to do is to git clone.

它曾经在 Ubuntu 16.04 中工作。我已经检查了这个解决方案,但它对我不起作用。我想要做的就是 git clone。

回答by Rock

Finally found the answer. It seems that I have to do:

终于找到了答案。看来我必须这样做:

git config --global http.proxy http://<my_proxy>:<my_port>
git config --global https.proxy https://<my_proxy>:<my_port>

Spent quick some time on this but luckily it works in the end. I thought this would be hard to fix but it turns out to be some commands that I never did before on Ubuntu 16.04.

在这方面花了一些时间,但幸运的是它最终奏效了。我认为这很难解决,但事实证明这是我以前在 Ubuntu 16.04 上从未执行过的一些命令。

回答by nullbyte91

Might be issue with gnutlsPackage. we have to compile a gitPackage with openssl instead of gnutls. Follow the below steps,

可能是gnutls包的问题。我们必须用 openssl 而不是 gnutls编译一个git包。按照以下步骤,

sudo apt-get install -y build-essential fakeroot dpkg-dev
sudo apt-get -y build-dep git
sudo apt-get install -y libcurl4-openssl-dev

mkdir git-openssl
cd git-openssl
apt-get source git
cd git-*
sed -i -e 's/libcurl4-gnutls-dev/libcurl4-openssl-dev/g' 
./debian/control
sed -i -- '/TEST\s*=\s*test/d' ./debian/rules
sudo dpkg-buildpackage -rfakeroot -b
sudo dpkg -i git_2.7.4-0ubuntu1.6_arm64.deb

#CleanUp
cd ../../
sudo rm -rf git-openssl

You can follow This Bogor You can find simple script here to do that

你可以按照这个沼泽或者你可以在这里找到简单的脚本来做到这一点