I’m creating a Spring Boot application (v3.3.5) with Vaadin (v24.5.3) and I’ve read several articles on how to enable HTTPS, but they don’t seem to be working for me. Here are the steps:
create self-signed certificate and pks12 key using java keytool -genkeypair
put generated p12 file in /src/main/resources of project
export certificate from p12 file add to KeyChain, and say trust always
add spring configuration to application.properties to point to key
Thank you for the link. Is there a current solution, or is there just no way that SpringBoot/Vaadin and HTTPS can work together? I am only trying to load my application in one browser window, and I have tried adding the following line to my application.properties to stop the livereload server file but it does not help:
I don’t recommend to use HTPS on the Spring application. Usually there is a reverse proxy in front of the application so you don’t have to deal with that.
Hi Simon, for now I am just running on my local laptop. Eventually I would like to deploy this on the cloud since it is a small app, and assume at that point i would need HTTPs support. I’m not familiar with reverse proxy setup, so I will do some reading on that. Thank you for the suggestion
I am using my keystore in file system instead of inside jar (classpath).
That allows me to use HTTP for development and switch to HTTPS in production,
all without rebuilding jar file. It is also important to be able to regularly update
keystore, if you are using standard Certificate (not self-signed), which has limited
validity max 2 years. With self-signed certificate, browser will be warning that
you are connecting to unsecured server.
Both files “application.properties” and “tangram.p12” (keystore) are stored in “root” of deployment directory (directory where my JAR file is).
Notice “server.ssl.key-store: file:./tangram.p12”, which means to look for keystore in file system.
No other setting are necessary, just to switch server.ssl.enabled to “true” or “false” and restart service.
As @SimonMartinelli suggested, don’t try to setup HTTPS directly in Spring Boot. If you need to test how will your application run with HTTPS enabled, I’d recommend to follow this How To:
It enables you to develop using HTTP and test HTTPS only when needed. It basically spawns a reverse proxy for your app running on localhost:8080 in a Docker