简体   繁体   English

git错误:gnutls_handshake()在推送时失败

[英]git error: gnutls_handshake() failed on push

I have been using git for a while with no problems, then suddenly it started throwing this error when using git push : 我已经使用git一段时间没有问题,然后突然它开始抛出这个错误使用git push

error: gnutls_handshake() failed: A TLS packet with unexpected length was received. 错误:gnutls_handshake()失败:收到了意外长度的TLS数据包。 while accessing ... fatal: HTTP request failed 访问...致命:HTTP请求失败

It was working fine, then suddenly it stopped. 工作正常,然后突然停了下来。

What is the problem? 问题是什么?

Thanks 谢谢

It seems there is a problem with the gnutls package. 似乎gnutls包有问题。 As a workaround, you can try to compile git with openssl . 作为一种解决方法,您可以尝试使用openssl编译git More info on how to accomplish this you can find here . 有关如何完成此任务的更多信息,请点击此处

The linked discussion on askubuntu references a version number for git that may not match up with your own. 关于askubuntu的链接讨论引用了可能与您自己不匹配的git的版本号。 Instead of these two lines: 而不是这两行:

sudo dpkg-source -x git_1.7.9.5-1.dsc
cd git_1.7.9.5 8.

you need to account for the version of git you're using. 你需要考虑你正在使用的git版本。 In my case, it was 1.8.xxxxx. 就我而言,它是1.8.xxxxx。

sudo dpkg-source -x git_<git-version-number>.dsc
cd git_<git-version-number>

An easy way to get around this is to just copy the first part of the command and then hit Tab to autocomplete. 解决此问题的简单方法是复制命令的第一部分,然后单击Tab键以自动完成。 This may not work perfectly if you have recompiled before. 如果您之前已重新编译,这可能无法正常工作。

In my case same error was caused by completely different thing. 在我的情况下,同样的错误是由完全不同的事情引起的

Debian was upgraded from Wheezy to Jessie, and thus apache was upgraded 2.2.22 to 2.4.10. Debian从Wheezy升级到Jessie,因此apache升级到2.2.22到2.4.10。 git was trying to push to https://www.example.com and it stopped working with error: gnutls_handshake() failed: A TLS packet with unexpected length was received git试图推送到https://www.example.com并且它停止了error: gnutls_handshake() failed: A TLS packet with unexpected length was received

Turns out, www.example.com was resolving to both IPv4 and IPv6 addresses, and apache config was having <Virtualhost xywz:443> IPv4 address only. 事实证明, www.example.com正在解析IPv4和IPv6地址,而apache配置只有<Virtualhost xywz:443> IPv4地址。 Changing that to <Virtualhost _default_:443> fixed the problem. 将其更改为<Virtualhost _default_:443>修复了问题。

(just so if it helps somebody else with same problem... only found it after the tedious recompile of git with openssl didn't change anything at all) (只是如果它有助于其他人有同样的问题...只有在使用openssl进行繁琐的git重新编译之后才发现它并没有改变任何东西)

This answer might help. 这个答案可能有帮助。 I was surprised that the problems are nowhere to be linked together although the question is old. 我很惊讶这些问题无处可归,尽管这个问题已经过去了。

Just to be sure the usefull info won't get lost, I copy a brief solution from the question: 为了确保有用的信息不会丢失,我从问题中复制一个简短的解决方案:

hostname=XXX
port=443
trust_cert_file_location=`curl-config --ca`

sudo bash -c "echo -n | openssl s_client -showcerts -connect $hostname:$port 2>/dev/null  | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' >> $trust_cert_file_location"

I have also faced the same issue which was fixed later by disabling my Kaspersky antivirus in my local machine. 我也面临同样的问题,后来通过在我的本地机器上禁用我的卡巴斯基反病毒软件来解决这个问题。 I hope this may be helpful to others. 我希望这可能对其他人有所帮助。 错误报告和解决方案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM