【问题标题】:How to activemq in ssl如何在 ssl 中激活 MQ
【发布时间】:2015-12-18 04:57:05
【问题描述】:

我正在尝试通过 jms (activemq) 发送消息,但我希望它采用 ssl 协议。 它目前在 tcp 中有效。

我使用 jndi,带有一个虚拟主题和 2 个队列。有人可以帮我吗,我试过了,但我卡住了服务器无法启动:

http://activemq.apache.org/how-do-i-use-ssl.html

谢谢

编辑:日志说:“对实体“needClientAuth”的引用必须以';'结尾分隔符。”

【问题讨论】:

  • 你能把日志发过来吗?
  • 把整个trace放在这里,需要';'不表示问题,一定是某处缺少分号
  • 感谢您的帮助:实际上在 activemq 站点上它被写为: 而它是
  • 他们忘记了“&”所以当然 JMS 崩溃了,但谢谢你

标签: java ssl jms activemq jndi


【解决方案1】:

我会回答我自己的问题:

首先在 ..../apache-activemq-5.11.1/conf/activemq.xml :

<transportConnectors>
  <transportConnector name="ssl" uri="ssl://0.0.0.0:61617?trace=true&amp;needClientAuth=true"/>
</transportConnectors>

不要忘记在服务器端阻塞的 & amp;(没有空格)。在activemq页面上没有写。也不要忘记打开你的端口。这里 (61617)

仍在activemq.xml中

<sslContext>
     <sslContext keyStore="file:${activemq.base}/conf/amq-server.ks" 
                 keyStorePassword="PASSWORD" 
                 trustStore="file:${activemq.base}/conf/amq-server.ts" 
                 trustStorePassword="PASSWORD" />
  </sslContext>

重启JMS;这次应该没问题。现在你的服务器端没问题了,让我们去客户端吧。

我已经在 activemq ..../apache-activemq-5.11.1/conf 中做到了这一点:(按照要求的内容,名称,通过等...)。

## Create a keystore for the broker SERVER
$ keytool -genkey -alias amq-server -keyalg RSA -keysize 2048 -validity 90 -keystore amq-server.ks

## Export the broker SERVER certificate from the keystore
$ keytool -export -alias amq-server -keystore amq-server.ks -file amq-server_cert

## Create the CLIENT keystore
$ keytool -genkey -alias amq-client -keyalg RSA -keysize 2048 -validity 90 -keystore amq-client.ks

## Import the previous exported broker's certificate into a CLIENT truststore
$ keytool -import -alias amq-server -keystore amq-client.ts -file amq-server_cert

## If you want to make trusted also the client, you must export the client's certificate from the keystore
$ keytool -export -alias amq-client -keystore amq-client.ks -file amq-client_cert

## Import the client's exported certificate into a broker SERVER truststore
$ keytool -import -alias amq-client -keystore amq-server.ts -file amq-client_cert

然后我在https://winscp.net/eng/index.php 的帮助下将我的“amq-client.ts”和“amq-client.ks”从我的服务器下载到我的 PC(我在 windows 上开发,在 linux 上开发服务器)。

我在 eclipse 中使用这两个文件作为源。 (我不会解释如何)。

最后在 Eclipse 中我只需要更改一件事,我必须用 ActiveMQSslConnectionFactory 替换 QueueConnectionFactory:

所以我删了

QueueConnectionFactory connFactory = (QueueConnectionFactory) ctx
                    .lookup("jms/ConnectionFactory");

取而代之的是:

ActiveMQSslConnectionFactory connectionFactory = new ActiveMQSslConnectionFactory(url);
            try {
                connectionFactory.setTrustStore(CLIENT_TS_FILE);
                connectionFactory.setTrustStorePassword("PASSWORD asked while TS file made");
                connectionFactory.setKeyStore(CLIENT_KS_FILE);
                connectionFactory.setKeyStorePassword("PASSWORD asked while KS file made");
            } catch (Exception e) {
                throw new MotorException(
                        "JMS Connection Failed (Trust store or key store weren't found) : ",
                        e);
            }

至少对于 activemq 和 ssl 来说,互联网上的内容很少,它可能会对某人有所帮助。

【讨论】:

  • 如何提供ssl url
  • 大声笑,是的,我有点懒,但在 Eclipse 中添加文件作为源代码很常见......;我的意思是……
  • 谢谢伊戈尔,正是我需要的
猜你喜欢
  • 2011-10-24
  • 2023-02-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多