Prerequisites
- Docker available locally
- Token to pull images from the Minimus image registry
- A working directory for keystores and certs
Deploy Keycloak for production
The following explains how to deploy Keycloak in either HTTPS mode or HTTP-dev mode.1
Create a BCFKS Keystore (FIPS‑approved)
Use If you encounter a permissions-related error, grant write permissions to your working directory and rerun the above command:Verify the BCFKS keystore:
keytool from the Keycloak FIPS image to generate a BCFKS keystore and keypair (provider CCJ):Create BCFKS keystore
2
Generate a Local CA and Server Certificate (PEM)
To set up HTTPS using PEM files (instead of a keystore), follow the steps to create a local CA and sign a server certificate.
- Generate a private key for the Certificate Authority (CA):
- Create a root self-signed CA certificate:
- Generate a Server RSA private key for Keycloak:
- CSR for your Keycloak host (edit CN):
- Create a file
keycloak.extcontaining certificate extension settings for a TLS certificate: - Sign a Certificate Signing Request (CSR) with your CA:
- Run
lsto verify that the following certificates were created:- CA:
myCA.crt,myCA.key,myCA.srl - Server (PEM):
keycloak.crt,keycloak.key,keycloak.csr,keycloak.ext
- CA:
3
Create a BCFKS Truststore (to trust your CA)
Import your CA into a BCFKS truststore:
Import CA into truststore
4
Run Keycloak
To run in dev mode, deploy Keycloak in HTTP:Visit the Keycloak console (UI) at http://localhost:8080.To run in production, deploy Keycloak with the truststore in HTTPS:Visit the Keycloak console (UI) in HTTPS at https://localhost:8443.
Run Keycloak in HTTP
Even in HTTP mode, FIPS checks still apply to admin and other passwords so ensure they have at least 14 characters.
Run Keycloak in HTTPS
5
Trust the CA locally (browser/curl)
6
File hygiene
Change the file permissions in
server.keystore so only the file owner has read/write access and nobody else has access:Troubleshooting
If you get an errorpassword must be at least 112 bits, it means that one or more passwords is under 14 characters long. Passwords should be 16-24 characters.
Check the passwords for the following variables: KC_BOOTSTRAP_ADMIN_PASSWORD, KC_HTTPS_KEY_STORE_PASSWORD, truststore password, etc.