微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

无法通过 SSL 连接到代理

如何解决无法通过 SSL 连接到代理

我有一个在本地主机上运行的 ActiveMQ 实例,它试图连接到另一个在 AWS (Amazon MQ) 上运行的实例。在 AWS 上运行的代理需要通过 SSL 建立代理到代理的连接。

在我的本地主机代理的 activemq.xml 中,我添加了以下内容以创建与在 AWS 上运行的代理的连接(目前只是一种方式):

<networkConnectors>
    <networkConnector name="local-to-aws" userName="myCommonUser" duplex="true" uri="static:(ssl://###.mq.ca-central-1.amazonaws.com:61617)"/>
</networkConnectors>

如果我尝试用它启动我的本地代理,我的 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

为了尝试解决这个问题,我在本地主机代理的 activemq.xml 配置中添加了以下内容

<sslContext>
    <sslContext keyStore="file:${activemq.base}/conf/broker.ks"
                keyStorePassword="###"
                trustStore="file:${activemq.base}/conf/client.ts"
                trustStorePassword="###"/>
</sslContext>

broker.ksclient.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

这就是我在 localhost 代理上启用 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 证书并将其添加到我的本地主机代理?我不知道接下来要做什么。

更新:我使用 Portecle 从 AWS 代理下载 SSL 证书并将它们添加client.ts

解决方法

似乎在验证端(本地主机),需要验证远程 AWS 代理的 TLS 证书。为此,验证方需要设置一个受信任的密钥库(又名信任库)来保存该证书层次结构(或根 CA,取决于从远程 AWS 代理返回的证书链)来自根 CA 到服务器证书。

请将 StarField CA 证书上传到受信任的商店,然后根据您的评论解决问题。

link 提供了实现该目标的详细信息。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。