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

eclipse的egit不能clone和pull github上的項目了,先開始以爲是網絡問題,於是使用最簡單的方法windows下用cmd命令 ping github.com 結果如下: 雖然網絡不穩定但不至於連接不上,而且多試幾次發現大部分時間網絡是穩定的,如果是因爲網絡問題那麼可以參考別的博文,在此不做詳細解釋。

t圖片
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.SourceBranchPage8.run(SourceBranchPage.java:324)atorg.eclipse.jface.operation.ModalContext8.run(SourceBranchPage.java:324) at org.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 就可以了。如圖:
在這裏插入圖片描述

————————————————
版權聲明:本文爲CSDN博主「Royal__Moon」的原創文章,遵循 CC 4.0 BY-SA 版權協議,轉載請附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/royal__moon/article/details/79427431

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章