@@ -65,25 +65,23 @@ public class RmiConnector
6565{
6666 private static final LocalizedLogger logger = LocalizedLogger .getLoggerForThisClass ();
6767
68- static final String JMX_REMOTE_RMI_SERVER_CREDENTIAL_TYPES =
69- "jmx.remote.rmi.server.credential.types" ;
70-
7168 /**
7269 * JDK 10+ JMX environment property scoping a JEP 290 deserialization
7370 * filter to the credentials object passed during {@code newClient()}.
7471 * Using the credentials-scoped filter (instead of the connector-wide
7572 * {@code jmx.remote.rmi.server.serial.filter.pattern}) avoids breaking
7673 * legitimate JMX traffic such as MBean invocations and notifications,
7774 * which may legitimately carry non-String types.
75+ * <p>
76+ * Note: this property is mutually exclusive with
77+ * {@code jmx.remote.rmi.server.credential.types}; specifying both makes
78+ * {@code RMIJRMPServerImpl} throw an {@link IllegalArgumentException} and
79+ * prevents the connector from starting. The filter pattern is preferred
80+ * because it additionally constrains array length and nesting depth.
7881 */
7982 static final String JMX_REMOTE_RMI_SERVER_CREDENTIALS_FILTER_PATTERN =
8083 "jmx.remote.rmi.server.credentials.filter.pattern" ;
8184
82- private static final String [] JMX_CREDENTIAL_TYPES =
83- {
84- String .class .getName (),
85- String [].class .getName ()
86- };
8785
8886 private static final String JMX_CREDENTIAL_SERIAL_FILTER =
8987 "maxdepth=3;maxarray=2;java.lang.String;!*" ;
@@ -392,11 +390,13 @@ private void startConnectorNoClientCertificate() throws Exception
392390
393391 static void configureJmxDeserializationProtection (Map <String , Object > env )
394392 {
395- env .put (JMX_REMOTE_RMI_SERVER_CREDENTIAL_TYPES ,
396- JMX_CREDENTIAL_TYPES .clone ());
397393 // Scope the JEP 290 deserialization filter to the credentials object
398394 // only, so legitimate JMX RMI traffic (MBean operations, notifications,
399395 // etc.) is not affected by the restrictive allowlist.
396+ //
397+ // Do NOT also set "jmx.remote.rmi.server.credential.types": the JDK
398+ // rejects an environment that defines both properties, which would
399+ // prevent the RMI connector from starting.
400400 env .put (JMX_REMOTE_RMI_SERVER_CREDENTIALS_FILTER_PATTERN ,
401401 JMX_CREDENTIAL_SERIAL_FILTER );
402402 }
0 commit comments