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 2020/12/19 00:28:15 UTC

[GitHub] [cassandra] jonmeredith opened a new pull request #860: CASSANDRA-16362 Correct SSLContext initialization order for sstableloader

jonmeredith opened a new pull request #860:
URL: https://github.com/apache/cassandra/pull/860


   


----------------------------------------------------------------
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


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

Posted by GitBox <gi...@apache.org>.
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


[GitHub] [cassandra] jonmeredith closed pull request #860: CASSANDRA-16362 Correct SSLContext initialization order for sstableloader

Posted by GitBox <gi...@apache.org>.
jonmeredith closed pull request #860:
URL: https://github.com/apache/cassandra/pull/860


   


----------------------------------------------------------------
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


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

Posted by GitBox <gi...@apache.org>.
jonmeredith commented on pull request #860:
URL: https://github.com/apache/cassandra/pull/860#issuecomment-754939243


   I've reworked the patch to remove the hard-coded list of protocols when the legacy "TLS" protocol is selected. Instead the protocol list is created from `SSLContext.getInstance("TLS")` directly during initialization.
   This does have the consequence of including SSLFactory as an import for `DatabaseDescriptor`, but I don't think that causes any significant issues.
   The stress tool also has the same issues as BulkLoader so I've also updated that to apply protocols correctly.


----------------------------------------------------------------
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


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

Posted by GitBox <gi...@apache.org>.
jonmeredith commented on pull request #860:
URL: https://github.com/apache/cassandra/pull/860#issuecomment-761238799


   Merged.


----------------------------------------------------------------
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


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

Posted by GitBox <gi...@apache.org>.
jonmeredith commented on a change in pull request #860:
URL: https://github.com/apache/cassandra/pull/860#discussion_r552258630



##########
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:
       ack




----------------------------------------------------------------
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


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

Posted by GitBox <gi...@apache.org>.
jonmeredith commented on a change in pull request #860:
URL: https://github.com/apache/cassandra/pull/860#discussion_r552257310



##########
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:
       Agreed, didn't think to try the default formatting.




----------------------------------------------------------------
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