Karthik Suresh
Karthik Suresh

Reputation: 407

Conditional enabling of HTTPS in Springboot application

I would like to enable or disable the SSL/TLS with external configuration which can be provided during the application startup. The application should support all crud operations for http and https.

## SSL
server.port=8081
server.ssl.key-store=file:C:\\Users\\karthik\\hnm.p12
server.ssl.key-store-password=C*GSYS
server.ssl.keyStoreType=PKCS12

These properties are defined in application.properties

#Spring Security
security.require-ssl=false

Since the above property is deprecated, how can i achieve it without using the profiles.

Upvotes: 1

Views: 4815

Answers (2)

cassiomolin
cassiomolin

Reputation: 130927

To disable SSL, you can use:

server.ssl.enabled = false

Have a look at the server properties documentation for details.

Upvotes: 4

Karthik Suresh
Karthik Suresh

Reputation: 407

The properties if defined in application.yml

server:
  tomcat:
    accesslog:
      enabled: true
  ssl:
    key-store-type: PKCS12
    key-store: file:C:\\Users\\karthik\\hnm.p12
    enabled: true
    protocol: TLS
    key-store-password: C*GSYS

enabling and disabling the HTTPS can be achieved without code change. Tried and tested in Sprint boot 2.2.4.RELEASE

Upvotes: 0

Related Questions