6

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.

1 Answer 1

7

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.