Add better error management on fwrite
Add tls support for 1.2 and 1.3 version of docker