ActiveMQ - How do I use SSL

开发者福利!热门AI工具限时免费用 购周边即赠Coding Plan Lite,Claude Code、Cursor等20+工具畅享,效率翻倍! 阅读详情

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



Setting up the Key and Trust Stores

Also see Tomcat's SSL instructions for more info. The following was provided by Colin Kilburn. Thanks Colin!

ActiveMQ uses dummy credentials by default

ActiveMQ includes key and trust stores that reference a dummy self signed cert. When you create a broker certificate and stores for your installation, either overwrite the values in the conf directory or delete the existing dummy key and trust stores so they cannot interfere)

  1. Using keytool, create a certificate for the broker:

    keytool -genkey -alias broker -keyalg RSA -keystore broker.ks
  2. Export the broker's certificate so it can be shared with clients:

    keytool -export -alias broker -keystore broker.ks -file broker_cert
  3. Create a certificate/keystore for the client:

    keytool -genkey -alias client -keyalg RSA -keystore client.ks
  4. 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

Starting the Broker

Using the javax.net.ssl.* System Properties

Before starting the broker's VM set the ACTIVEMQ_SSL_OPTS environment variable so that it knows to use the broker keystore.  (note that in previous versions of ActiveMQ this property was called SSL_OPTS in some scripts.  As of v5.12.0 all scripts use ACTIVEMQ_SSL_OPTS)

export ACTIVEMQ_SSL_OPTS = -Djavax.net.ssl.keyStore=/path/to/broker.ks -Djavax.net.ssl.keyStorePassword=password
Using Spring to configure SSL for a Broker instance

Sometimes the use of javax.net.ssl.* system properties is not appropriate as they effect all SSL users in a JVM. ActiveMQ 5.2.x adds an <sslContext> element to the <amq:broker> that allows a broker specific set of SSL properties to be configured.

The SslContext test case validates starting an SSL transport listener using the configuration specified in the broker Xbean. The SslContext element is added to the broker as follows:

<beans
   <amq:broker useJmx= "false" persistent= "false" >
 
     <amq:sslContext>
       <amq:sslContext
             keyStore= "broker.ks" keyStorePassword= "password"
             trustStore= "client.ks" trustStorePassword= "password" />
     </amq:sslContext>
 
     <amq:transportConnectors>
       <amq:transportConnector uri= "ssl://localhost:61616" />
     </amq:transportConnectors>
 
   </amq:broker>
</beans>

The SslContext is used to configure the SslTransportFactory for that broker. Full details of the configuration options available can be seen in the schema definition or in the accessors of org.apache.activemq.spring.SpringSslContext

Starting the Client

When starting the client's VM, specify the following system properties:

javax.net.ssl.keyStore=/path/to/client.ks
javax.net.ssl.keyStorePassword=password
javax.net.ssl.trustStore=/path/to/client.ts

In Linux, do not use absolute path to keystore. By default, keytool uses ~/.keystore, but in some setups passing -Djavax.net.ssl.keyStore=/home/account/.keystore to Java VM does not work. This is not ActiveMQ specific but good to keep in mind anyway.

Client certificates

If you want to verify client certificates, you need to take a few extra steps:

  1. Export the client's certificate so it can be shared with broker:

    keytool -export -alias client -keystore client.ks -file client_cert
  2. Create a truststore for the broker, and import the client's certificate. This establishes that the broker "trusts" the client:

    keytool - import -alias client -keystore broker.ts -file client_cert
  3. Add

    -Djavax.net.ssl.trustStore=/path/to/broker.ts

    to ACTIVEMQ_SSL_OPTS

  4. Instruct ActiveMQ to require client authentication by setting the following in activemq.xml:

    <transportConnectors>
       <transportConnector name= "ssl" uri= "ssl://localhost:61617?needClientAuth=true" />
    </transportConnectors>

Certificate revocation

Starting with version 5.12, you can define certificate revocation list (CRL) path on ssl context, so that invalid certificates can revoked

< sslContext >
     < sslContext keyStore = "org/apache/activemq/security/broker1.ks"
                 keyStorePassword = "password"
                 trustStore = "org/apache/activemq/security/activemq-revoke.jks"
                 trustStorePassword = "password"
                 crlPath = "org/apache/activemq/security/activemq-revoke.crl" />
</ sslContext >

This list is static and loaded on broker startup.

Starting with version 5.14.0, you can also enable more advanced Online Certificate Status Protocol (OCSP) protocol. For that you need to configure a location for the java.security configuration extension by setting appropriate system properties (in ${ACTIVEMQ_HOME}/bin/env) like

