0

I use ssl to acces to my database, I have some configuration in JAVA JVM Args.

Is there a way to move these configuration into spring configuration file (My config are in application.yml) ?

JVM args that I want to move are :

-Djavax.net.ssl.keyStore=/path/to/keystore.jks
-Djavax.net.ssl.keyStorePassword=<password>
-Djavax.net.ssl.trustStore=/path/to/truststore.jks
-Djavax.net.ssl.trustStorePassword=<password>
jww
  • 97,681
  • 90
  • 411
  • 885
Youssouf Maiga
  • 6,701
  • 7
  • 26
  • 42

2 Answers2

1

In order for the properties to take effect, they need to be in the system Properties object before the SSL classes are initialized.

The chances are that if you attempt put them into the Spring config file, and (somehow) transfer them to the system Properties object, they won't get there soon enough.

Having said that ... the following Q&A explains how to inject new properties:

(Read all of the Answers.)

Community
  • 1
  • 1
Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
1

You can add JVM arguments for SSL properties in the application.yml file like this :

 server:    
      ssl:
          key-store: /path/to/keystore
          key-store-password: <password>
          trust-store: /path/trust/store
          trust-store-password: <password>

Common properties that can use in Spring properties file are defined here : https://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html

Youssouf Maiga
  • 6,701
  • 7
  • 26
  • 42
  • 1
    This is not equivalent to setting the JVM properties. These properties are for configuring the key store and trust store for the embedded web server (e.g. Tomcat) only. The JVM properties are used to set the default `SSLContext` for the JVM. – SteveO Apr 30 '17 at 03:50