我有一个在 localhost 上运行的 ActiveMQ 实例,它试图连接到在 AWS (Amazon MQ) 上运行的另一个实例。在 AWS 上运行的代理需要通过 SSL 建立代理到代理的连接。
在我的 localhost 代理中activemq.xml
,我添加了以下内容以创建与在 AWS 上运行的代理的连接(目前只是一种方式):
<networkConnectors>
<networkConnector name="local-to-aws" userName="myCommonUser" duplex="true" uri="static:(ssl://###.mq.ca-central-1.amazonaws.com:61617)"/>
</networkConnectors>
如果我尝试用它来启动我的 localhost 代理,我的activemy.log
文件中会出现以下错误:
2021-01-29 20:19:32,638 | WARN | Could not start network bridge between: vm://localhost and:
ssl://###.mq.ca-central-1.amazonaws.com:61617 due to: java.security.NoSuchAlgorithmException:
Error constructing implementation (algorithm: Default, provider: SunJSSE, class:
sun.security.ssl.SSLContextImpl$DefaultSSLContext) |
org.apache.activemq.network.DiscoveryNetworkConnector | Simple Discovery Agent-2
因此,为了尝试解决这个问题,我在 localhost 代理的activemq.xml
配置中添加了以下内容:
<sslContext>
<sslContext keyStore="file:${activemq.base}/conf/broker.ks"
keyStorePassword="###"
trustStore="file:${activemq.base}/conf/client.ts"
trustStorePassword="###"/>
</sslContext>
broker.ks
和client.ts
是使用以下命令生成的:
Using keytool, create a certificate for the broker:
keytool -genkey -alias broker -keyalg RSA -keystore broker.ks
Export the broker's certificate so it can be shared with clients:
keytool -export -alias broker -keystore broker.ks -file broker_cert
Create a certificate/keystore for the client:
keytool -genkey -alias client -keyalg RSA -keystore client.ks
Create a truststore for the client, and import the broker's certificate. This establishes that the client "trusts" the broker:
keytool -import -alias broker -keystore client.ts -file broker_cert
这就是我在我的本地主机代理上启用 SSL 所做的一切,我不确定除了将该<sslContext>
元素添加到我的配置中是否还有其他需要做的事情。
当我在进行更改后尝试启动 localhost 代理时,我现在得到一个不同的错误activemq.log
:
2021-01-29 20:07:03,686 | INFO | Error with pending remote brokerInfo on:
ssl://###.mq.ca-central-1.amazonaws.com/##.###.#.106:61617 (Connection or inbound has closed) |
org.apache.activemq.network.DemandForwardingBridgeSupport | ActiveMQ Transport: ssl://###.mq.ca-
central-1.amazonaws.com/##.###.#.106:61617
2021-01-29 20:07:03,687 | WARN | Could not start network bridge between: vm://localhost and:
ssl://###.mq.ca-central-1.amazonaws.com:61617 due to: sun.security.validator.ValidatorException:
PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find
valid certification path to requested target | org.apache.activemq.network.DiscoveryNetworkConnector |
Simple Discovery Agent-3
这就是我难住的地方。
有谁知道我做错了什么?我在 AWS 代理的配置中看不到任何与 SSL 相关的内容,我假设这是因为 AWS 故意向我隐藏了这一点,以防止我更改该代理的任何 SSL 设置。
我是否需要以某种方式获取 AWS 代理使用的 SSL 证书并将其添加到我的 localhost 代理?我不知道下一步该做什么。
更新:我使用 Portecle 从 AWS 代理下载 SSL 证书并将它们添加到client.ts
.