How to import MariaDB apt repository key behind an outgoing HTTP proxy

Written by - 0 comments

Published on - Listed in Linux MariaDB Internet


When installing MariaDB from their official apt repositories or mirrors, the documentation mentions the following commands to add the APT repository on a Debian Buster system:

sudo apt-get install software-properties-common dirmngr
sudo apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc'
sudo add-apt-repository 'deb [arch=amd64,arm64,ppc64el] https://mirror.mva-n.net/mariadb/repo/10.4/debian buster main'

However there's a catch when an outgoing http(s) proxy is used!

apt-key error: unable to fetch URI

When using an outgoing http proxy, the apt-key adv command fails, even though APT's configuration contains a valid configuration for using a http proxy:

root@debian:~# cat /etc/apt/apt.conf.d/10proxy
Acquire::http::Proxy "http://192.168.7.1:8888";
Acquire::https::Proxy "http://192.168.7.1:8888";

root@debian:~# sudo apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc'
Executing: /tmp/apt-key-gpghome.3k01JC7Nya/gpg.1.sh --fetch-keys https://mariadb.org/mariadb_release_signing_key.asc
gpg: requesting key from 'https://mariadb.org/mariadb_release_signing_key.asc'
gpg: WARNING: unable to fetch URI https://mariadb.org/mariadb_release_signing_key.asc: Connection refused

It seems as if apt-key is ignoring the proxy configuration. The same error also happens when using the http proxy in environment variable:

root@debian:~# export https_proxy=http://192.168.7.1:8888
root@debian:~# export http_proxy=http://192.168.7.1:8888
root@debian:~# sudo apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc'
Executing: /tmp/apt-key-gpghome.ZzWxUKXMku/gpg.1.sh --fetch-keys https://mariadb.org/mariadb_release_signing_key.asc
gpg: requesting key from 'https://mariadb.org/mariadb_release_signing_key.asc'
gpg: WARNING: unable to fetch URI https://mariadb.org/mariadb_release_signing_key.asc: Connection refused

So is apt-key actually ignoring all http proxy settings?

Kind of yes, kind of no.

http vs. hkp

The APT proxy settings and http proxy environment variables are applied when accessing URLs starting with http:// or https:// - using the http or https protocols. But fetching the apt keys is using a different protocol in the background: hkp (the OpenPGP HTTP Keyserver Protocol). Although hkp (or hkps) use the same ports as http and https, the protocol is different and this causes to "ignore" the http/https proxy settings.

Using proxy server in hkp request

But how does one tell the apt-key command to use a http proxy instead? The best way found so far is the accepted solution, provided by Rui F. Ribeiro, on the StackExchange question: debian - Unable to add gpg key with apt-key behind a proxy. By appending the parameter --keyserver-options, a http-proxy can be defined. But in that example the apt-key command actually connected to a keyserver using the --keyserver parameter. For the MariaDB case above, the GPG key is directly requested without going through a keyserver. Can this still be applied? Yes!

Looking for MariaDB GPG results in a dedicated MariaDB KB article: GPG. Here the relevant information about the used GPG keys (to sign the packages) are shown, including the relevant GPG Key ID on the Ubuntu keyservers:

With this information, we can now run apt-key command again with the http-proxy option:

root@debian:~# sudo apt-key adv --keyserver keyserver.ubuntu.com --keyserver-options http-proxy=http://192.168.7.1:8888 --recv-keys 0xF1656F24C74CD1D8
Executing: /tmp/apt-key-gpghome.02G0vZChBs/gpg.1.sh --keyserver keyserver.ubuntu.com --keyserver-options http-proxy=http://192.168.7.1:8888 --recv-keys 0xF1656F24C74CD1D8
gpg: key F1656F24C74CD1D8: public key "MariaDB Signing Key <signing-key@mariadb.org>" imported
gpg: Total number processed: 1
gpg:               imported: 1

Success!


Add a comment

Show form to leave a comment

Comments (newest first)

No comments yet.

RSS feed

Blog Tags:

  AWS   Android   Ansible   Apache   Apple   Atlassian   BSD   Backup   Bash   Bluecoat   CMS   Chef   Cloud   Coding   Consul   Containers   CouchDB   DB   DNS   Database   Databases   Docker   ELK   Elasticsearch   Filebeat   FreeBSD   Galera   Git   GlusterFS   Grafana   Graphics   HAProxy   HTML   Hacks   Hardware   Icinga   Influx   Internet   Java   KVM   Kibana   Kodi   Kubernetes   LVM   LXC   Linux   Logstash   Mac   Macintosh   Mail   MariaDB   Minio   MongoDB   Monitoring   Multimedia   MySQL   NFS   Nagios   Network   Nginx   OSSEC   OTRS   Office   OpenSearch   PGSQL   PHP   Perl   Personal   PostgreSQL   Postgres   PowerDNS   Proxmox   Proxy   Python   Rancher   Rant   Redis   Roundcube   SSL   Samba   Seafile   Security   Shell   SmartOS   Solaris   Surveillance   Systemd   TLS   Tomcat   Ubuntu   Unix   VMWare   VMware   Varnish   Virtualization   Windows   Wireless   Wordpress   Wyse   ZFS   Zoneminder