Use Java images with custom CA certificates
You can make your custom root Certificate Authority (CA) certificates available to Java images. Your application can then establish secure TLS connections to services that use certificates signed by your company’s CA.
Java uses the Java KeyStore (JKS) or Public-Key Cryptography Standards #12 (PKCS12) formats for key storage. However, you can import certificates in PEM files.
The key stores require a password for integrity checking. For the system truststore, the default password is changeit. This simple default password is intended for tamper detection and integrity verification rather than cryptographic confidentiality.
Add or replace custom CA certificates in Java images by using Podman
To add a custom Certificate Authority (CA) bundle to a Java image, you can use an OpenShift Container Platform ConfigMap. You can select whether you want to add your custom CA bundle to the existing truststore or create a new truststore that contains only your CA bundle.
Procedure
Results
- Start an OpenJDK container and mount the storage volume with the truststore to the
/etc/pki/ca-trust/extracted/java/cacertsfile:# podman run --rm \ --volume <volume_name>/cacerts:/etc/pki/ca-trust/extracted/java/cacerts:ro,Z \ registry.access.redhat.com/hi/openjdk:latest \ java -jar <application>.jar
Add or replace custom CA certificates in Java images on OpenShift Container Platform
Use an OpenShift Container Platform ConfigMap to add a custom Certificate Authority (CA) bundle to a Java image. You can select whether you want to add your custom CA bundle to the existing truststore or if you want to create a new truststore that contains only your CA bundle.
Before you begin
- You have access to OpenShift Container Platform CLI.
- You have the CA certificate bundle in PEM format.
- You have the permissions to create ConfigMaps and modify Pod specifications in the target namespace.
Procedure
Create a modified Java image to add custom root CA certificates
If you require that a Java image trusts both your custom Certificate Authorities (CAs) and the image’s built-in default CAs, create a modified image to add the custom certificates. This avoids the need to generate the truststore on each container startup.
Before you begin
- The
podmanpackage is installed.