Search in sources :

Example 6 with ServerEncryptionOptions

use of org.apache.cassandra.config.EncryptionOptions.ServerEncryptionOptions in project cassandra by apache.

the class MessagingServiceTest method listenOptionalSecureConnectionWithBroadcastAddr.

@Test
public void listenOptionalSecureConnectionWithBroadcastAddr() throws InterruptedException {
    ServerEncryptionOptions serverEncryptionOptions = new ServerEncryptionOptions().withOptional(true);
    listen(serverEncryptionOptions, true);
}
Also used : ServerEncryptionOptions(org.apache.cassandra.config.EncryptionOptions.ServerEncryptionOptions) Test(org.junit.Test)

Example 7 with ServerEncryptionOptions

use of org.apache.cassandra.config.EncryptionOptions.ServerEncryptionOptions in project cassandra by apache.

the class MessagingServiceTest method listenPlainConnectionWithBroadcastAddr.

@Test
public void listenPlainConnectionWithBroadcastAddr() throws InterruptedException {
    ServerEncryptionOptions serverEncryptionOptions = new ServerEncryptionOptions().withInternodeEncryption(ServerEncryptionOptions.InternodeEncryption.none);
    listen(serverEncryptionOptions, true);
}
Also used : ServerEncryptionOptions(org.apache.cassandra.config.EncryptionOptions.ServerEncryptionOptions) Test(org.junit.Test)

Example 8 with ServerEncryptionOptions

use of org.apache.cassandra.config.EncryptionOptions.ServerEncryptionOptions in project cassandra by apache.

the class MessagingServiceTest method listenOptionalSecureConnection.

@Test
public void listenOptionalSecureConnection() throws InterruptedException {
    for (// test used to be flaky, so run in a loop to make sure stable (see CASSANDRA-17033)
    int i = 0; // test used to be flaky, so run in a loop to make sure stable (see CASSANDRA-17033)
    i < 500; // test used to be flaky, so run in a loop to make sure stable (see CASSANDRA-17033)
    i++) {
        ServerEncryptionOptions serverEncryptionOptions = new ServerEncryptionOptions().withOptional(true);
        listen(serverEncryptionOptions, false);
    }
}
Also used : ServerEncryptionOptions(org.apache.cassandra.config.EncryptionOptions.ServerEncryptionOptions) Test(org.junit.Test)

Example 9 with ServerEncryptionOptions

use of org.apache.cassandra.config.EncryptionOptions.ServerEncryptionOptions in project cassandra by apache.

the class SSLFactoryTest method testSslContextReload_HappyPath.

@Test
public void testSslContextReload_HappyPath() throws IOException, InterruptedException {
    try {
        ServerEncryptionOptions options = addKeystoreOptions(encryptionOptions).withInternodeEncryption(ServerEncryptionOptions.InternodeEncryption.all);
        SSLFactory.initHotReloading(options, options, true);
        SslContext oldCtx = SSLFactory.getOrCreateSslContext(options, true, ISslContextFactory.SocketType.CLIENT);
        File keystoreFile = new File(options.keystore);
        SSLFactory.checkCertFilesForHotReloading(options, options);
        keystoreFile.trySetLastModified(System.currentTimeMillis() + 15000);
        SSLFactory.checkCertFilesForHotReloading(options, options);
        SslContext newCtx = SSLFactory.getOrCreateSslContext(options, true, ISslContextFactory.SocketType.CLIENT);
        Assert.assertNotSame(oldCtx, newCtx);
    } catch (Exception e) {
        throw e;
    } finally {
        DatabaseDescriptor.loadConfig();
    }
}
Also used : ServerEncryptionOptions(org.apache.cassandra.config.EncryptionOptions.ServerEncryptionOptions) File(org.apache.cassandra.io.util.File) IOException(java.io.IOException) CertificateException(java.security.cert.CertificateException) SslContext(io.netty.handler.ssl.SslContext) Test(org.junit.Test)

Example 10 with ServerEncryptionOptions

use of org.apache.cassandra.config.EncryptionOptions.ServerEncryptionOptions in project cassandra by apache.

the class SSLFactoryTest method testSslFactoryHotReload_CorruptOrNonExistentFile_DoesNotClearExistingSslContext.

@Test
public void testSslFactoryHotReload_CorruptOrNonExistentFile_DoesNotClearExistingSslContext() throws IOException {
    try {
        ServerEncryptionOptions options = addKeystoreOptions(encryptionOptions);
        File testKeystoreFile = new File(options.keystore + ".test");
        FileUtils.copyFile(new File(options.keystore).toJavaIOFile(), testKeystoreFile.toJavaIOFile());
        options = options.withKeyStore(testKeystoreFile.path());
        SSLFactory.initHotReloading(options, options, true);
        SslContext oldCtx = SSLFactory.getOrCreateSslContext(options, true, ISslContextFactory.SocketType.CLIENT);
        SSLFactory.checkCertFilesForHotReloading(options, options);
        testKeystoreFile.trySetLastModified(System.currentTimeMillis() + 15000);
        FileUtils.forceDelete(testKeystoreFile.toJavaIOFile());
        SSLFactory.checkCertFilesForHotReloading(options, options);
        SslContext newCtx = SSLFactory.getOrCreateSslContext(options, true, ISslContextFactory.SocketType.CLIENT);
        Assert.assertSame(oldCtx, newCtx);
    } catch (Exception e) {
        throw e;
    } finally {
        DatabaseDescriptor.loadConfig();
        FileUtils.deleteQuietly(new File(encryptionOptions.keystore + ".test").toJavaIOFile());
    }
}
Also used : ServerEncryptionOptions(org.apache.cassandra.config.EncryptionOptions.ServerEncryptionOptions) File(org.apache.cassandra.io.util.File) IOException(java.io.IOException) CertificateException(java.security.cert.CertificateException) SslContext(io.netty.handler.ssl.SslContext) Test(org.junit.Test)

Aggregations

ServerEncryptionOptions (org.apache.cassandra.config.EncryptionOptions.ServerEncryptionOptions)16 Test (org.junit.Test)14 SslContext (io.netty.handler.ssl.SslContext)4 File (org.apache.cassandra.io.util.File)4 IOException (java.io.IOException)3 CertificateException (java.security.cert.CertificateException)3 SSLServerSocket (javax.net.ssl.SSLServerSocket)1 IInternodeAuthenticator (org.apache.cassandra.auth.IInternodeAuthenticator)1 ConfigurationException (org.apache.cassandra.exceptions.ConfigurationException)1 InetAddressAndPort (org.apache.cassandra.locator.InetAddressAndPort)1