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.youkuaiyun.com/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.
r
u
n
(
S
o
u
r
c
e
B
r
a
n
c
h
P
a
g
e
.
j
a
v
a
:
324
)
a
t
o
r
g
.
e
c
l
i
p
s
e
.
j
f
a
c
e
.
o
p
e
r
a
t
i
o
n
.
M
o
d
a
l
C
o
n
t
e
x
t
8.run(SourceBranchPage.java:324) at org.eclipse.jface.operation.ModalContext
8.run(SourceBranchPage.java:324)atorg.eclipse.jface.operation.ModalContextModalContextThread.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 就可以了。如图:
————————————————
版权声明:本文为优快云博主「Royal__Moon」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.youkuaiyun.com/royal__moon/article/details/79427431