How to build more secure Java apps using OpenJDK and OpenJRE
This project provides a test framework for validating a multi-stage build for a Java application with TLS enabled.The setup includes the creation of self-signed certificates and has the Java container run an application server over HTTPS.
1
Fetch the example Kubernetes YAML configuration files
The configurations are based on the changes described in our general NGINX guide. To simplify the process we provide example configuration files in our GitHub repo. Save the example YAML files to your project folder:
Run the following command to generate the certificates.
Copy
Ask AI
docker compose -f create-certs.yml up --abort-on-container-exit
3
Start the Java server
This will run the Java server and map port 5001 on your host to 5001 in the container.
Copy
Ask AI
docker compose up --build app
4
Extract the certificate for curl
You need to place the server certificate (https.crt) on your host so you can communicate with curl.Copy it from the container Docker volume to your host (The container name in our example is jdk-jre-tls-test-app-1):