git 错误:gnutls_handshake() 推送失败

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

git error: gnutls_handshake() failed on push

git

提问by Wahtever

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. while accessing ... fatal: HTTP request failed

错误:gnutls_handshake() 失败:收到了长度意外的 TLS 数据包。访问时...致命:HTTP 请求失败

It was working fine, then suddenly it stopped.

它工作正常,然后突然停止。

What is the problem?

问题是什么?

Thanks

谢谢

采纳答案by niculare

It seems there is a problem with the gnutlspackage. As a workaround, you can try to compile gitwith openssl. More info on how to accomplish this you can find here.

好像是gnutls包裹有问题。作为一种解决方法,您可以尝试git使用openssl. 您可以在此处找到有关如何完成此操作的更多信息。

回答by cardonator

The linked discussion on askubuntu references a version number for git that may not match up with your own. Instead of these two lines:

askubuntu 上的链接讨论引用了 git 的版本号,该版本号可能与您自己的不匹配。而不是这两行:

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. In my case, it was 1.8.xxxxx.

您需要考虑您正在使用的 git 版本。就我而言,它是 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. This may not work perfectly if you have recompiled before.

解决这个问题的一个简单方法是复制命令的第一部分,然后按 Tab 键自动完成。如果您之前重新编译过,这可能无法完美运行。

回答by Matija Nalis

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. git was trying to push to https://www.example.comand it stopped working with error: gnutls_handshake() failed: A TLS packet with unexpected length was received

Debian 从 Wheezy 升级到 Jessie,因此 apache 从 2.2.22 升级到 2.4.10。git 试图推送到https://www.example.com并且它停止使用error: gnutls_handshake() failed: A TLS packet with unexpected length was received

Turns out, www.example.comwas resolving to both IPv4 and IPv6 addresses, and apache config was having <Virtualhost x.y.w.z:443>IPv4 address only. Changing that to <Virtualhost _default_:443>fixed the problem.

结果证明,www.example.com正在解析 IPv4 和 IPv6 地址,而 apache 配置<Virtualhost x.y.w.z:443>只有 IPv4 地址。更改它以<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 进行繁琐的重新编译后才发现它根本没有改变任何东西)

回答by StSav012

This answermight 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"

回答by Ragubathi U

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. error report and solution

我也遇到了同样的问题,后来通过在我的本地机器上禁用我的卡巴斯基防病毒软件来解决这个问题。我希望这可能对其他人有所帮助。 错误报告及解决方法