eclipse无法连接github终级解决方案

重装了WIN10系统 网页可以登录github,命令行工具也可以clone push到github上,但是eclipse无法连接github

 

按照网上办法 首先ping github.com

发现请求超时 最终在host文件中加入

192.30.253.113 github.com 
192.30.252.131 github.com 
185.31.16.185 github.global.ssl.fastly.net 
74.125.237.1 dl-ssl.google.com 
173.194.127.200 groups.google.com 
192.30.252.131 github.com 
185.31.16.185 github.global.ssl.fastly.net 
74.125.128.95 ajax.googleapis.com

可以ping通,但是eclipse依然报错无法连接

然后按照网上提示

在eclipse-window-preferences-team-git-configuration 中add entry,设置key为http.sslVerify,值为false,然后apply

如下

问题依然无法解决

继续百度参考https://blog.csdn.net/royal__moon/article/details/79427431 发现可能ssl协议的版本不对

查看eclipse错误日志

org.eclipse.jgit.api.errors.TransportException: https://github.com/xukai19891114/ssm.git: cannot open git-upload-pack
	at org.eclipse.jgit.api.LsRemoteCommand.execute(LsRemoteCommand.java:223)
	at org.eclipse.jgit.api.LsRemoteCommand.call(LsRemoteCommand.java:159)
	at org.eclipse.egit.core.op.ListRemoteOperation.run(ListRemoteOperation.java:99)
	at org.eclipse.egit.ui.internal.clone.SourceBranchPage$8.run(SourceBranchPage.java:339)
	at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:119)
Caused by: org.eclipse.jgit.errors.TransportException: https://github.com/xukai19891114/ssm.git: cannot open git-upload-pack
	at org.eclipse.jgit.transport.TransportHttp.connect(TransportHttp.java:518)
	at org.eclipse.jgit.transport.TransportHttp.openFetch(TransportHttp.java:296)
	at org.eclipse.jgit.api.LsRemoteCommand.execute(LsRemoteCommand.java:202)
	... 4 more
Caused by: javax.net.ssl.SSLException: Received fatal alert: protocol_version
	at sun.security.ssl.Alerts.getSSLException(Unknown Source)
	at sun.security.ssl.Alerts.getSSLException(Unknown Source)
	at sun.security.ssl.SSLSocketImpl.recvAlert(Unknown Source)
	at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
	at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
	at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
	at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
	at sun.net.www.protocol.https.HttpsClient.afterConnect(Unknown Source)
	at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
	at java.net.HttpURLConnection.getResponseCode(Unknown Source)
	at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(Unknown Source)
	at org.eclipse.jgit.transport.http.JDKHttpConnection.getResponseCode(JDKHttpConnection.java:98)
	at org.eclipse.jgit.util.HttpSupport.response(HttpSupport.java:174)
	at org.eclipse.jgit.transport.TransportHttp.connect(TransportHttp.java:469)
	... 6 more

问题的关键:Caused by: javax.net.ssl.SSLException: Received fatal alert: protocol_version

果然是ssl协议的版本不对

原因是2018年2月8日后禁止通过TLSv1.1协议连接https://github.com 和 https://api.github.com.

如果是新版的eclipse默认是1.8的不会有这个问题,因为JDK1.8默认支持TLSv1.2,JDK1.7默认是TLSv1.1,所以需要将eclipse中的TLSv1改为TLSv1.2。1.7的eclipse默认是TLSv1.1

解决 

打开eclipse安装目录下的eclipse.ini添加一句:-Dhttps.protocols=TLSv1,TLSv1.1,TLSv1.2  就可以了。如图:

 

 

 

  • 2
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值