Search in sources :

Example 1 with RemoteEndpointAwareJdkSSLOptions

use of com.datastax.driver.core.RemoteEndpointAwareJdkSSLOptions in project cassandra by apache.

the class BulkLoader method buildSSLOptions.

private static SSLOptions buildSSLOptions(EncryptionOptions clientEncryptionOptions) {
    if (!clientEncryptionOptions.isEnabled()) {
        return null;
    }
    SSLContext sslContext;
    try {
        sslContext = SSLFactory.createSSLContext(clientEncryptionOptions, true);
    } catch (IOException e) {
        throw new RuntimeException("Could not create SSL Context.", e);
    }
    // Temporarily override newSSLEngine to set accepted protocols until it is added to
    // RemoteEndpointAwareJdkSSLOptions.  See CASSANDRA-13325 and CASSANDRA-16362.
    RemoteEndpointAwareJdkSSLOptions sslOptions = new RemoteEndpointAwareJdkSSLOptions(sslContext, null) {

        protected SSLEngine newSSLEngine(SocketChannel channel, InetSocketAddress remoteEndpoint) {
            SSLEngine engine = super.newSSLEngine(channel, remoteEndpoint);
            String[] acceptedProtocols = clientEncryptionOptions.acceptedProtocolsArray();
            if (acceptedProtocols != null && acceptedProtocols.length > 0)
                engine.setEnabledProtocols(acceptedProtocols);
            return engine;
        }
    };
    return sslOptions;
}
Also used : RemoteEndpointAwareJdkSSLOptions(com.datastax.driver.core.RemoteEndpointAwareJdkSSLOptions) SocketChannel(com.datastax.shaded.netty.channel.socket.SocketChannel) InetSocketAddress(java.net.InetSocketAddress) SSLEngine(javax.net.ssl.SSLEngine) SSLContext(javax.net.ssl.SSLContext) IOException(java.io.IOException)

Aggregations

RemoteEndpointAwareJdkSSLOptions (com.datastax.driver.core.RemoteEndpointAwareJdkSSLOptions)1 SocketChannel (com.datastax.shaded.netty.channel.socket.SocketChannel)1 IOException (java.io.IOException)1 InetSocketAddress (java.net.InetSocketAddress)1 SSLContext (javax.net.ssl.SSLContext)1 SSLEngine (javax.net.ssl.SSLEngine)1