How can I allow HTTPS protocol for Java web application

67 Views Asked by At

I have a Java web application and one of the modules is using Vaadin for rendering the web interface. This module is running inside a docker container on a server. Could anyone help me to understand how I can add a SSL certificate in order to allow https calls for this module?

I have an assumption that we need to add the cert in cacerts file in java security directory but I don't have direct access to it since it's inside docker container.

I have tried to add the following line to docker-compose.yml for this module in volumes section.

volumes:

${CONF_DIR}/backend/cert/cacerts:/usr/java/default/lib/security/

But when I call https://xxxxx... I'm getting the error - This site can’t provide a secure connection ERR_SSL_PROTOCOL_ERROR

1

There are 1 best solutions below

2
Simon Martinelli On

Usually, the Docker server has an ingress or reverse proxy in front of it that handles HTTPS.

But if you need to do it yourself you have to configure Spring Boot:

server.ssl.key-store-type=PKCS12
server.ssl.key-store=<location of the cert>
server.ssl.key-store-password=<password>
server.ssl.key-alias=<the alias>

Please find the official guide here: https://spring.io/blog/2023/06/07/securing-spring-boot-applications-with-ssl