How to enable HTTPS protocol for package managers using libapt-pkg library

Enable HTTPS (Hypertext Transfer Protocol Secure) for package managers using libapt-pkg library.

You can easily identify that HTTPS transport is missing during regular package management operations as error messages are very clear.

$ sudo apt-get update
Get:1 stretch/updates InRelease [63.0 kB]
Ign:2 stretch InRelease
Hit:3 stretch Release
Get:4 stretch/updates/main amd64 Packages [269 kB]
Get:5 stretch/updates/main Translation-en [118 kB]
Fetched 450 kB in 0s (961 kB/s)
Reading package lists... Done
E: The method driver /usr/lib/apt/methods/https could not be found.
N: Is the package apt-transport-https installed?
E: Failed to fetch
E: Some index files failed to download. They have been ignored, or old ones used instead.

Install missing apt-transport-https package.

$ sudo apt-get install apt-transport-https
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
The following NEW packages will be installed:
  apt-transport-https libcurl3-gnutls
0 upgraded, 2 newly installed, 0 to remove and 6 not upgraded.
Need to get 460 kB of archives.
After this operation, 873 kB of additional disk space will be used.
Do you want to continue? [Y/n]
Get:1 stretch/main amd64 libcurl3-gnutls amd64 7.52.1-5+deb9u3 [289 kB]
Get:2 stretch/main amd64 apt-transport-https amd64 1.4.8 [171 kB]
Fetched 460 kB in 0s (9505 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package libcurl3-gnutls:amd64.
(Reading database ... 17075 files and directories currently installed.)
Preparing to unpack .../libcurl3-gnutls_7.52.1-5+deb9u3_amd64.deb ...
Unpacking libcurl3-gnutls:amd64 (7.52.1-5+deb9u3) ...
Selecting previously unselected package apt-transport-https.
Preparing to unpack .../apt-transport-https_1.4.8_amd64.deb ...
Unpacking apt-transport-https (1.4.8) ...
Setting up libcurl3-gnutls:amd64 (7.52.1-5+deb9u3) ...
Processing triggers for libc-bin (2.24-11+deb9u1) ...
Setting up apt-transport-https (1.4.8) ...

Now you can use HTTPS protocol without any problems.

$ sudo apt-get update
Hit:1 stretch/updates InRelease
Ign:2 stretch InRelease
Hit:3 stretch Release
Ign:4 stretch InRelease
Hit:6 stretch Release
Reading package lists... Done

About Milosz Galazka

Milosz is a Linux Foundation Certified Engineer working for a successful Polish company as a system administrator and a long time supporter of Free Software Foundation and Debian operating system. He is also open for new opportunities and challenges.