Your own TLS Certificate¶
The DICOS API Gateway Manager always uses HTTPS (port 10443 in the container, see A custom TLS port). Without your own certificate it uses a self-signed one, which browsers and clients do not trust.
The Self-Signed Certificate¶
Without your own certificate, the API Gateway Manager creates a self-signed certificate for your installation when it starts for the first time:
- It is stored in the folder
/opt/aagmasssl-cert-generated.keyandssl-cert-generated.pemand used again on every start. - It contains the host name of the container,
localhostanddagm.dicos.local, and is valid for 825 days. It is renewed automatically on the start of the container 30 days before it expires. - Every installation gets its own private key.
If the folder /opt/aagm is not writable, the API Gateway Manager uses the self-signed certificate of the image and writes a warning to the log. Its private key is the same in every installation: provide your own certificate in that case.
To create a new self-signed certificate, delete the two files ssl-cert-generated.* and restart the container.
To go back from your own certificate to the self-signed one, delete the two files ssl-cert-aagm.* and restart the container.
See the Certificate in the API Gateway Manager¶
The tab TLS Certificate under Configuration shows the certificate that the API Gateway Manager serves: where it comes from (your own certificate, the self-signed certificate of this installation or the one of the image), subject, issuer, alternative names, validity, SHA-256 fingerprint and the number of certificates sent (the certificate and its intermediate CAs). It warns if the certificate expires within 30 days or has expired, if it is the certificate of the image, and if there is another certificate in the config folder that is only used after a restart of the container.
The certificate can only be changed via the files described below, not in the tab. 30 days before it expires, the Advisor also shows the advice TLS certificate of the API Gateway Manager expires.
Use Your Own Certificate¶
- Copy two files to the folder
/opt/aagmof your installation (the volume that holds theConfiguration.xml):ssl-cert-aagm.key: the private key, in PEM format and without a passphrasessl-cert-aagm.pem: the certificate in PEM format, followed by the certificates of the intermediate CAs (first your certificate, then the CA that issued it, and so on; the root CA is not needed). Without the intermediate CAs, clients see an incomplete chain and do not trust the certificate.
- Restart the container of the API Gateway Manager, e.g. with
docker compose up -d --force-recreate dagm(dagmis the name of the service in yourdocker-compose.yml). The certificate is read when the container starts.
The certificate must contain the host name under which the API Gateway Manager is called as subject alternative name (SAN), e.g. dagm.example.com.
The API Gateway Manager does not renew your own certificate itself. Before it expires, replace the two files and restart the container again, by hand or automatically, see below.
Renew the Certificate Automatically¶
The API Gateway Manager reads the certificate when the container starts. To renew it automatically, let another tool request it, e.g. via ACME from your company CA (Secardeo certACME, EJBCA, step-ca and others) or a public CA:
-
ACME client on the Docker host, e.g. acme.sh, certbot or lego: it writes the two files to
/opt/aagmand restarts the container after every renewal. Example with acme.sh, DNS-01 via a DNS server with dynamic updates:acme.sh --issue --server https://acme.example.com/directory -d dagm.example.com --dns dns_nsupdate acme.sh --install-cert -d dagm.example.com \ --key-file /opt/aagm/ssl-cert-aagm.key \ --fullchain-file /opt/aagm/ssl-cert-aagm.pem \ --reloadcmd "docker compose -f /path/to/docker-compose.yml up -d --force-recreate dagm"acme.sh renews the certificate in time by itself (cron job). The full chain file contains the certificate and the intermediate CAs, as the API Gateway Manager needs it. The API Gateway Manager is not reachable for a few seconds while the container restarts.
-
Reverse proxy in front of the API Gateway Manager, e.g. Traefik, Caddy or nginx with ACME: the proxy terminates TLS and renews its certificate itself, the API Gateway Manager behind it keeps its self-signed certificate (the proxy connects to port 10443). No restart of the API Gateway Manager is needed.
-
Kubernetes and OpenShift: see below.
Do Not Open the HTTP Port¶
Besides HTTPS on port 10443, the container also answers plain HTTP on port 8080, without a redirect to HTTPS. Do not publish port 8080 (e.g. as port 80): users would sign in unencrypted. Publish only port 10443 (e.g. as port 443), as in the installation guide. An ingress that terminates TLS may use port 8080 inside the cluster.
Kubernetes and OpenShift¶
If the API Gateway Manager runs behind an ingress or a route that terminates TLS, the clients see the certificate of the ingress, not the one of the API Gateway Manager. Configure your certificate on the ingress then, e.g. renewed automatically by cert-manager via ACME. The certificate of the API Gateway Manager is only used between the ingress and the container.
To use your own certificate in the container anyway, mount the two files into /opt/aagm, e.g. from a secret as in the OpenShift example.
The container reads the files only when it starts, and files mounted with subPath (as in the example) are not updated when the secret changes: restart the pod after a renewal, e.g. automatically with a tool like Reloader.