我们使用 ActiveMQ 对来自远程客户端的消息进行排队。
客户端使用以下 URL 连接到我们服务器上的 ActiveMQ;
ssl://www.mydomain.com:61616
这在过去工作得很好,是由一位在公司工作时间较长的开发人员设置的。
最近我们不得不更新我们的 SSL 证书,因为旧证书已经用完了。我们为我们的 http 服务器成功地做到了这一点,但现在才意识到原始 keystore 的副本仍然驻留在 ActiveMQ 配置文件夹中。
我们已尝试将新 keystore 放入 ActiveMQ 配置文件夹,覆盖旧 keystore 。然而,这似乎不起作用,所有连接都被以下堆栈跟踪拒绝;
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(Unknown Source)
at java.security.cert.CertPathBuilder.build(Unknown Source)
我们这里做错了什么? 我们使用 keytool -list 命令列出了新旧 keystore 的内容,它们看起来非常相似(当然除了日期)。 我们是否需要对调用上述 url 的客户端进行其他更新以接受我们的新 keystore ?
最佳答案
可能是您的信任库与您的 keystore 不同步。这是从头开始设置的一般方法;您的配置会有所不同,因此请根据需要进行调整:
为每个客户端生成证书,并向代理信任库注册客户端证书。
> keytool -genkey -alias producer -keyalg RSA -keystore myproducer.ks
> keytool -genkey -alias consumer -keyalg RSA -keystore myconsumer.ks
导出两个证书
> keytool -export -alias producer -keystore myproducer.ks -file producer_cert
> keytool -export -alias consumer -keystore myconsumer.ks -file consumer_cert
将证书导入生产者信任库(新文件)
> keytool -import -alias producer -keystore mybroker.ts -file producer_cert
> keytool -import -alias consumer -keystore mybroker.ts -file consumer_cert
将代理信任库复制到您拥有旧代理的任何位置,通常是 {ACTIVEMQ_HOME}/conf。您通常可以在代理配置中看到这一点:
<broker ...>
<sslContext>
<sslContext keyStore="file:${activemq.base}/conf/mybroker.ks"
keyStorePassword="test123"
trustStore="file:${activemq.base}/conf/mybroker.ts"
trustStorePassword="test123"/>
</sslContext>
</broker>
关于ssl - "unable to find valid certification path to requested target"添加新的 Keystore 到 ActiveMQ 之后,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6747248/