maulin-vasavada commented on code in PR #3457:
URL: https://github.com/apache/cassandra/pull/3457#discussion_r1839535116


##########
test/distributed/org/apache/cassandra/distributed/test/JMXEncryptionOptionsTest.java:
##########
@@ -0,0 +1,102 @@
+/*
+ * 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 com.google.common.collect.ImmutableMap;
+import org.junit.Test;
+
+import org.apache.cassandra.distributed.Cluster;
+import org.apache.cassandra.distributed.api.Feature;
+import org.apache.cassandra.distributed.test.jmx.JMXGetterCheckTest;
+
+public class JMXEncryptionOptionsTest extends AbstractEncryptionOptionsImpl
+{
+    @Test
+    public void testDefaultSettings() throws Throwable
+    {
+        try (Cluster cluster = builder().withNodes(1).withConfig(c -> {
+            c.with(Feature.JMX);
+            c.set("jmx_encryption_options",
+                  ImmutableMap.builder().putAll(validKeystore)
+                              .put("enabled", true)
+                              .put("require_client_auth", false)
+                              .build());
+        }).start())
+        {
+            // Invoke the same code vs duplicating any code from the 
JMXGetterCheckTest
+            JMXGetterCheckTest.testAllValidGetters(cluster);
+        }
+    }
+
+    @Test
+    public void testPEMBasedEncryptionOptions() throws Throwable
+    {
+        try (Cluster cluster = builder().withNodes(1).withConfig(c -> {
+            c.with(Feature.JMX);
+            c.set("jmx_encryption_options",
+                  ImmutableMap.builder().putAll(validPEMKeystore)
+                              .put("enabled", true)
+                              .put("require_client_auth", false)
+                              .build());
+        }).start())
+        {
+            // Invoke the same code vs duplicating any code from the 
JMXGetterCheckTest
+            JMXGetterCheckTest.testAllValidGetters(cluster);
+        }
+    }
+
+    @Test
+    public void testInvalidKeystorePath() throws Throwable

Review Comment:
   addressed in https://github.com/apache/cassandra/pull/3638



##########
src/java/org/apache/cassandra/utils/JMXServerUtils.java:
##########
@@ -243,10 +254,18 @@ private static Map<String, Object> 
configureJmxSocketFactories(InetAddress serve
 
             SslRMIClientSocketFactory clientFactory = new 
SslRMIClientSocketFactory();
             SslRMIServerSocketFactory serverFactory = new 
SslRMIServerSocketFactory(ciphers, protocols, requireClientAuth);
-            env.put(RMIConnectorServer.RMI_SERVER_SOCKET_FACTORY_ATTRIBUTE, 
serverFactory);
-            env.put(RMIConnectorServer.RMI_CLIENT_SOCKET_FACTORY_ATTRIBUTE, 
clientFactory);
-            env.put("com.sun.jndi.rmi.factory.socket", clientFactory);
-            logJmxSslConfig(serverFactory);
+            setSocketFactoriesInEnv(env, clientFactory, serverFactory);
+        }
+        else if (jmxEncryptionOptions != null && 
jmxEncryptionOptions.getEnabled() != null && jmxEncryptionOptions.getEnabled())
+        {
+            logger.info("Enabling JMX SSL using jmx_encryption_options from 
cassandra.yaml");
+            // Here we can continue to use the SslRMIClientSocketFactory for 
client sockets.
+            // However, we should still set System properties for 
cipher_suites and enabled_protocols
+            // to have the same behavior as cassandra-env.sh based JMX SSL 
settings
+            setJmxSystemProperties(jmxEncryptionOptions);

Review Comment:
   addressed in https://github.com/apache/cassandra/pull/3638__



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to