You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by GitBox <gi...@apache.org> on 2021/01/05 23:15:40 UTC

[GitHub] [cassandra] dcapwell commented on a change in pull request #860: CASSANDRA-16362 Correct SSLContext initialization order for sstableloader

dcapwell commented on a change in pull request #860:
URL: https://github.com/apache/cassandra/pull/860#discussion_r552254492



##########
File path: test/unit/org/apache/cassandra/db/virtual/SettingsTableTest.java
##########
@@ -154,7 +155,7 @@ public void testEncryptionOverride() throws Throwable
         check(pre + "protocol", "[TLSv5]");
 
         config.server_encryption_options = config.server_encryption_options.withProtocol("TLS");
-        check(pre + "protocol", "[TLSv1.3, TLSv1.2, TLSv1.1, TLSv1]");
+        check(pre + "protocol", "[" + String.join(", ", SSLFactory.tlsInstanceProtocolSubstitution()) + "]");

Review comment:
       isn't this simpler?
   
   ```
   check(pre + "protocol", SSLFactory.tlsInstanceProtocolSubstitution()).toString());
   ```

##########
File path: src/java/org/apache/cassandra/tools/BulkLoader.java
##########
@@ -261,10 +268,22 @@ private static SSLOptions buildSSLOptions(EncryptionOptions clientEncryptionOpti
             throw new RuntimeException("Could not create SSL Context.", e);
         }
 
-        return JdkSSLOptions.builder()
-                            .withSSLContext(sslContext)
-                            .withCipherSuites(clientEncryptionOptions.cipherSuitesArray())
-                            .build();
+        // Temporarily override newSSLEngine to set accepted protocols until it is added to JdkSSLOptions

Review comment:
       `s/JdkSSLOptions/RemoteEndpointAwareJdkSSLOptions/g`

##########
File path: test/distributed/org/apache/cassandra/distributed/test/SSTableLoaderEncryptionOptionsTest.java
##########
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.cassandra.distributed.test;
+
+import java.io.IOException;
+import java.util.Collections;
+
+import com.google.common.collect.ImmutableMap;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import org.apache.cassandra.config.DatabaseDescriptor;
+import org.apache.cassandra.distributed.Cluster;
+import org.apache.cassandra.distributed.api.Feature;
+import org.apache.cassandra.tools.BulkLoader;
+import org.apache.cassandra.tools.ToolRunner;
+
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertTrue;
+
+
+public class SSTableLoaderEncryptionOptionsTest extends AbstractEncryptionOptionsImpl
+{
+    static Cluster cluster;

Review comment:
       nit: statics should be all caps

##########
File path: test/distributed/org/apache/cassandra/distributed/test/SSTableLoaderEncryptionOptionsTest.java
##########
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.cassandra.distributed.test;
+
+import java.io.IOException;
+import java.util.Collections;
+
+import com.google.common.collect.ImmutableMap;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import org.apache.cassandra.config.DatabaseDescriptor;
+import org.apache.cassandra.distributed.Cluster;
+import org.apache.cassandra.distributed.api.Feature;
+import org.apache.cassandra.tools.BulkLoader;
+import org.apache.cassandra.tools.ToolRunner;
+
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertTrue;
+
+
+public class SSTableLoaderEncryptionOptionsTest extends AbstractEncryptionOptionsImpl
+{
+    static Cluster cluster;
+    static String nodes;
+    static int nativePort;
+    static int storagePort;
+
+    @BeforeClass
+    public static void setupCluster() throws IOException
+    {
+        cluster = Cluster.build().withNodes(1).withConfig(c -> {
+            c.with(Feature.NATIVE_PROTOCOL, Feature.NETWORK, Feature.GOSSIP); // need gossip to get hostid for java driver
+            c.set("server_encryption_options",
+                  ImmutableMap.builder().putAll(validKeystore)
+                              .put("internode_encryption", "all")
+                              .put("optional", false)
+                              .build());
+            c.set("client_encryption_options",
+                  ImmutableMap.builder().putAll(validKeystore)
+                              .put("enabled", true)
+                              .put("optional", false)
+                              .put("accepted_protocols", Collections.singletonList("TLSv1.2"))
+                              .build());
+        }).start();
+        nodes = cluster.get(1).config().broadcastAddress().getHostString();
+        nativePort = cluster.get(1).callOnInstance(DatabaseDescriptor::getNativeTransportPort);
+        storagePort = cluster.get(1).callOnInstance(DatabaseDescriptor::getStoragePort);
+    }
+
+    @AfterClass
+    public static void tearDownCluster()
+    {
+        cluster.close();

Review comment:
       this could be null, so should add a null check (if setup fails this is null)




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org