您的位置:首页 > 编程语言 > Java开发

最新eclipse连接github cannot open git-upload-pack(git-receive-pack)

2018-03-02 23:15 399 查看
  最近上班发现eclipse的egit不能clone和pull github上的项目了,先开始以为是网络问题,于是使用最简单的方法windows下用cmd命令 ping github.com 结果如下: 虽然网络不稳定但不至于连接不上,而且多试几次发现大部分时间网络是稳定的,如果是因为网络问题那么可以参考别的博文,在此不做详细解释。

eclipse报错信息为cannot open git-upload-pack,如下图:不管是下面的哪一种情况其实都是一个问题,下面详细分析。






根据以上异常信息去百度,基本上的回答都是告你在eclipse-window-preferences-team-git-configuration中add entry,设置key为http.sslVerify,值为false,然后apply,就解决了,然而并不是这么简单。。。。当然这一步还是要做的,为了确保后面的操作能成功吧。后来看到这篇博文http://blog.csdn.net/uikoo9/article/details/79383201,他提醒到会是ssl协议的版本不对。查看eclipse的错误日志,找到如下异常信息:MESSAGE https://github.com/apache/hadoop.git: cannot open git-upload-pack!STACK 0
org.eclipse.jgit.api.errors.TransportException: https://github.com/apache/hadoop.git: cannot open git-upload-pack
at org.eclipse.jgit.api.LsRemoteCommand.call(LsRemoteCommand.java:196)
at org.eclipse.egit.core.op.ListRemoteOperation.run(ListRemoteOperation.java:99)
at org.eclipse.egit.ui.internal.clone.SourceBranchPage$8.run(SourceBranchPage.java:324)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:122)或者
org.eclipse.jgit.errors.TransportException: https://github.com/XXXX/XXXX.git: cannot open git-receive-pack
.......
... 3 more最重要的异常信息其实是:
Caused by: javax.net.ssl.SSLException: Received fatal alert: protocol_version就是ssl协议的版本不对,上面提到的博客还贴出了github的通知:2018年2月8日后禁止通过TLSv1.1协议连接https://github.com 和 https://api.github.com.原文地址为https://githubengineering.com/crypto-removal-notice/原文截取为:February 8, 2018 we’ll start disabling the following:
TLSv1
/
TLSv1.1
: This applies to all HTTPS connections, including web, API, and git connections to https://github.com and https://api.github.com.
diffie-hellman-group1-sha1
: This applies to all SSH connections to github.com
diffie-hellman-group14-sha1
: This applies to all SSH connections to github.com
总结原因就是:我的eclipse是4.4.0版的并不是最新版的,因此我的ecplise的默认JDK为JDK1.7,当然最新版的eclipse默认是1.8的不会有这个问题,因为JDK1.8默认支持TLSv1.2,JDK1.7默认是TLSv1.1,所以需要将eclipse中的TLSv1改为TLSv1.2。怎么改呢?其实很简单,网上答案千奇百怪但是如果eclipse的默认JDK是1.7的就简单,如果是1.7以下的请另外百度。。。。打开eclipse安装目录下的eclipse.ini添加一句:-Dhttps.protocols=TLSv1,TLSv1.1,TLSv1.2  就可以了。如图:
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: