Home > Software design >  spring boot - use https only if ssl.key-store file exists
spring boot - use https only if ssl.key-store file exists

Time:05-28

I added these lines to application.properties:

server.ssl.key-store: keystore.p12
server.ssl.key-store-password: 111111
server.ssl.keyStoreType: PKCS12
server.ssl.keyAlias: tomcat

How do I use HTTPS only if the server.ssl.key-store file exists? Otherwise, I want to use HTTP.

CodePudding user response:

I solved a compareable problem by setting those properties programatically. This mean, you could check if the key-store file exists before you start your application with SpringApplication.run(MyApplication.class, args);

Depending on whether the key-store exists or not you could build a new args-array, which includes the old args and your ssl setting.

  • Related