I am connecting to MySQL over SSL from my Java application. I have configured MYSQL to support SSL and generated client certificates. I have imported server CA certificate a
The value for jdbc.url
in jdbc.properties has to be
jdbc:mysql://127.0.0.1:3306/MySampleDb?verifyServerCertificate=true&useSSL=true&requireSSL=true
Those parameters must be added directly to the URL for MySQL. The parameters for keyStore
and trustStore
should be passed to the JVM at start like so:
-Djavax.net.ssl.keyStore=path_to_keystore_file
-Djavax.net.ssl.keyStorePassword=password
-Djavax.net.ssl.trustStore=path_to_truststore_file
-Djavax.net.ssl.trustStorePassword=password
You can use Spring to set system properties but I'd never use it, it's too cumbersome.