Tag Archives: The TLS connection was non-properly terminated

[Solved] Git Clone Error: The TLS connection was non-properly terminated.

Operating system: Ubuntu 18.04

Test time: November 18, 2021

Problem Description:

Recently, the author encountered the following problems when downloading the repository on GitHub by using the GIT clone command, resulting in cloning failure

$ git clone https://github.com/pjreddie/darknet
Clone to 'darknet'...
fatal: unable to access 'https://github.com/pjreddie/darknet/': gnutls_handshake() failed: The TLS connection was non-properly terminated.

Solution:

Modify the HTTPS of the warehouse connection to git to clone

$ git clone https://github.com/pjreddie/darknet

Git Error: failed: The TLS connection was non-properly terminated

Tencent virtual machine doesn’t know why it can’t git clone, and an error is reported:

fatal: unable to access 'https://github.com/asdf-vm/asdf-plugins.git/': gnutls_handshake() failed: The TLS connection was non-properly terminated.
plugin ruby not found in repository

After checking, you need to use libcurl4 OpenSSL dev to replace gnutls to compile 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

If there is an error that the source code cannot be found, use the command sudo vim /etc/apt/sources.list to open the file and uncomment the line with deb_src, save and run sudo apt update, and then execute the last command above.
Then:

sudo apt-get install libcurl4-openssl-dev
sudo dpkg-source -x git_2.17.1-1ubuntu0.9.dsc
cd git_2.17.1 # Actual version may differ

Then edit the Debian/control file and use the command sudo VIM deebian/control to change all libcurl4 gnutls dev to libcurl4 OpenSSL dev. (I only met one libcurl4 gnutls dev here)
then run the command:

# This step will take a long time, wait patiently
sudo dpkg-buildpackage -rfakeroot -b

sudo dpkg -i git_2.17.1-1ubuntu0.9_amd64.deb

That’s it. Just git again

+ git clone https://github.com/asdf-vm/asdf.git /root/.asdf --depth 1
Cloning into '/root/.asdf'...
+ echo -e '\n. $HOME/.asdf/asdf.sh'
+ echo -e '\n. $HOME/.asdf/completions/asdf.bash'
+ echo -e 'legacy_version_file = yes'
+ asdf plugin-add ruby
initializing plugin repository...Cloning into '/root/.asdf/repository'...

————————————————————————————Renew

I did it again in the afternoon. There was still the same problem. Finally, the reset agent solved it perfectly

git config --global --unset https.https://github.com.proxy 
git config --global --unset http.https://github.com.proxy