重装了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