2

我能够获得父连接器

        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
        QueryExp qe = Query.match(Query.attr("port"), Query.value("443"));
        ObjectName on = new ObjectName("*:type=Connector,*");
        Set<ObjectName> objectNames = mbs.queryNames(on, qe);

而且我不想读取 server.xml 以防它不同步。如何获得 SSLHostConfig ?

4

1 回答 1

2

ConnectorMBean 不包含有关 TLS 配置的信息。您需要findSslHostConfigstype=ThreadPool. ThreadPool实际上是用词不当,因为这个 MBean 是由 each 导出的ProtocolHandler

final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
final QueryExp qe = Query.eq(Query.attr("port"), Query.value(443));
final ObjectName on = new ObjectName("*:type=ThreadPool,*");
final Set<ObjectName> protocols = mbs.queryNames(on, qe);
for (final ObjectName protocol : protocols) {
    SSLHostConfig[] configs = (SSLHostConfig[]) mbs.invoke(protocol, "findSslHostConfigs", null, null);
    // do something with the SSLHostConfig
}

或者,SSLHostConfigs 也可以作为 MBean 使用:它们具有属性type=SSLHostConfig

于 2021-10-08T20:41:17.503 回答