Adding the Certificate to Keycloak

Adding the Certificate to Keycloak

For Resonate to trust the certificate on your SMTP server, you must add the certificate to Keycloak.
  1. Add the certificate to the Keycloak truststore, located by default at:
    • For Ubuntu:
      /etc/ssl/certs/java/cacerts
    • For Red Hat:
      /etc/pki/java/cacerts
    Use a tool such as Keytool to add the certificate to the truststore. Keytool requires that you set a password. Remember this password for later; you need to specify it when you add the certificate to the Keycloak truststore.
  2. Create a ConfigMap using the certificate files:
    kubectl create configmap certificates --from-file=cacerts=path/to/your/certs
  3. Mount this ConfigMap into the Keycloak pod. To do so, edit the Keycloak deployment:
    kubectl patch deployment keycloak -p '{"spec": {"template": {"spec": {"volumes": [{"name": "certificates", "configMap": {"name": "certificates"}}], "containers": [{"name": "keycloak", "volumeMounts": [{"name": "certificates", "mountPath": "/etc/ssl/certs/java/cacerts"}]}]}}}'
  4. If using a custom truststore, set the password for the truststore in the Keycloak deployment:
    kubectl patch deployment keycloak -p '{"spec": {"template": {"spec": {"containers": [{"name": "keycloak", "env": [{"name": "JAVA_OPTS", "value": "-Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m - Dfile.encoding=UTF-8 -Dsun.stdout.encoding=UTF-8 -Dsun.err.encoding=UTF-8 - Dstdout.encoding=UTF-8 -Dstderr.encoding=UTF-8 -XX:+ExitOnOutOfMemoryError - Djava.security.egd=file:/dev/urandom -XX:+UseParallelGC - XX:MinHeapFreeRatio=10 -XX:MaxHeapFreeRatio=20 -XX:GCTimeRatio=4 - XX:AdaptiveSizePolicyWeight=90 - Djavax.net.ssl.trustStorePassword=password"}]}]}}}'
    The password is at the end of the environment variable. Replace password with the password that you set when creating the truststore.
After you have added the certificate to your truststore, configure the SMTP settings in Keycloak. Refer to Configuring the SMTP Settings in Keycloak.