Registering a secure service

Securing the server side is one thing; registering a secure application is something else. Let's look at how we can do this:

  1. To enable SSL for a Spring Boot application, we need to start with generating a self-signed certificate. I recommend you use keytool for that, which is available under your JRE root in the bin catalog:
keytool -genkey -alias client -storetype PKCS12 -keyalg RSA -keysize 2048 -keystore keystore.p12 -validity 3650
  1. Enter the required data and copy the generated keystore file keystore.p12 to your application's src/main/resources catalog. The next step is to enable HTTPS for Spring Boot using configuration properties in application.yml:
server:  port: ${PORT:8081} ssl: key-store: classpath:keystore.p12 ...

Get Mastering Spring Cloud now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.