ACTIVEMQ_SSL_OPTS= "-Djava.security.properties=$ACTIVEMQ_CONF/java.security"

Then you need to configure OCSP responder properties in java.security file like

ocsp.enable= true
ocsp.responderURL=http: //ocsp.example.net:80

A demo of the broker configuration working with OCSP responder can be found at https://github.com/dejanb/sslib

Working Around Java 7 SSL Bugs

As noted by issue AMQ-5970, it seems some versions of Java 7 have problems with SSL sessions that need to use the Diffie-Hellman cypher suite. If you run into this issue, just copy the Bouncy Castle bcprov-jdk15on-148.jar to ActiveMQ's lib directory and restart your broker.

These links might also help

activeMQ-传输协议 ActiveMQ支持的client-broker:Transmission Control Protocol (TCP) 这是默认的Broker配置,TCP的Client监听端口是61616。 在网络传输数据前,必须要序列化数据,消息是通过一个叫wire protocol的来序列化成字节流。目的是促使网络上的效率和数据快速交互。 TCP连接的URI形式:tcp://hostn 阅读详情

相关推荐

从硬件到软件:TSMaster报文过滤全链路配置指南(含同星设备适配)

本文详细介绍了TSMaster平台下CAN/LIN/FlexRay总线的报文过滤全链路配置指南,特别针对同星TC1016等硬件的兼容性进行实战演示。从硬件层预过滤到软件层可编程过滤,提供五维过滤体系构建方法,帮助工程师提升车载诊断与总线分析效率。重点解析混合总线过滤策略优化及诊断场景下的特殊过滤方案。

tensorflowjs6的博客 340

useSSL

useSSL=false和useSSL=true的区别: SSL即为:Secure Sockets Layer 安全套接字协议。 在MySQL进行连接时: 如果MySQL的版本是5.7之后的版本必须要加上useSSL=false, mysql5.7以及之前的版本则不用进行添加useSSL=false,会默认为false, 一般情况下都是使用useSSL=false,尤其是在将项目部署到linux上时要使用useSSL=false useSSL=true:就是一般通过证书或者令牌进行...

qq_51515673的博客 1万+

锁定放大器

锁定放大器

qq_46757048的博客 4666

useSSL是什么?设置成false和true的区别

安全套接字协议),,在外面连接mysql的时候,版本若是在5.7之前,就不用加这个useSSL,若是大于5.7,则需要添加useSSL。设置成false:直接通过账号密码连接,所以通常使用useSSL=false!【在linux系统里面一定要加这个配置】设置成true:是进行安全验证,一般需要通过一些证书或者令牌。SSL全称(Secure Sockets。

小魏快起床的博客 3439

useSSL是什么意思

配置数据库连接的时候经常见到useSSL=false/true

未系上弦月 1714

配置 ActiveMQ 使用 SSL 连接

一、技术背景 SSL(Secure Sockets Layer 安全套接层)及其继任者TLS(TransportLayer Security传输层安全)是为网络通信提供安全及数据完整性的一种安全协议。TLS与SSL在传输层对网络连接进行加密,用以保障在Internet上数据传输之安全,利用数据加密(Encryption)技术,可确保数据在网络上之传输过程中不会被截取及窃听。   JSSE(J

7445

ActiveMQ SSL应用之使用原因、思路、生成密钥和证书

为啥要使用SSL ActiveMQ普通的TCP连接方式,报文在网络中是以明文方式传输的,出于安全的考虑,为了确保报文数据在网络传输过程中不会被截取及窃听,需要使用密文传输,MQ本身是支持SSL加密方式的,开启SSL配置即可满足这一需求,并且不需要修改任何业务代码,加密算法本篇以RSA为例。 SSL应用思路 1、使用keytool工具生成RSA密钥和证书文件。 2、Activ...

zhuhaoyu6666的博客 2008

ActiveMQ 使用SSL

官方地址:http://activemq.apache.org/how-do-i-use-ssl (如果看不懂英文文档,直接使用浏览器翻译一下,很简单的) 1:服务端生成导出证书 keytool -genkey -alias broker -keyalg RSA -keystore broker.ks keytool -export -alias broker -keystore broker.ks -file broker_cert 会提示输入密码,正常输入即可。其他信息可以不填,直接回车。 2:客户

再鹤的博客 1773

Activemq 使用 SSL

 activeqm 使用ssl 除了配置服务端外客户端连接的时候也需要使用ssl,网上的和官方的资料都比较散,因此收集到一起做写例子,共两个部分。第一部分是配置服务端,第二部分是客户端测试连接。  http://activemq.apache.org/download.html 先到官方下载activemq 目前版本是5.2.0,  第一部分 配置服务端 按官方http://a

小茗的专栏 4430

ActiveMQ(五)——ActiveMQ的Transport

一、支持的传输协议 Connector:ActiveMQ提供的,用来实现连接通讯的功能。包括:client-to-broker、broker-to-broker。ActiveMQ允许客户端使用多种协议来连接 配置Transport Connector,在conf/activemq.xml中,配置如下: <transportConnectors> <transportConne...

816

ActiveMq学习⑦__ActiveMq协议

NIO配置cp activemq.xml activemq.xml.bk 备份./activemq stop 停止mq运行修改配置文件NIO测试测试添加nio协议后,默认tcp协议是否支持生产者消费者测试添加nio协议public static final String ACTIVEMQ_URL = “nio://IP地址:61618”;//测试nio 协议生产者消费者。

qq_45905724的博客 726

activemq

activemq熟悉

mengduan913的博客 360

ActiveMQ 传输协议

ActiveMQ允许客户端使用多种协议来连接,配置Transport Connector的文件在activeMQ安装目录的conf/activemq.xml中的标签之内。官方默认提供的: <transportConnectors> <!-- DOS protection, limit concurrent connections to 1000 and frame siz...

方亚军的博客 325

Spring Boot整合ActiveMQ

Spring Boot整合ActiveMQ ActiveMQ概述 官网:http://activemq.apache.org/ MQ全称是MessageQueue(消息队列),是一个消息的接收和转发的容器,主要用于消息的推送。ActiveMQ是Apache提供的一个开源消息中间件,纯Java技术实现。 ActiveMQ的安装(windows) 打开下载官网:http://activemq...

一叶知春秋 2483

ActiveMQ支持的传输协议

连接到ActiveMQ Connector:ActiveMQ提供的,用来实现连接通讯的功能。包括:client-to-broker、broker-to-broker。ActiveMQ允许客户端使用多种协议来连接 配置Transport Connector,在conf/activemq.xml里面,大致如下: ActiveMQ支持的client-broker通讯协议如下: TCP:...

Future_LL的博客 481

ActiveMQ 实战 - ActiveMQ支持的传输协议

Apache ActiveMQ 支持多种传输协议,这些协议使得客户端能够以不同的方式与消息代理(Broker)进行通信。请注意,实际支持的协议可能会随着ActiveMQ版本的更新而有所变化或增加新特性。元素来启用和配置所选协议。开发者可以根据具体需求选择合适的传输协议,并在。配置文件中设置相应的。

qq_33240556的博客 823

解决ssl java.security.cert.CertificateException: No name match

记录一次activemq ssl java.security.cert.CertificateException: No name matching localhost found的问题

清心寡欲,做一个专注的程序员 4639

ActiveMQ是什么?

ActiveMQ是什么?  ActiveMQ 是Apache出品,最流行的,能力强劲的开源消息总线。ActiveMQ 是一个完全支持JMS1.1和J2EE 1.4规范的 JMS Provider实现,尽管JMS规范出台已经是很久的事情了,但是JMS在当今的J2EE应用中间仍然扮演着特殊的地位。 ActiveMQ特性列表  1. 多种语言和协议编写客户端。语言: Java, C, C++

xinsuanwencun的专栏 5053

1.2.2 ActiveMQ支持的消息协议解析

进入到activemq文件目录下,我的是在/var/activemq下,进入conf文件夹中的activemq.xml。 找到这一段,在tcp://0.0.0.0:61616?后面加上transport.trace=true&amp; 然后需要修改一下日志文件的格式vi log4j.properties也是在conf目录下。 在上面加上这段代码log4j.logger.org.apach...

weixin_43871142的博客 365

ActiveMQ学习笔记(7)----ActiveMQ支持的传输协议

1. 连接到ActiveMQ   Connector: Active提供的,用来实现连接通讯的功能,包括:client-to-broker,broker-to-broker.ActiveMQ允许客户端使用多种协议来连接。   1.1 配置Transport Connecto   在conf/activemq.xml里面,大致如下: <transportConnecto...

xiaoshen66的博客 113
上一篇: Redis+Spring缓存实例(windows环境,附实例源码及详解)
下一篇: Java中的SPI(Service Provider Interface)介绍及示例
Sam_qifa
博客等级 码龄15年 6粉丝 8原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值