Skip to content

Commit

Permalink
[misc] permit using "file://" for keystore path.
Browse files Browse the repository at this point in the history
  • Loading branch information
rusher committed Apr 12, 2017
1 parent 3b9a257 commit 5816f91
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
Expand Up @@ -283,7 +283,6 @@ private KeyManager loadClientCerts(String keyStoreUrl, String keyStorePassword,
char[] keyStorePasswordChars = keyStorePassword == null ? null : keyStorePassword.toCharArray();

//permit using "file:..." for compatibility
if (keyStoreUrl.startsWith("file:///")) keyStoreUrl = keyStoreUrl.substring(8);
if (keyStoreUrl.startsWith("file://")) keyStoreUrl = keyStoreUrl.substring(7);

inStream = new FileInputStream(keyStoreUrl);
Expand Down Expand Up @@ -417,8 +416,7 @@ private void connect(String host, int port) throws SQLException, IOException {
serverData.put("sql_mode", resultSet.getString(4));

} else {
//MySQL 5.6 with SSL doesn't support pipeline auth.
if (options.usePipelineAuth && (serverMariaDb || (!serverMariaDb && options.useSsl))) {
if (options.usePipelineAuth) {
try {
sendPipelineAdditionalData();
readPipelineAdditionalData();
Expand Down
30 changes: 15 additions & 15 deletions src/test/java/org/mariadb/jdbc/SslTest.java
Expand Up @@ -406,7 +406,7 @@ public void testTruststore() throws SQLException, IOException, KeyStoreException

Properties info = new Properties();
info.setProperty("useSSL", "true");
info.setProperty("trustStore", "file:///" + keystorePath);
info.setProperty("trustStore", "file://" + keystorePath);
testConnect(info, true);
} catch (SQLNonTransientConnectionException nonTransient) {
//java 9 doesn't accept empty keystore
Expand All @@ -425,7 +425,7 @@ public void testTrustStoreWithPassword() throws IOException, KeyStoreException,

Properties info = new Properties();
info.setProperty("useSSL", "true");
info.setProperty("trustStore", "file:///" + keystorePath);
info.setProperty("trustStore", "file://" + keystorePath);
info.setProperty("trustStorePassword", "mysecret");
testConnect(info, true);
} finally {
Expand Down Expand Up @@ -478,7 +478,7 @@ public void testTruststoreWithWrongPassword() throws IOException, KeyStoreExcept

Properties info = new Properties();
info.setProperty("useSSL", "true");
info.setProperty("trustStore", "file:///" + keystorePath);
info.setProperty("trustStore", "file://" + keystorePath);
info.setProperty("trustStorePassword", "notthepassword");
testConnect(info, true);
} finally {
Expand All @@ -496,7 +496,7 @@ public void testTruststoreWithWrongCert() throws IOException, KeyStoreException,

Properties info = new Properties();
info.setProperty("useSSL", "true");
info.setProperty("trustStore", "file:///" + keystorePath);
info.setProperty("trustStore", "file://" + keystorePath);
info.setProperty("trustStorePassword", "mysecret");
testConnect(info, true);
} finally {
Expand Down Expand Up @@ -525,8 +525,8 @@ public void testTruststoreAndClientKeystore() throws SQLException, IOException,

Properties info = new Properties();
info.setProperty("useSSL", "true");
info.setProperty("trustStore", "file:///" + truststorePath);
info.setProperty("keyStore", "file:///" + clientKeystorePath);
info.setProperty("trustStore", "file://" + truststorePath);
info.setProperty("keyStore", "file://" + clientKeystorePath);
info.setProperty("keyStorePassword", clientKeystorePassword);
testConnect(info, true, testUser, "ssltestpassword");
} catch (SQLNonTransientConnectionException nonTransient) {
Expand Down Expand Up @@ -559,9 +559,9 @@ public void testAliases() throws SQLException, IOException, KeyStoreException, C

Properties info = new Properties();
info.setProperty("useSSL", "true");
info.setProperty("trustCertificateKeyStoreUrl", "file:///" + truststorePath);
info.setProperty("trustCertificateKeyStoreUrl", "file://" + truststorePath);
info.setProperty("trustCertificateKeyStorePassword", "trustPwd");
info.setProperty("clientCertificateKeyStoreUrl", "file:///" + clientKeystorePath);
info.setProperty("clientCertificateKeyStoreUrl", "file://" + clientKeystorePath);
info.setProperty("clientCertificateKeyStorePassword", clientKeystorePassword);
testConnect(info, true, testUser, "ssltestpassword");
} finally {
Expand All @@ -587,7 +587,7 @@ public void testClientKeystore() throws SQLException, IOException, KeyStoreExcep
Properties info = new Properties();
info.setProperty("useSSL", "true");
info.setProperty("serverSslCert", serverCertificatePath);
info.setProperty("keyStore", "file:///" + clientKeystorePath);
info.setProperty("keyStore", "file://" + clientKeystorePath);
info.setProperty("keyStorePassword", clientKeystorePassword);
testConnect(info, true, testUser, "ssltestpassword");
} finally {
Expand Down Expand Up @@ -617,7 +617,7 @@ public void testClientKeyStoreWithPrivateKeyPwd() throws Exception {
Properties info = new Properties();
info.setProperty("useSSL", "true");
info.setProperty("serverSslCert", serverCertificatePath);
info.setProperty("keyStore", "file:///" + clientKeyStore2Path);
info.setProperty("keyStore", "file://" + clientKeyStore2Path);
info.setProperty("keyStorePassword", clientKeyStore2Password);
testConnect(info, true, testUser, "ssltestpassword");

Expand All @@ -631,7 +631,7 @@ public void testClientKeyStoreWithPrivateKeyPwd() throws Exception {
Properties info = new Properties();
info.setProperty("useSSL", "true");
info.setProperty("serverSslCert", serverCertificatePath);
info.setProperty("keyStore", "file:///" + clientKeyStore2Path);
info.setProperty("keyStore", "file://" + clientKeyStore2Path);
info.setProperty("keyStorePassword", clientKeyStore2Password);
info.setProperty("keyPassword", clientKeyPassword);
testConnect(info, true, testUser, "ssltestpassword");
Expand All @@ -658,7 +658,7 @@ public void testClientKeyStorePkcs12() throws Exception {
Properties info = new Properties();
info.setProperty("useSSL", "true");
info.setProperty("serverSslCert", serverCertificatePath);
info.setProperty("keyStore", "file:///" + clientKeyStore2Path);
info.setProperty("keyStore", "file://" + clientKeyStore2Path);
info.setProperty("keyStorePassword", clientKeyStore2Password);
testConnect(info, true, testUser, "ssltestpassword");
} finally {
Expand Down Expand Up @@ -794,7 +794,7 @@ public void testClientKeyStoreProperties() throws SQLException, IOException, Key

Properties info = new Properties();
info.setProperty("useSSL", "true");
info.setProperty("keyStore", "file:///" + clientKeystorePath);
info.setProperty("keyStore", "file://" + clientKeystorePath);
info.setProperty("keyStorePassword", clientKeystorePassword);

testConnect(info, true, testUser, "ssltestpassword");
Expand Down Expand Up @@ -835,8 +835,8 @@ public void testTruststoreAndClientKeystoreWrongPassword() throws SQLException,

Properties info = new Properties();
info.setProperty("useSSL", "true");
info.setProperty("trustStore", "file:///" + truststorePath);
info.setProperty("keyStore", "file:///" + clientKeystorePath);
info.setProperty("trustStore", "file://" + truststorePath);
info.setProperty("keyStore", "file://" + clientKeystorePath);
info.setProperty("keyStorePassword", "notthekeystorepass");
testConnect(info, true, testUser, "ssltestpassword");
} finally {
Expand Down

0 comments on commit 5816f91

Please sign in to comment.