"The TLS connection was non-properly terminated" in Windows 10 Linux Subsystem

inquam picture inquam · Apr 13, 2018 · Viewed 9k times · Source

I recently reinstalled my computer and installed Linux Subsystem which I always do. When I wanted to run composer I noticed something strange. It failed because it was unable to establish a TLS connection.

[RuntimeException] Failed to clone https://github.com/inquam/colors.php via https, ssh protocols, aborting.

  • https://github.com/inquam/colors.php Cloning into bare repository '/home/danlil/.cache/composer/vcs/https---github.com-inquam-colors.php'... fatal: unable to access 'https://github.com/inquam/colors.php/': gnutls_handshake() failed: The TLS connection was non-properly terminated.

  • [email protected]:inquam/colors.php Cloning into bare repository '/home/danlil/.cache/composer/vcs/https---github.com-inquam-colors.php'... Warning: Permanently added the RSA host key for IP address '192.30.253.113' to the list of known hosts. Permission denied (public key). fatal: Could not read from remote repository.

    Please make sure you have the correct access rights and the repository exists.

After trying a bit more I noticed that this happens no matter which GitHub repository I try to clone via https and it also applies to any connection via curl or other commands that connect using TLS. I have tried several proposed solutions in other threads like updating ca-certificates, reinstalling Ubuntu on Windows 10, downloading https://curl.haxx.se/ca/cacert.pem and pointing to that in php.ini, making sure ipv6 is not the preferred method in Ubuntu etc.

Previously when I have used Ubuntu in Windows 10 I have just installed and everything has worked without any issues like this at all.

Update: After testing a bit more I decided to test install the Windows version of GIT and remove the Linux one since the Linux Subsystem can now run Windows binaries. It worked fine. Then Composer wanted to download https://packagist.org/packages.json and failed once again due to TLS. So TLS doesn't work in Bash when running Linux versions of the programs but work fine with WIndows versions.

[Composer\Downloader\TransportException] The "https://packagist.org/packages.json" file could not be downloaded: Failed to enable crypto failed to open stream: operation failed

To demonstrate it seems to affect every native Bash application I tested the following too

me@DATHREADRIPPER:/mnt/e/src$ php -r 'echo file_get_contents("https://packagist.org/packages.json");'

PHP Warning: file_get_contents(): Failed to enable crypto in Command line code on line 1 PHP Warning: file_get_contents(https://packagist.org/packages.json): failed to open stream: operation failed in Command line code on line 1

Update: For me, this was finally solved when I installed the newer Ubuntu 18.04 in Windows from the Windows store.

Answer