Spring Boot FAQ: Top Questions
26. How do you enable HTTPS in a Spring Boot application?
To enable HTTPS in Spring Boot, configure the server to use SSL with a valid certificate in application.properties
.
πΊοΈ Steps:
- Generate a keystore using keytool or obtain one from a CA.
- Add SSL properties to the config file.
π₯ Example:
server.port=8443
server.ssl.key-store=classpath:keystore.p12
server.ssl.key-store-password=changeit
server.ssl.keyStoreType=PKCS12
server.ssl.keyAlias=myalias
π Expected Output:
Application runs on HTTPS at port 8443.
π οΈ Use Cases:
- Secure API and web endpoints.
- Complying with HTTPS-only policies.