Video guide of the process
Step 1 : Generate SSL Certificate
To enable HTTPS, we would require a SSL certificate. This certificate can be obtained from a Certificate Authority.
Also, we can generate a self-signed certificate using java keytool
utility.
1 | keytool -genkey -noprompt -alias chocolate \ |
This will generate a PKCS12 keystore
file as chocolate.p12 with the newly generated certificate.
Step 2 : Configure SSL connector for Server
To enable HTTPS in our application, we need to configure few ssl properties binding the application server with the keystore that was generated in the previous step.
Add the below configuration to your application.yml
1 | server: |
That’s all you need to enable HTTPS in a spring boot application.
You can now access the application with the endpoint: https://localhost:8443
You would need to add the Security Certificate Exception in this was a self-signed certificate.