方案|解決git gnutls_handshake失敗
電腦不知道為什麼不能git clone,報錯:
$ git clone https://github.com/ShixiangWang/VSHunter 正克隆到 'VSHunter'... fatal: unable to access 'https://github.com/ShixiangWang/VSHunter/': gnutls_handshake() failed: The TLS connection was non-properly terminated.
查了下需要使用libcurl4-openssl-dev替換gnutls對git進行編譯。
sudo apt-get install build-essential fakeroot dpkg-dev mkdir ~/git-openssl cd ~/git-openssl sudo apt-get source git sudo apt-get build-dep git
如果出現找不到原始碼的報錯,使用命令sudo vim /etc/apt/sources.list開啟檔案並取消帶deb_src那一行的註釋,儲存後執行sudo apt update,然後再執行上面最後一條命令
接著:
sudo apt-get install libcurl4-openssl-dev sudo dpkg-source -x git_2.17.0-1.dsc cd git_2.17.0 #實際版本可能不同
然後編輯檔案debian/control
,使用命令sudo vim deebian/control
,將全部的libcurl4-gnutls-dev改為libcurl4-openssl-dev 。
接著執行命令:
sudo dpkg-buildpackage -rfakeroot -b # (if it's failing on test, you can remove the line TEST=test from the file debian/rules) sudodpkg -i../git_2.17.0-1_amd64.deb
一般情況下到這就修復了這個問題了,但此時我還是不能進行克隆。
$ git clone https://github.com/ShixiangWang/VSHunter.git 正克隆到 'VSHunter'... fatal: unable to access 'https://github.com/ShixiangWang/VSHunter.git/': OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to 127.0.0.1:45077
通過搜尋,我搞明白 git也要配置網路代理,而我使用了藍燈,代理就出問題了。
進行以下配置:
git config --global http.proxy 'socks5://127.0.0.1:45077' git config --global https.proxy 'socks5://127.0.0.1:45077' git config --global http.proxy 'http://127.0.0.1:45077' git config --global https.proxy 'http://127.0.0.1:45077' 注意埠號也設定代理的埠號,不同vpn,不同系統埠號可能不同。
現在我就能夠正常克隆了:
$ git clone https://github.com/ShixiangWang/VSHunter.git 正克隆到 'VSHunter'... remote: Enumerating objects: 95, done. remote: Counting objects: 100% (95/95), done. remote: Compressing objects: 100% (57/57), done. remote: Total 591 (delta 54), reused 64 (delta 34), pack-reused 496 接收物件中: 100% (591/591), 149.13 MiB | 848.00 KiB/s, 完成. 處理 delta 中: 100% (361/361), 完成.
一些代理相關命令:
#檢視代理 git config --global http.proxy #刪除代理 git config --global --unset http.proxy git config --global --unset https.proxy
參考文章:
- ofollow,noindex">解決git gnutls_handshake失敗
- github 遇到 OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443問題