[Java Srping] Configuring embedded Tomcat to run on https (NOT production code)

Run bash to generate keystore.jks in src/mian/resources folder:

keytool -genKey -keyalg RSA -alias linkedin -keystore keystore.jks -storepass password -validity 4000 -keysize 2048

Modify application.yml file:

management:
  secutiry:
    enabled: false
server:
  ssl:
    key-store: classpath:keystore.jks
    key-store-password: password
    key-store-type: JKS
    key-alias: linkedin
    key-password: password

Verify it is https:

http --verify=no https://localhsot:8080/api/greeting

Should be able to see the response.

原文地址:https://www.cnblogs.com/Answer1215/p/14059257.html