Skip to content

Commit

Permalink
SSTableLoader will fail if encryption parameters are used due to CASS…
Browse files Browse the repository at this point in the history
…ANDRA-16144

patch by Alexander Dejanovski; reviewed by David Capwell, Jon Meredith for CASSANDRA-16280
  • Loading branch information
adejanovski authored and dcapwell committed Nov 17, 2020
1 parent 45acc63 commit d031c44
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
8 changes: 0 additions & 8 deletions src/java/org/apache/cassandra/tools/LoaderOptions.java
Expand Up @@ -475,51 +475,43 @@ public Builder parseArgs(String cmdArgs[])
if (cmd.hasOption(SSL_TRUSTSTORE))
{
clientEncOptions = clientEncOptions.withTrustStore(cmd.getOptionValue(SSL_TRUSTSTORE));
clientEncOptions.applyConfig();
}

if (cmd.hasOption(SSL_TRUSTSTORE_PW))
{
clientEncOptions = clientEncOptions.withTrustStorePassword(cmd.getOptionValue(SSL_TRUSTSTORE_PW));
clientEncOptions.applyConfig();
}

if (cmd.hasOption(SSL_KEYSTORE))
{
// if a keystore was provided, lets assume we'll need to use
clientEncOptions = clientEncOptions.withKeyStore(cmd.getOptionValue(SSL_KEYSTORE))
.withRequireClientAuth(true);
clientEncOptions.applyConfig();
}

if (cmd.hasOption(SSL_KEYSTORE_PW))
{
clientEncOptions = clientEncOptions.withKeyStorePassword(cmd.getOptionValue(SSL_KEYSTORE_PW));
clientEncOptions.applyConfig();
}

if (cmd.hasOption(SSL_PROTOCOL))
{
clientEncOptions = clientEncOptions.withProtocol(cmd.getOptionValue(SSL_PROTOCOL));
clientEncOptions.applyConfig();
}

if (cmd.hasOption(SSL_ALGORITHM))
{
clientEncOptions = clientEncOptions.withAlgorithm(cmd.getOptionValue(SSL_ALGORITHM));
clientEncOptions.applyConfig();
}

if (cmd.hasOption(SSL_STORE_TYPE))
{
clientEncOptions = clientEncOptions.withStoreType(cmd.getOptionValue(SSL_STORE_TYPE));
clientEncOptions.applyConfig();
}

if (cmd.hasOption(SSL_CIPHER_SUITES))
{
clientEncOptions = clientEncOptions.withCipherSuites(cmd.getOptionValue(SSL_CIPHER_SUITES).split(","));
clientEncOptions.applyConfig();
}

if (cmd.hasOption(TARGET_KEYSPACE))
Expand Down
23 changes: 22 additions & 1 deletion test/unit/org/apache/cassandra/tools/LoaderOptionsTest.java
Expand Up @@ -44,4 +44,25 @@ public void testNativePort() throws Exception {
options = LoaderOptions.builder().parseArgs(args2).build();
assertEquals(9142, options.nativePort);
}
}

/**
* Regression testing for CASSANDRA-16280
*
* Check that providing encryption parameters to the loader (such as keystore and truststore) won't break loading
* the options.
*
* @throws Exception
*/
@Test
public void testEncryptionSettings() throws Exception
{
String[] args = { "-d", "127.9.9.1", "-ts", "test.jks", "-tspw", "truststorePass1", "-ks", "test.jks", "-kspw",
"testdata1", "--ssl-ciphers", "TLS_RSA_WITH_AES_256_CBC_SHA",
"--ssl-alg", "SunX509", "--store-type", "JKS", "--ssl-protocol", "TLS",
sstableDirName("legacy_sstables", "legacy_ma_simple") };
LoaderOptions options = LoaderOptions.builder().parseArgs(args).build();
options = LoaderOptions.builder().parseArgs(args).build();
assertEquals("test.jks", options.clientEncOptions.keystore);
}
}

0 comments on commit d031c44

Please sign in to comment.