Re: connector/j client certificate

Mark Matthews <[email protected]> Thu, 30 Jul 2015 22:18:52 -0500
Newsgroups gmane.comp.db.mysql.java
Message-ID <[email protected]>
--Apple-Mail-F6F610F0-2A23-43F5-8158-7E447BE766A0
Content-Type: text/plain;
	charset=us-ascii
Content-Transfer-Encoding: quoted-printable



> On Jul 30, 2015, at 9:02 PM, Abhishek Mistry <[email protected]> wrote=
:
>=20
> 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.ht=
ml
>=20
> 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");
>=20
> 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.
>=20
> con =3D DriverManager.getConnection("jdbc:" + dbType + "://" + dbHost + ":=
" +
> dbPort + "/" + dbCollation + "?useSSL=3Dtrue"
> + "&clientCertificateKeyStoreUrl=3D" + URLEncoder.encode(mysqlKeystore,
> "UTF-8")
> + "&clientCertificateKeyStorePassword=3D" + mysqlKeystorePassword
> + "&trustCertificateKeyStoreUrl=3D" + URLEncoder.encode(mysqlTruststore,
> "UTF-8")
> + "&trustCertificateKeyStorePassword=3D" + mysqlTruststorePassword
> , dbUser, dbPassword);
>=20
> 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.
>=20
> 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 e=
xplanation?

- Mark=

--Apple-Mail-F6F610F0-2A23-43F5-8158-7E447BE766A0--