diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/ssl/SSLSupport.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/ssl/SSLSupport.java index 5320bacac9..2b97c75888 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/ssl/SSLSupport.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/ssl/SSLSupport.java @@ -103,7 +103,7 @@ public class SSLSupport { URL keystoreURL = SSLSupport.validateStoreURL(keystorePath); in = keystoreURL.openStream(); } - ks.load(in, keystorePassword.toCharArray()); + ks.load(in, keystorePassword == null ? null : keystorePassword.toCharArray()); } finally { if (in != null) { @@ -126,7 +126,7 @@ public class SSLSupport { else { KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); KeyStore ks = SSLSupport.loadKeystore(keyStoreProvider, keystorePath, keystorePassword); - kmf.init(ks, keystorePassword.toCharArray()); + kmf.init(ks, keystorePassword == null ? null : keystorePassword.toCharArray()); return kmf.getKeyManagers(); } diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/ssl/SSLSupportTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/ssl/SSLSupportTest.java index cb2655296f..6ecb385c15 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/ssl/SSLSupportTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/ssl/SSLSupportTest.java @@ -137,6 +137,17 @@ public class SSLSupportTest extends ActiveMQTestBase { } } + @Test + public void testContextWithNullKeyStorePassword() throws Exception { + try { + SSLSupport.createContext(storeType, keyStorePath, null, storeType, trustStorePath, trustStorePassword); + Assert.fail(); + } + catch (Exception e) { + assertFalse(e instanceof NullPointerException); + } + } + @Test public void testContextWithBadTrustStorePath() throws Exception { try {