8020207: jconsole fails connecting over SSL using service:jmx:rmi://...jndi...

Reviewed-by: kevinw
This commit is contained in:
Gennadiy Krivoshein 2025-10-21 10:33:19 +00:00 committed by Dmitry Chuyko
parent a0c4124432
commit ea7186a87f

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -34,6 +34,7 @@ import java.lang.management.*;
import static java.lang.management.ManagementFactory.*;
import java.lang.ref.WeakReference;
import java.lang.reflect.*;
import java.net.URI;
import java.rmi.*;
import java.rmi.registry.*;
import java.rmi.server.*;
@ -133,7 +134,24 @@ public class ProxyClient implements JConsoleContext {
this.advancedUrl = url;
this.connectionName = getConnectionName(url, userName);
this.displayName = connectionName;
setParameters(new JMXServiceURL(url), userName, password);
JMXServiceURL jmxServiceURL = new JMXServiceURL(url);
setParameters(jmxServiceURL, userName, password);
if ("rmi".equals(jmxServiceURL.getProtocol())) {
String path = jmxServiceURL.getURLPath();
if (path.startsWith("/jndi/")) {
int end = path.indexOf(';');
if (end < 0) end = path.length();
String registryURIStr = path.substring(6, end);
URI registryURI = URI.create(registryURIStr);
if ("rmi".equals(registryURI.getScheme())
&& "/jmxrmi".equals(registryURI.getPath())) {
this.registryHostName = registryURI.getHost();
this.registryPort = registryURI.getPort();
this.vmConnector = true;
checkSslConfig();
}
}
}
}
private ProxyClient(LocalVirtualMachine lvm) throws IOException {