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 files below from our GitHub repository

Save these files to your project folder:
2

Generate the certificates

Run the following command to generate the certificates.
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.
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):
docker cp jdk-jre-tls-test-app-1:/certs/https.crt ./https.crt
5

Test with curl

Now you can send curl requests to your Java server.
  • Send a curl command to the default endpoint to get a text response:
    curl --cacert ./https.crt https://localhost:5001/
    
    You should get the following response:
    ✅ Hello over HTTPS from Java TLS Server running minimus images!
    
  • Send a curl command to the JSON endpoint:
    curl --cacert ./https.crt https://localhost:5001/data
    
    You should get the following response:
    {
    "message": "Hello from the server running minimus image and using json format!",
    "status": "success"
    }