connector/j client certificate

Abhishek Mistry <[email protected]> Thu, 30 Jul 2015 22:02:53 -0400
Newsgroups gmane.comp.db.mysql.java
Message-ID <CAO6z227WNRP09nanUrRbh4jowefiv8GZA5h8uE1KoF4W30+L8Q@mail.gmail.com>
--047d7b41c5b4c56463051c2237af
Content-Type: text/plain; charset=UTF-8

I am trying to use SSL in my application. I followed the instructions in
the manual at
http://dev.mysql.com/doc/connector-j/en/connector-j-reference-using-ssl.html

I am able to connect to the database if I set the javax system properties
as in
System.setProperty("javax.net.ssl.keyStore","path_to_keystore_file");
System.setProperty("javax.net.ssl.keyStorePassword","password");
System.setProperty("javax.net.ssl.trustStore","path_to_truststore_file");
System.setProperty("javax.net.ssl.trustStorePassword","password");

But the problem is that setting these global properties screws up other
HTTP clients that I need to run to connect to various REST APIs. Is there a
way to set the keystore/truststore only for mysql? I saw that you could
specify properties in the connection URL but that did not work for me. I
tried the following code.

con = DriverManager.getConnection("jdbc:" + dbType + "://" + dbHost + ":" +
dbPort + "/" + dbCollation + "?useSSL=true"
+ "&clientCertificateKeyStoreUrl=" + URLEncoder.encode(mysqlKeystore,
"UTF-8")
+ "&clientCertificateKeyStorePassword=" + mysqlKeystorePassword
+ "&trustCertificateKeyStoreUrl=" + URLEncoder.encode(mysqlTruststore,
"UTF-8")
+ "&trustCertificateKeyStorePassword=" + mysqlTruststorePassword
, dbUser, dbPassword);

This kept giving me errors saying the keystore URL was invalid
(C:\etc\certs\mysql.keystore). I tried various formats but didn't get
anywhere. There doesn't seem to be any documentation on the valid format
for the URL.

Does anyone have any ideas? I've been going around in circles on this.

--047d7b41c5b4c56463051c2237af--