use of io.crate.protocols.ssl.SslContextProvider in project crate by crate.
the class SSLTransportITest method test_nodes_connect_with_ssl.
@Test
public void test_nodes_connect_with_ssl() throws Exception {
execute("select count(*) from sys.nodes");
assertThat(response.rows()[0][0], is(2L));
SslContextProvider sslContextProvider = new SslContextProvider(sslSettings);
SSLContext sslContext = sslContextProvider.jdkSSLContext();
for (var transport : internalCluster().getInstances(Transport.class)) {
var publishAddress = transport.boundAddress().publishAddress();
var address = publishAddress.address();
ProbeResult probeResult = ConnectionTest.probeSSL(sslContext, address);
assertThat(probeResult, is(ProbeResult.SSL_AVAILABLE));
}
}
use of io.crate.protocols.ssl.SslContextProvider in project crate by crate.
the class CrateHttpsTransportTest method testPipelineConfiguration.
@Test
public void testPipelineConfiguration() throws Exception {
Settings settings = Settings.builder().put(PATH_HOME_SETTING.getKey(), "/tmp").put(SslSettings.SSL_HTTP_ENABLED.getKey(), true).put(SslSettings.SSL_TRUSTSTORE_FILEPATH.getKey(), trustStoreFile.getAbsolutePath()).put(SslSettings.SSL_TRUSTSTORE_PASSWORD.getKey(), "keystorePassword").put(SslSettings.SSL_KEYSTORE_FILEPATH.getKey(), keyStoreFile.getAbsolutePath()).put(SslSettings.SSL_KEYSTORE_PASSWORD.getKey(), "keystorePassword").put(SslSettings.SSL_KEYSTORE_KEY_PASSWORD.getKey(), "keystorePassword").build();
NetworkService networkService = new NetworkService(Collections.singletonList(new NetworkService.CustomNameResolver() {
@Override
public InetAddress[] resolveDefault() {
return new InetAddress[] { InetAddresses.forString("127.0.0.1") };
}
@Override
public InetAddress[] resolveIfPossible(String value) throws IOException {
return new InetAddress[] { InetAddresses.forString("127.0.0.1") };
}
}));
PipelineRegistry pipelineRegistry = new PipelineRegistry(settings);
pipelineRegistry.setSslContextProvider(new SslContextProvider(settings));
Netty4HttpServerTransport transport = new Netty4HttpServerTransport(settings, networkService, BigArrays.NON_RECYCLING_INSTANCE, mock(ThreadPool.class), NamedXContentRegistry.EMPTY, pipelineRegistry, new NettyBootstrap(), mock(NodeClient.class));
EmbeddedChannel channel = new EmbeddedChannel();
try {
transport.start();
Netty4HttpServerTransport.HttpChannelHandler httpChannelHandler = (Netty4HttpServerTransport.HttpChannelHandler) transport.configureServerChannelHandler();
httpChannelHandler.initChannel(channel);
assertThat(channel.pipeline().first(), instanceOf(SslHandler.class));
} finally {
transport.stop();
transport.close();
channel.releaseInbound();
channel.close().awaitUninterruptibly();
}
}
use of io.crate.protocols.ssl.SslContextProvider in project crate by crate.
the class DefaultTransportITest method test_nodes_connect_with_hba_enabled_and_default_transport_mode.
@Test
public void test_nodes_connect_with_hba_enabled_and_default_transport_mode() throws Exception {
execute("select count(*) from sys.nodes");
assertThat(response.rows()[0][0], is(2L));
SslContextProvider sslContextProvider = new SslContextProvider(sslSettings);
SSLContext sslContext = sslContextProvider.jdkSSLContext();
for (var transport : internalCluster().getInstances(Transport.class)) {
var publishAddress = transport.boundAddress().publishAddress();
var address = publishAddress.address();
ProbeResult probeResult = ConnectionTest.probeSSL(sslContext, address);
assertThat(probeResult, is(ProbeResult.SSL_MISSING));
}
}
use of io.crate.protocols.ssl.SslContextProvider in project crate by crate.
the class MockTransportService method createNewService.
public static MockTransportService createNewService(Settings settings, Version version, ThreadPool threadPool, @Nullable ClusterSettings clusterSettings) {
var allSettings = Settings.builder().put(TransportSettings.PORT.getKey(), ESTestCase.getPortRange()).put(settings).build();
var namedWriteableRegistry = new NamedWriteableRegistry(ClusterModule.getNamedWriteables());
var transport = new Netty4Transport(allSettings, version, threadPool, new NetworkService(List.of()), new PageCacheRecycler(allSettings), namedWriteableRegistry, new NoneCircuitBreakerService(), new NettyBootstrap(), new AlwaysOKAuthentication(name -> User.CRATE_USER), new SslContextProvider(allSettings));
return new MockTransportService(allSettings, transport, threadPool, boundAddress -> new DiscoveryNode(Node.NODE_NAME_SETTING.get(settings), UUIDs.randomBase64UUID(), boundAddress.publishAddress(), Node.NODE_ATTRIBUTES.getAsMap(settings), DiscoveryNode.getRolesFromSettings(settings), version), clusterSettings);
}
use of io.crate.protocols.ssl.SslContextProvider in project crate by crate.
the class TransportServiceHandshakeTests method startServices.
private NetworkHandle startServices(String nodeNameAndId, Settings settings, Version version) {
var allSettings = Settings.builder().put(TransportSettings.PORT.getKey(), ESTestCase.getPortRange()).put(settings).build();
var transport = new Netty4Transport(allSettings, // handle the real world scenario instead of a faked one.
Version.CURRENT, threadPool, new NetworkService(Collections.emptyList()), PageCacheRecycler.NON_RECYCLING_INSTANCE, new NamedWriteableRegistry(Collections.emptyList()), new NoneCircuitBreakerService(), new NettyBootstrap(), new AlwaysOKAuthentication(userName -> User.CRATE_USER), new SslContextProvider(settings));
TransportService transportService = new MockTransportService(allSettings, transport, threadPool, (boundAddress) -> new DiscoveryNode(nodeNameAndId, nodeNameAndId, boundAddress.publishAddress(), emptyMap(), emptySet(), version), null);
transportService.start();
transportService.acceptIncomingRequests();
transportServices.add(transportService);
return new NetworkHandle(transportService, transportService.getLocalNode());
}
Aggregations