Okay, so I have been working on this for a while trying to figure this out. I have JMX monitoring working from one client to the server, but not from another client to the server. To me, the only difference seems to be that one is RHEL6, the other RHEL7. It works with RHEL6.
So here is the relevant code, in obtaining the MBeanServerConnection:
env.put(JMXConnector.CREDENTIALS, credentials);
env.put(RMIConnectorServer.RMI_SERVER_SOCKET_FACTORY_ATTRIBUTE ,
new SslRMIServerSocketFactory());
url = new JMXServiceURL(
"service:jmx:rmi:///jndi/rmi://123.123.123.123:1234/jmxrmi");
jmxc = JMXConnectorFactory.connect(url, env);
mbsc = jmxc.getMBeanServerConnection();
I compile with an identical jdk1.8.0_51 versions locally in /opt
on both machines. The keystores and truststores I created were first created on RHEL7, where this only works from RHEL6. I set these properties at runtime (formatted for readability):
/opt/java/jdk1.8.0_51/bin/java -cp .
-Djavax.net.ssl.keyStore=/path/to/keyStore.key
-Djavax.net.ssl.keyStorePassword=keypassword
-Djavax.net.ssl.trustStore=/path/to/trustStore.key
-Djavax.net.ssl.trustStorePassword=trustpassword
-Djavax.net.debug=all
MonitoringProgram
So what happens is that from my RHEL7 machine and the debugging on, I get plenty of output and then it freezes after this last output:
Ignoring unavailable cipher suite: TLS_DHE_DSS_WITH_AES_256_CBC_SHA256
Ignoring unavailable cipher suite: TLS_DHE_RSA_WITH_AES_256_CBC_SHA
Ignoring unavailable cipher suite: TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA
Ignoring unavailable cipher suite: TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
When I have to kill the program, or wait for an immensely long timeout. Now this same program, with debugging, has all of the exact same output (I've compared them with diff
) until then, but continues instead of freezing:
Ignoring unavailable cipher suite: TLS_DHE_DSS_WITH_AES_256_CBC_SHA256
Ignoring unavailable cipher suite: TLS_DHE_RSA_WITH_AES_256_CBC_SHA
Ignoring unavailable cipher suite: TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA
Ignoring unavailable cipher suite: TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
Allow unsafe renegotiation: false
Allow legacy hello messages: true
...
With lots of more output due to the debug=all, and with my expected output (for now, simply trying to obtain the domains of the mbean server).
So what could be causing this difference? The worst part is the connection just freezes, rather than throwing me an exception that I might be able to debug. I have tried recreating the keystore a couple of times, but I don't think it's that anymore. I thought it might be due to the unavailable cipher suites, but the working instance has those same unavailable cipher suites before settling on this cipher suite: TLS_DHE_DSS_WITH_AES_128_CBC_SHA256
with TLSv1.2. Remember, it has the exact same output until it freezes, so I'm not sure if the debug tool is going to let me completely solve this.
Any ideas or input would be greatly appreciated.
Edit: I'm adding the connection timeout stacktrace, should have added that in the first place. Still working on a solution.
java.rmi.ConnectException: Connection refused to host: 123.123.123.123; nested exception is:
java.net.ConnectException: Connection timed out
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:619)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:216)
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:202)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:130)
at javax.management.remote.rmi.RMIServerImpl_Stub.newClient(Unknown Source)
at javax.management.remote.rmi.RMIConnector.getConnection(RMIConnector.java:2432)
at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:308)
at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:270)
at MonitoringProgram.getMBeanServerConnection(MonitoringProgram.java:173)
at MonitoringProgram.main(MonitoringProgram.java:208)
Caused by: java.net.ConnectException: Connection timed out
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:668)
at sun.security.ssl.SSLSocketImpl.<init>(SSLSocketImpl.java:427)
at sun.security.ssl.SSLSocketFactoryImpl.createSocket(SSLSocketFactoryImpl.java:88)
at javax.rmi.ssl.SslRMIClientSocketFactory.createSocket(SslRMIClientSocketFactory.java:121)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:613)
... 9 more
Error: Connection refused