使用 Git 同步时出现ssl错误

时间:2023-03-09 16:43:32
使用 Git 同步时出现ssl错误

错误提示

  • fatal: unable to access 'https://android.googlesource.com/platform/prebuilts/qemu-kernel/': gnutls_handshake() failed: Error in the pull function. fatal: unable to access

  • fatal: unable to access 'https://android.googlesource.com/platform/frameworks/opt/net/ethernet/': gnutls_handshake() failed: The TLS connection was non-properly terminated.

原因分析

由系统的 git 默认使用的 libcurl4-gnutls-dev 造成,可以使用openssl解决.

解决办法

安装编译环境
sudo apt-get update
sudo apt-get install build-essential fakeroot dpkg-dev libcurl4-openssl-dev
sudo apt-get build-dep git
mkdir git-openssl && cd git-openssl
sudo apt-get source git
替换为 libcurl4-openssl-dev
dpkg-source -x git_2.11.0-4.dsc
gksu sed -i 's/libcurl4-gnutls-dev/libcurl4-openssl-dev/g' debian/control
重构.deb
  • 删除 debian/rules 中的TEST=test行gksu sed -i 's/TEST=test//g' debian/control
  • 重构sudo dpkg-buildpackage -rfakeroot -b
  • 安装sudo dpkg -i ../git_2.11.0-4_amd64.deb