在我的 Spring Boot 应用程序中,我的
application.yml
部分如下:
spring:
activemq:
broker-url: ssl://10.68.84.40:61617
user: admin
password: admin
packages:
trust-all: true
其中
10.68.84.40:61617
是添加到 activemq.xml
的端点:
<transportConnector name="ssl" uri="ssl://0.0.0.0:61617?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
Spring Boot 官方文档对于 ActiveMQ 的使用过于简单。我深入研究
org.springframework.boot.autoconfigure.jms.activemq.ActiveMQProperties
源代码,发现将 spring.activemq.packages.trust-all
设置为 true 应该信任所有服务器证书,但它仍然得到 sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
。
然后我看到另一个属性
spring.activemq.packages.trusted
,但我想知道应该放在那里。
添加:使用 openssl,看到服务器证书的 CN 只是
localhost
。应用程序正在使用 IP 进行呼叫。
设置
spring.activemq.packages.trust-all
与SSL证书没有任何关系,并且Spring的源代码没有给出任何迹象表明它与SSL证书有关。它与 JMS ObjectMessage
实例的反序列化有关。请参阅ActiveMQ Classic 文档了解更多信息。
不幸的是,无法强制 ActiveMQ Classic 中的 OpenWire JMS 客户端“信任所有”SSL 证书。但是,如果您决定迁移,则可以从 ActiveMQ Artemis 的 Core JMS 客户端获得此行为。详情请参阅此处。