Getting JMX working under Tomcat 7 with SSL and a self-signed cert

↘锁芯ラ 提交于 2019-12-04 20:13:30

You are starting the RMI Registry on port 1099. In order for the RMI Registry to utilize SSL you need to pass an additional -Dcom.sun.management.jmxremote.registry.ssl=true argument.

Edit: Do you use jconsole -J-Djavax.net.ssl.trustStore=truststore -J-Djavax.net.ssl.trustStorePassword=trustword -Djavax.net.ssl.keyStore=keystore -Djavax.net.ssl.keyStorePassword=password to start JConsole? It needs to know where the stores are and the corresponding passwords.

For VisualVM you can install VisualVM-Security plugin which will add a new tab to the Options dialogue allowing you customize the SSL related options in UI.

I wanted tomcat getting to work with jmx and ssl and followed Bruce setup. In case someone runs int the same problem: using the openssl and keytool commands form Bruce I was getting at client ssl errors:

javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure

Not sure why but the figerprint on one side was 5 chars longer at the beginning.

I recreated the keystore using:

keytool -genkeypair -alias tomcat -keyalg RSA -keystore keystore.jks -dname cn=test,ou=test,dc=example,dc=com

In tomcat sever.xml I added the listener as Bruce suggested.

Because client auth is set to false I do not add truststore in tomcat jmx configuration. Instead I added registry.ssl:

[...]
-Djavax.net.ssl.keyStorePassword=your_keystore_pass
-Dcom.sun.management.jmxremote.registry.ssl=true

Then on client side as J.B. suggested I download ssl plugin for visualvm and criss-cross the keystore resulting in:

visualvm -J-Djavax.net.ssl.trustStore=keystore.jks -J-Djavax.net.ssl.trustStorePassword=your_keystore_pass

When adding authentication make sure that your jmx access file looks like:

<user_name>    readwrite

and your password file looks like:

<user_name>    <your_password>

This solved my ssl jmx setup for testing with visualm vm.

Edit:

Had some issues with having the registry also over SSL, set by:

-Dcom.sun.management.jmxremote.registry.ssl=true

leading at client to throw:

Root exception is java.rmi.ConnectIOException: non-JRMP server at remote endpoint

Adding client auth authentication:

-Dcom.sun.management.jmxremote.ssl.need.client.auth=true
-Djavax.net.ssl.trustStore=truststore.jks
-Djavax.net.ssl.trustStorePassword=your_trust_store_pass

solved both jmx and its registry to use ssl.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!