ARTEMIS-445 avoid NPE on null ks password
This commit is contained in:
parent
923c12c7a4
commit
32ce8710fc
|
@ -103,7 +103,7 @@ public class SSLSupport {
|
||||||
URL keystoreURL = SSLSupport.validateStoreURL(keystorePath);
|
URL keystoreURL = SSLSupport.validateStoreURL(keystorePath);
|
||||||
in = keystoreURL.openStream();
|
in = keystoreURL.openStream();
|
||||||
}
|
}
|
||||||
ks.load(in, keystorePassword.toCharArray());
|
ks.load(in, keystorePassword == null ? null : keystorePassword.toCharArray());
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
if (in != null) {
|
if (in != null) {
|
||||||
|
@ -126,7 +126,7 @@ public class SSLSupport {
|
||||||
else {
|
else {
|
||||||
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
|
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
|
||||||
KeyStore ks = SSLSupport.loadKeystore(keyStoreProvider, keystorePath, keystorePassword);
|
KeyStore ks = SSLSupport.loadKeystore(keyStoreProvider, keystorePath, keystorePassword);
|
||||||
kmf.init(ks, keystorePassword.toCharArray());
|
kmf.init(ks, keystorePassword == null ? null : keystorePassword.toCharArray());
|
||||||
|
|
||||||
return kmf.getKeyManagers();
|
return kmf.getKeyManagers();
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
@Test
|
||||||
public void testContextWithBadTrustStorePath() throws Exception {
|
public void testContextWithBadTrustStorePath() throws Exception {
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue