Chapter 12. Configuring custom SSL/TLS certificates for Red Hat Quay on OpenShift Container Platform
When Red Hat Quay is deployed on OpenShift Container Platform, the tls component of the QuayRegistry custom resource definition (CRD) is set to managed by default. As a result, OpenShift Container Platform’s Certificate Authority is used to create HTTPS endpoints and to rotate SSL/TLS certificates.
You can configure custom SSL/TLS certificates before or after the initial deployment of Red Hat Quay on OpenShift Container Platform. This process involves creating or updating the configBundleSecret resource within the QuayRegistry YAML file to integrate your custom certificates and setting the tls component to unmanaged.
When configuring custom SSL/TLS certificates for Red Hat Quay, administrators are responsible for certificate rotation.
The following procedures enable you to apply custom SSL/TLS certificates to ensure secure communication and meet specific security requirements for your Red Hat Quay on OpenShift Container Platform deployment. These steps assumed you have already created a Certificate Authority (CA) bundle or an ssl.key, and an ssl.cert. The procedure then shows you how to integrate those files into your Red Hat Quay on OpenShift Container Platform deployment, which ensures that your registry operates with the specified security settings and conforms to your organization’s SSL/TLS policies.
-
The following procedure is used for securing Red Hat Quay with an HTTPS certificate. Note that this differs from managing Certificate Authority Trust Bundles. CA Trust Bundles are used by system processes within the
Quaycontainer to verify certificates against trusted CAs, and ensure that services like LDAP, storage backend, and OIDC connections are trusted. -
If you are adding the certificates to an existing deployment, you must include the existing
config.yamlfile in the new config bundle secret, even if you are not making any configuration changes.
12.1. Creating a Certificate Authority Copy linkLink copied to clipboard!
Use the following procedure to set up your own CA and use it to issue a server certificate for your domain. This allows you to secure communications with SSL/TLS using your own certificates.
Procedure
Generate the root CA key by entering the following command:
openssl genrsa -out rootCA.key 2048
$ openssl genrsa -out rootCA.key 2048Copy to Clipboard Copied! Toggle word wrap Toggle overflow Generate the root CA certificate by entering the following command:
openssl req -x509 -new -nodes -key rootCA.key -sha256 -days 1024 -out rootCA.pem
$ openssl req -x509 -new -nodes -key rootCA.key -sha256 -days 1024 -out rootCA.pemCopy to Clipboard Copied! Toggle word wrap Toggle overflow Enter the information that will be incorporated into your certificate request, including the server hostname, for example:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Generate the server key by entering the following command:
openssl genrsa -out ssl.key 2048
$ openssl genrsa -out ssl.key 2048Copy to Clipboard Copied! Toggle word wrap Toggle overflow Generate a signing request by entering the following command:
openssl req -new -key ssl.key -out ssl.csr
$ openssl req -new -key ssl.key -out ssl.csrCopy to Clipboard Copied! Toggle word wrap Toggle overflow Enter the information that will be incorporated into your certificate request, including the server hostname, for example:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a configuration file
openssl.cnf, specifying the server hostname, for example:Example
openssl.cnffileCopy to Clipboard Copied! Toggle word wrap Toggle overflow Use the configuration file to generate the certificate
ssl.cert: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 x509 -req -in ssl.csr -CA rootCA.pem -CAkey rootCA.key -CAcreateserial -out ssl.cert -days 356 -extensions v3_req -extfile openssl.cnfCopy to Clipboard Copied! Toggle word wrap Toggle overflow Confirm your created certificates and files by entering the following command:
ls /path/to/certificates
$ ls /path/to/certificatesCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
rootCA.key ssl-bundle.cert ssl.key custom-ssl-config-bundle-secret.yaml rootCA.pem ssl.cert openssl.cnf rootCA.srl ssl.csr
rootCA.key ssl-bundle.cert ssl.key custom-ssl-config-bundle-secret.yaml rootCA.pem ssl.cert openssl.cnf rootCA.srl ssl.csrCopy to Clipboard Copied! Toggle word wrap Toggle overflow
12.2. Creating a custom SSL/TLS configBundleSecret resource Copy linkLink copied to clipboard!
After creating your custom SSL/TLS certificates, you can create a custom configBundleSecret resource for Red Hat Quay on OpenShift Container Platform, which allows you to upload ssl.cert and ssl.key files.
Prerequisites
-
You have base64 decoded the original config bundle into a
config.yamlfile. For more information, see Downloading the existing configuration. - You have generated custom SSL certificates and keys.
Procedure
Create a new YAML file, for example,
custom-ssl-config-bundle-secret.yaml:touch custom-ssl-config-bundle-secret.yaml
$ touch custom-ssl-config-bundle-secret.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create the
custom-ssl-config-bundle-secretresource.Create the resource by entering the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Where
<config.yaml>is yourbase64 decodedconfig.yamlfile. - 2
- Where
<ssl.cert>is yourssl.certfile. - 3
- Optional. The
--from-file=extra_ca_cert_<name-of-certificate>.crt=ca-certificate-bundle.crtfield allows Red Hat Quay to recognize custom Certificate Authority (CA) files. If you are using LDAP, OIDC, or another service that uses custom CAs, you must add them via theextra_ca_certpath. For more information, see "Adding additional Certificate Authorities to Red Hat Quay on OpenShift Container Platform." - 4
- Where
<ssl.key>is yourssl.keyfile.
Optional. You can check the content of the
custom-ssl-config-bundle-secret.yamlfile by entering the following command:cat custom-ssl-config-bundle-secret.yaml
$ cat custom-ssl-config-bundle-secret.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the
configBundleSecretresource by entering the following command:oc create -n <namespace> -f custom-ssl-config-bundle-secret.yaml
$ oc create -n <namespace> -f custom-ssl-config-bundle-secret.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
secret/custom-ssl-config-bundle-secret created
secret/custom-ssl-config-bundle-secret createdCopy to Clipboard Copied! Toggle word wrap Toggle overflow Update the
QuayRegistryYAML file to reference thecustom-ssl-config-bundle-secretobject by entering the following command:oc patch quayregistry <registry_name> -n <namespace> --type=merge -p '{"spec":{"configBundleSecret":"custom-ssl-config-bundle-secret"}}'$ oc patch quayregistry <registry_name> -n <namespace> --type=merge -p '{"spec":{"configBundleSecret":"custom-ssl-config-bundle-secret"}}'Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
quayregistry.quay.redhat.com/example-registry patched
quayregistry.quay.redhat.com/example-registry patchedCopy to Clipboard Copied! Toggle word wrap Toggle overflow Set the
tlscomponent of theQuayRegistryYAML toFalseby entering the following command:oc patch quayregistry <registry_name> -n <namespace> --type=merge -p '{"spec":{"components":[{"kind":"tls","managed":false}]}}'$ oc patch quayregistry <registry_name> -n <namespace> --type=merge -p '{"spec":{"components":[{"kind":"tls","managed":false}]}}'Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
quayregistry.quay.redhat.com/example-registry patched
quayregistry.quay.redhat.com/example-registry patchedCopy to Clipboard Copied! Toggle word wrap Toggle overflow Ensure that your
QuayRegistryYAML file has been updated to use the custom SSLconfigBundleSecretresource, and that your andtlsresource is set toFalseby entering the following command:oc get quayregistry <registry_name> -n <namespace> -o yaml
$ oc get quayregistry <registry_name> -n <namespace> -o yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Confirm a TLS connection to the server and port by entering the following command:
openssl s_client -connect <quay-server.example.com>:443
$ openssl s_client -connect <quay-server.example.com>:443Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow