我会回答我自己的问题:
首先在 ..../apache-activemq-5.11.1/conf/activemq.xml 里面:
<transportConnectors>
<transportConnector name="ssl" uri="ssl://0.0.0.0:61617?trace=true&needClientAuth=true"/>
</transportConnectors>
不要忘记&(没有空格)这就是服务器端阻塞的原因。在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 来说,它可能会对某人有所帮助。