繁体   English   中英

如何在ssl中activemq

[英]How to activemq in ssl

我正在尝试通过jms(activemq)发送消息,但我希望它是在ssl协议中。 它现在在tcp中工作。

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

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

谢谢

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

我会回答我自己的问题:

首先内部.... / 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”从我的服务器到我的电脑(我在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很少有人可以帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM