use of org.apache.cassandra.config.EncryptionOptions in project cassandra by apache.
the class ClientWarningsTest method testUnloggedBatch.
@Test
public void testUnloggedBatch() throws Exception {
createTable("CREATE TABLE %s (pk int PRIMARY KEY, v text)");
// v4 and higher
try (SimpleClient client = new SimpleClient(nativeAddr.getHostAddress(), nativePort, version, true, new EncryptionOptions())) {
client.connect(false);
QueryMessage query = new QueryMessage(createBatchStatement2(1), QueryOptions.DEFAULT);
Message.Response resp = client.execute(query);
assertNull(resp.getWarnings());
query = new QueryMessage(createBatchStatement2(DatabaseDescriptor.getBatchSizeWarnThreshold()), QueryOptions.DEFAULT);
resp = client.execute(query);
assertEquals(1, resp.getWarnings().size());
}
}
use of org.apache.cassandra.config.EncryptionOptions in project cassandra by apache.
the class ClientWarningsTest method testLargeBatch.
@Test
public void testLargeBatch() throws Exception {
createTable("CREATE TABLE %s (pk int PRIMARY KEY, v text)");
// v4 and higher
try (SimpleClient client = new SimpleClient(nativeAddr.getHostAddress(), nativePort, version, true, new EncryptionOptions())) {
client.connect(false);
QueryMessage query = new QueryMessage(createBatchStatement2(DatabaseDescriptor.getBatchSizeWarnThreshold() / 2 + 1), QueryOptions.DEFAULT);
Message.Response resp = client.execute(query);
assertEquals(1, resp.getWarnings().size());
query = new QueryMessage(createBatchStatement(DatabaseDescriptor.getBatchSizeWarnThreshold()), QueryOptions.DEFAULT);
resp = client.execute(query);
assertNull(resp.getWarnings());
}
}
use of org.apache.cassandra.config.EncryptionOptions in project cassandra by apache.
the class PEMBasedSslContextFactoryTest method getSslContextOpenSSL.
@Test
public void getSslContextOpenSSL() throws IOException {
ParameterizedClass sslContextFactory = new ParameterizedClass(PEMBasedSslContextFactory.class.getSimpleName(), new HashMap<>());
EncryptionOptions options = new EncryptionOptions().withTrustStore("test/conf/cassandra_ssl_test.truststore.pem").withKeyStore("test/conf/cassandra_ssl_test.keystore.pem").withKeyStorePassword("cassandra").withRequireClientAuth(false).withCipherSuites("TLS_RSA_WITH_AES_128_CBC_SHA").withSslContextFactory(sslContextFactory);
SslContext sslContext = SSLFactory.getOrCreateSslContext(options, true, ISslContextFactory.SocketType.CLIENT);
Assert.assertNotNull(sslContext);
if (OpenSsl.isAvailable())
Assert.assertTrue(sslContext instanceof OpenSslContext);
else
Assert.assertTrue(sslContext instanceof SslContext);
}
use of org.apache.cassandra.config.EncryptionOptions in project cassandra by apache.
the class SSLFactoryTest method testCacheKeyEqualityForCustomSslContextFactory.
@Test
public void testCacheKeyEqualityForCustomSslContextFactory() {
Map<String, String> parameters1 = new HashMap<>();
parameters1.put("key1", "value1");
parameters1.put("key2", "value2");
EncryptionOptions encryptionOptions1 = new EncryptionOptions().withSslContextFactory(new ParameterizedClass(DummySslContextFactoryImpl.class.getName(), parameters1)).withProtocol("TLSv1.1").withRequireClientAuth(true).withRequireEndpointVerification(false);
SSLFactory.CacheKey cacheKey1 = new SSLFactory.CacheKey(encryptionOptions1, ISslContextFactory.SocketType.SERVER);
Map<String, String> parameters2 = new HashMap<>();
parameters2.put("key1", "value1");
parameters2.put("key2", "value2");
EncryptionOptions encryptionOptions2 = new EncryptionOptions().withSslContextFactory(new ParameterizedClass(DummySslContextFactoryImpl.class.getName(), parameters2)).withProtocol("TLSv1.1").withRequireClientAuth(true).withRequireEndpointVerification(false);
SSLFactory.CacheKey cacheKey2 = new SSLFactory.CacheKey(encryptionOptions2, ISslContextFactory.SocketType.SERVER);
Assert.assertEquals(cacheKey1, cacheKey2);
}
use of org.apache.cassandra.config.EncryptionOptions in project cassandra by apache.
the class MessagingServiceMBeanImpl method reloadSslCertificates.
@Override
public void reloadSslCertificates() throws IOException {
final EncryptionOptions.ServerEncryptionOptions serverOpts = DatabaseDescriptor.getInternodeMessagingEncyptionOptions();
final EncryptionOptions clientOpts = DatabaseDescriptor.getNativeProtocolEncryptionOptions();
SSLFactory.validateSslCerts(serverOpts, clientOpts);
SSLFactory.checkCertFilesForHotReloading(serverOpts, clientOpts);
}
Aggregations