Skip to content

Commit 77bbda2

Browse files
committed
Properly set SSL configuration options for Scylla
Extend withSsl() and withSslAuth() methods of CcmBridge to correctly set up SSL keys on Scylla. Add references keys to a format usable by Scylla. This commit is ported from Java Driver 3.x (commit 8590737) "withSslLocalhostCn" functionality is not modified for now - a test with it is disabled.
1 parent eb4be82 commit 77bbda2

File tree

1 file changed

+38
-9
lines changed
  • test-infra/src/main/java/com/datastax/oss/driver/api/testinfra/ccm

1 file changed

+38
-9
lines changed

test-infra/src/main/java/com/datastax/oss/driver/api/testinfra/ccm/CcmBridge.java

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,26 @@ public class CcmBridge implements AutoCloseable {
9494
public static final String DEFAULT_SERVER_TRUSTSTORE_PASSWORD = "scylla1sfun";
9595
public static final String DEFAULT_SERVER_TRUSTSTORE_PATH = "/server.truststore";
9696

97+
public static final String DEFAULT_SERVER_TRUSTSTORE_PEM_PATH = "/server.truststore.pem";
98+
9799
private static final File DEFAULT_SERVER_TRUSTSTORE_FILE =
98100
createTempStore(DEFAULT_SERVER_TRUSTSTORE_PATH);
101+
private static final File DEFAULT_SERVER_TRUSTSTORE_PEM_FILE =
102+
createTempStore(DEFAULT_SERVER_TRUSTSTORE_PEM_PATH);
99103

100104
public static final String DEFAULT_SERVER_KEYSTORE_PASSWORD = "scylla1sfun";
101105
public static final String DEFAULT_SERVER_KEYSTORE_PATH = "/server.keystore";
102106

107+
// Contain the same keypair as the server keystore, but in format usable by Scylla
108+
public static final String DEFAULT_SERVER_PRIVATE_KEY_PATH = "/server.key";
109+
public static final String DEFAULT_SERVER_CERT_CHAIN_PATH = "/server.crt";
110+
103111
private static final File DEFAULT_SERVER_KEYSTORE_FILE =
104112
createTempStore(DEFAULT_SERVER_KEYSTORE_PATH);
113+
private static final File DEFAULT_SERVER_PRIVATE_KEY_FILE =
114+
createTempStore(DEFAULT_SERVER_PRIVATE_KEY_PATH);
115+
private static final File DEFAULT_SERVER_CERT_CHAIN_FILE =
116+
createTempStore(DEFAULT_SERVER_CERT_CHAIN_PATH);
105117

106118
// A separate keystore where the certificate has a CN of localhost, used for hostname
107119
// validation testing.
@@ -550,15 +562,25 @@ public Builder withCreateOption(String option) {
550562
/** Enables SSL encryption. */
551563
public Builder withSsl() {
552564
cassandraConfiguration.put("client_encryption_options.enabled", "true");
553-
cassandraConfiguration.put("client_encryption_options.optional", "false");
554-
cassandraConfiguration.put(
555-
"client_encryption_options.keystore", DEFAULT_SERVER_KEYSTORE_FILE.getAbsolutePath());
556-
cassandraConfiguration.put(
557-
"client_encryption_options.keystore_password", DEFAULT_SERVER_KEYSTORE_PASSWORD);
565+
if (SCYLLA_ENABLEMENT) {
566+
cassandraConfiguration.put(
567+
"client_encryption_options.certificate",
568+
DEFAULT_SERVER_CERT_CHAIN_FILE.getAbsolutePath());
569+
cassandraConfiguration.put(
570+
"client_encryption_options.keyfile", DEFAULT_SERVER_PRIVATE_KEY_FILE.getAbsolutePath());
571+
} else {
572+
cassandraConfiguration.put("client_encryption_options.optional", "false");
573+
cassandraConfiguration.put(
574+
"client_encryption_options.keystore", DEFAULT_SERVER_KEYSTORE_FILE.getAbsolutePath());
575+
cassandraConfiguration.put(
576+
"client_encryption_options.keystore_password", DEFAULT_SERVER_KEYSTORE_PASSWORD);
577+
}
558578
return this;
559579
}
560580

561581
public Builder withSslLocalhostCn() {
582+
// FIXME: Add Scylla support.
583+
// @IntegrationTestDisabledCassandra3Failure @IntegrationTestDisabledSSL
562584
cassandraConfiguration.put("client_encryption_options.enabled", "true");
563585
cassandraConfiguration.put("client_encryption_options.optional", "false");
564586
cassandraConfiguration.put(
@@ -573,10 +595,17 @@ public Builder withSslLocalhostCn() {
573595
public Builder withSslAuth() {
574596
withSsl();
575597
cassandraConfiguration.put("client_encryption_options.require_client_auth", "true");
576-
cassandraConfiguration.put(
577-
"client_encryption_options.truststore", DEFAULT_SERVER_TRUSTSTORE_FILE.getAbsolutePath());
578-
cassandraConfiguration.put(
579-
"client_encryption_options.truststore_password", DEFAULT_SERVER_TRUSTSTORE_PASSWORD);
598+
if (SCYLLA_ENABLEMENT) {
599+
cassandraConfiguration.put(
600+
"client_encryption_options.truststore",
601+
DEFAULT_SERVER_TRUSTSTORE_PEM_FILE.getAbsolutePath());
602+
} else {
603+
cassandraConfiguration.put(
604+
"client_encryption_options.truststore",
605+
DEFAULT_SERVER_TRUSTSTORE_FILE.getAbsolutePath());
606+
cassandraConfiguration.put(
607+
"client_encryption_options.truststore_password", DEFAULT_SERVER_TRUSTSTORE_PASSWORD);
608+
}
580609
return this;
581610
}
582611

0 commit comments

Comments
 (0)