Spring Boot 2应用程序无法覆盖RMIRegistry默认端口1099以确保JMX连接安全

问题描述 投票:1回答:1

不幸的是,我们的Spring Boot 2应用程序公开了RMI注册表默认端口 1099,我们的安全团队对此表示抱怨。我们希望JMX应该以安全的方式专门通过端口8999使用。当前,您可以通过两种方式进行连接-通过端口1099不安全,通过端口8999安全。到目前为止,我们尚不了解,因为我们实际上已经设置了适当的系统属性来防止这种情况:

-Dcom.sun.management.jmxremote=true 
-Dcom.sun.management.jmxremote.port=8999
-Dcom.sun.management.jmxremote.rmi.port=8999
-Dcom.sun.management.jmxremote.ssl=false 
-Dcom.sun.management.jmxremote.authenticate=true 
-Dcom.sun.management.jmxremote.password.file=/opt/our_app/jmxremote.password 
-Dcom.sun.management.jmxremote.access.file=/opt/our_app/jmxremote.access

为什么端口1099仍然打开?我不得不提到Spring Actuator也在使用中,但是我在那里找不到任何配置来控制端口,因此似乎不是问题。

java spring-boot spring-jmx
1个回答
2
投票

感谢Ravi Sharam在上面的评论中给出了解决方案。

我们在项目中具有以下依赖性:

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-activemq</artifactId>
</dependency>

通过使用系统属性另外启动应用程序

-Dorg.apache.activemq.broker.jmx.createConnector=false

打开的默认端口1099已删除。让我们用netstat

检查一下
root@protect01:/opt/our_app# netstat -ntlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      29956/rpcbind
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN      19282/systemd-resol
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1421/sshd
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      25126/master
tcp        0      0 0.0.0.0:8001            0.0.0.0:*               LISTEN      988/java
tcp6       0      0 :::8999                 :::*                    LISTEN      988/java
tcp6       0      0 :::111                  :::*                    LISTEN      29956/rpcbind
tcp6       0      0 :::80                   :::*                    LISTEN      3986/apache2
tcp6       0      0 :::22                   :::*                    LISTEN      1421/sshd
tcp6       0      0 127.0.0.1:8089          :::*                    LISTEN      988/java
tcp6       0      0 ::1:25                  :::*                    LISTEN      25126/master
tcp6       0      0 :::34139                :::*                    LISTEN      988/java
tcp6       0      0 :::11099                :::*                    LISTEN      988/java
tcp6       0      0 :::443                  :::*                    LISTEN      3986/apache2
tcp6       0      0 :::45093                :::*                    LISTEN      988/java

不再有开放端口1099,只有预期的8999。Yippiiii!

© www.soinside.com 2019 - 2024. All rights reserved.