ARTEMIS-4266 mitigate NPE with bad SSL config
This commit is contained in:
parent
31095682ee
commit
dc0b3ac55a
|
@ -697,7 +697,7 @@ public class NettyAcceptor extends AbstractAcceptor {
|
|||
if (configuration.containsKey(TransportConstants.SSL_CONTEXT_PROP_NAME)) {
|
||||
return;
|
||||
}
|
||||
if (keyStorePath == null && TransportConstants.DEFAULT_KEYSTORE_PROVIDER.equals(keyStoreProvider)) {
|
||||
if (keyStorePath == null && keyStoreProvider == null) {
|
||||
throw new IllegalArgumentException("If \"" + TransportConstants.SSL_ENABLED_PROP_NAME + "\" is true then \"" + TransportConstants.KEYSTORE_PATH_PROP_NAME + "\" must be non-null unless an alternative \"" + TransportConstants.KEYSTORE_PROVIDER_PROP_NAME + "\" has been specified.");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -144,4 +144,33 @@ public class NettyAcceptorTest extends ActiveMQTestBase {
|
|||
Wait.assertEquals(61616, () -> server.getRemotingService().getAcceptor(normal).getActualPort());
|
||||
Wait.assertEquals(-1, () -> server.getRemotingService().getAcceptor(invm).getActualPort());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvalidSSLConfig() {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put(TransportConstants.SSL_ENABLED_PROP_NAME, "true");
|
||||
|
||||
try {
|
||||
new NettyAcceptor("netty", null, params, null, null, null, null, Map.of());
|
||||
fail("This should have failed with an IllegalArgumentException");
|
||||
} catch (IllegalArgumentException e) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidSSLConfig1() {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put(TransportConstants.SSL_ENABLED_PROP_NAME, "true");
|
||||
params.put(TransportConstants.KEYSTORE_PROVIDER_PROP_NAME, RandomUtil.randomString());
|
||||
new NettyAcceptor("netty", null, params, null, null, null, null, Map.of());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidSSLConfig2() {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put(TransportConstants.SSL_ENABLED_PROP_NAME, "true");
|
||||
params.put(TransportConstants.SSL_CONTEXT_PROP_NAME, RandomUtil.randomString());
|
||||
new NettyAcceptor("netty", null, params, null, null, null, null, Map.of());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue