Chapter 1. Using SSL to protect connections to Red Hat Quay
This document assumes you have deployed Red Hat Quay in a single-node or highly available deployment.
To configure Quay with a self-signed certificate, you need to create a Certificate Authority (CA), then generate the required key and certificate files. You then enter those files using the Red Hat Quay config UI or command line.
1.1. Create a CA and sign a certificate Copy linkLink copied to clipboard!
Create a root CA.
openssl genrsa -out rootCA.key 2048 openssl req -x509 -new -nodes -key rootCA.key -sha256 -days 1024 -out rootCA.pem
$ openssl genrsa -out rootCA.key 2048 $ openssl req -x509 -new -nodes -key rootCA.key -sha256 -days 1024 -out rootCA.pem
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create an
openssl.cnf
file. ReplacingDNS.1
andIP.1
with the hostname and IP of the Quay server:openssl.cnf
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create key and certificates. The following set of shell commands invoke the
openssl
utility to create a key for Quay, generate a request for an Authority to sign a new certificate, and finally generate a certificate for Quay signed by the CA created earlier.Make sure the CA certificate file
rootCA.pem
and theopenssl.cnf
config file are both available.openssl genrsa -out ssl.key 2048 openssl req -new -key ssl.key -out ssl.csr -subj "/CN=quay-enterprise" -config openssl.cnf openssl x509 -req -in ssl.csr -CA rootCA.pem -CAkey rootCA.key -CAcreateserial -out ssl.cert -days 356 -extensions v3_req -extfile openssl.cnf
$ openssl genrsa -out ssl.key 2048 $ openssl req -new -key ssl.key -out ssl.csr -subj "/CN=quay-enterprise" -config openssl.cnf $ openssl x509 -req -in ssl.csr -CA rootCA.pem -CAkey rootCA.key -CAcreateserial -out ssl.cert -days 356 -extensions v3_req -extfile openssl.cnf
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
1.2. Configure Quay to use the new certificate Copy linkLink copied to clipboard!
The next step can be accomplished either in the Red Hat Quay superuser panel, or from the terminal.
1.2.1. Configure with the superuser GUI in Quay Copy linkLink copied to clipboard!
-
Set the
Server Hostname
to the appropriate value and check theEnable SSL
then upload thessl.key
andssl.cert
files: -
Save the configuration. Red Hat Quay will automatically validate the SSL certificate:
-
Restart the container
1.2.2. Configure with the command line Copy linkLink copied to clipboard!
By not using the web interface the configuration checking mechanism built into Red Hat Quay is unavailable. It is suggested to use the web interface if possible.
Copy the
ssl.key
andssl.cert
into the specifiedconfig
directory. In this example, the config directory for Quay is on a host named reg.example.com in a directory named /mnt/quay/config.NoteThe certificate/key files must be named ssl.key and ssl.cert
ls scp ssl.* root@reg.example.com:/mnt/quay/config/
$ ls ssl.cert ssl.key $ scp ssl.* root@reg.example.com:/mnt/quay/config/ [root@reg.example.com ~]$ ls /mnt/quay/config/ config.yaml ssl.cert ssl.key
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Modify the
PREFERRED_URL_SCHEME:
parameter in config.yaml fromhttp
tohttps
PREFERRED_URL_SCHEME: https
PREFERRED_URL_SCHEME: https
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Restart the Red Hat Quay container:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
1.2.3. Test the secure connection Copy linkLink copied to clipboard!
Confirm the configuration by visiting the URL from a browser https://reg.example.com/
"Your Connection is not secure" means the CA is untrusted but confirms that SSL is functioning properly. Check Google for how to configure your operating system and web browser to trust your new CA.
1.3. Configuring Docker to Trust a Certificate Authority Copy linkLink copied to clipboard!
Docker requires that custom certs be installed to /etc/docker/certs.d/
under a directory with the same name as the hostname private registry. It is also required for the cert to be called ca.crt
. Here is how to do that:
Copy the rootCA file.
cp tmp/rootCA.pem /etc/docker/certs.d/reg.example.com/ca.crt
$ cp tmp/rootCA.pem /etc/docker/certs.d/reg.example.com/ca.crt
Copy to Clipboard Copied! Toggle word wrap Toggle overflow After you have copied the rootCA.pem file,
docker login
should authenticate successfully and pushing to the repository should succeed.Copy to Clipboard Copied! Toggle word wrap Toggle overflow