Re: connector/j client certificate

Abhishek Mistry <[email protected]> Fri, 31 Jul 2015 03:34:02 +0000
Newsgroups gmane.comp.db.mysql.java
Message-ID <CAO6z2253SD7BWAkU9etP-eq2HX3Wc=ME3AFbdp8KxU85X060zw@mail.gmail.com>
--e89a8fb203484a2c12051c237ec6
Content-Type: text/plain; charset=UTF-8

I actually just figured it out from some Oracle (not mysql) documentation.
The correct format is not a file uri. On windows it's
file:/C:/path_with_forward_slashes/.keystore

One slash instead of two and you have to put the drive letter too. Strange.

Thanks anyway!

On Thu, Jul 30, 2015, 11:18 PM Mark Matthews <[email protected]>
wrote:

>
>
> On Jul 30, 2015, at 9:02 PM, Abhishek Mistry <[email protected]>
> wrote:
>
> 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.
>
>
> Hi, it is a URL, see https://en.m.wikipedia.org/wiki/File_URI_scheme for
> an explanation?
>
> - Mark
>

--e89a8fb203484a2c12051c237ec6--