apt update: Could not handshake: An unexpected TLS packet was received
Solution 1:
Check if the proxy is also set for https. Since curl
is working with https, I assume, that somewhere a https_proxy
variable is set (e.g. ~/.bashrc
). apt
requires a proxy configuration in /etc/apt/apt.conf
or /etc/apt/apt.conf.d/
. You need to specify the proxy for all protocols:
# e.g. in file /etc/apt/apt.conf.d/05proxy
Acquire::http::proxy "http://192.168.0.1:3128/";
Acquire::https::proxy "http://192.168.0.1:3128/";
Acquire::ftp::proxy "http://192.168.0.1:3128/";
Also keep in mind, if the proxy configuration is only set for the sdnc-dev
user, you need sudo -E
to expose the environment to the root user.
Solution 2:
I got the same error when using apt-get update
, with Ubuntu 20.04 LTS.
I have configured the proxy during the installation, in this way the proxy urls are in /etc/apt/apt.conf.d/05proxy
In my case I wrongly configured the proxy URL (for my organization) and need to edit 05proxy
and change https://proxy.mydom.it
to http://proxy.mydom.it
Wrong config:
Acquire::http::proxy "https://proxy.mydom.it:8080";
Acquire::https::proxy "https://proxy.mydom.it:8080";
Good config:
Acquire::http::proxy "http://proxy.mydom.it:8080";
Acquire::https::proxy "http://proxy.mydom.it:8080";
Turning https to http, in my case, fixed the TLS error