Reputation: 9584
I would like to be able to connect to a MySQL server with JDBC through an SSL connection. The MySQL documentation states that we should set system properties:
java
System.setProperty("javax.net.ssl.trustStore","path_to_truststore_file");
System.setProperty("javax.net.ssl.trustStorePassword","password");
Indeed, it works... for MySQL. But once I've set those system properties, I cannot make regular HTTPS calls to registered websites. The system trustore has been overriden, and I get an SSLHandshakeException
.
I'd like to be able to set the trustore ONLY for the JDBC MySQL connection. Any regular HTTPS call should use the system trust store.
How can it be done ?
I have found this question that may lead to an answer but it looks like it's not working.
Upvotes: 7
Views: 4523
Reputation: 9584
Turns out the MySQL JDBC driver allows to override those properties as part of the connection URL.
So I need to add &trustCertificateKeyStoreUrl=file://path_to_truststore_file&trustCertificateKeyStorePassword=password
to the connection URL.
Upvotes: 8