Service Registry & SSO Integration with Self-Signed Certificate
When securing Service Registry using Red Hat SSO that has HTTPS endpoint set up with a self-signed certificate, you might end up with following error when starting the Service Registry container.
Problem
The reason behind the scence is basically Service Registry cannot connect to Red Hat SSO via HTTPS endpoint because self-signed certificate is unknown and the CA who sign the certificate is not trusted by JVM.
Solution
To fix this issue, in summary, you need to add the self-signed certificate (the one that's used to setup HTTPS endpoint for SSO) or the certificate of CA who signed the certificate itself to JVM truststore/keystore file so the certificate is known or trusted by JVM. To do so, follow the steps below:
Get list of Service Registry pod(s) with follwing command.
Sample output:
SSH to Service Registry pod using
oc rsh
command and find JVM truststore/keystore path in the container withls -l $JAVA_HOME/lib/security/
command. Look for thecacerts
file which is the default JVM truststore/keystore file.However, in this case, the
cacerts
file is a symbolic link to/etc/pki/java/cacerts
file which is another symbolic link to/etc/pki/ca-trust/extracted/java/cacerts
file which is the file that we need to copy from container.Sample output:
Use
oc rsync
command to copy file from Servie Registry container.Sample output:
Add self-signed certificate to the
cacerts
file with following command line or GUI tool.Replace
$JDK_HOME
with your actual JDK home path.Replace
$CERT
with the path to your certificate the you previously installed to the system.Replace
$ALIAS
with the preferred alias to be used in the keystore.Note that
changeit
is the default password for Java's cacerts file.
Create a Secret object for the
cacerts
truststore file.Note. If you encounter a
java.io.IOException: Invalid keystore format
error in Service Registry container log, the upload of the binary file did not work properly. As an alternative, encode the file as a base64 string usingcat registry-keystore.jks | base64 -w0 > data.txt
and edit the Secret resource as yaml to manually add the encoded file.Add the Secret to Service Registry Deployment.
You'll be directed to the Service Registry Deployment page.
Go to Environment tab and add two new environment variables as screenshot below.
TRUSTSTORE_PASSWORD
environment variable value is read from the Secret object you've created above.JAVA_OPTIONS
environment value is-Djavax.net.ssl.trustStore=/etc/pki/java/custom/truststore -Djavax.net.ssl.trustStorePassword=$(TRUSTSTORE_PASSWORD)
After new pods are created, open one of the and go to Terminal tab then type
ls -l /etc/pki/java/custom/
command. You should see thetruststore
file which is mounted from the Secret object.Go to Logs tab, you should see the value of
JAVA_OPTIONS
environment variable get added as thejava
command arguments. And the application should start without any error about certificate.
References
Last updated