我正在尝试通过 SSL 连接到 RabbitMQ。我已按照[此处}(https://www.rabbitmq.com/ssl.html)链接的 RabbitMQ SSL 文档进行操作。
根据 RabbitMQ SSL 文档,由于已知漏洞,不建议使用 SSLv3 和 TLSv1 连接。因此,我按照说明在 RabbitMQ 上禁用了这些协议。
我正在使用 Spring AMQP 1.4.3 连接到 RabbitMQ。
ApplicationContext context = new GenericXmlApplicationContext("classpath:/testConfig/testrabbit-context.xml");
RabbitTemplate template = context.getBean(RabbitTemplate.class);
MessageProperties messageProperties = new MessageProperties();
org.springframework.amqp.core.Message amqpMessage = new org.springframework.amqp.core.Message("Test".getBytes(), messageProperties);
String routingKey = "TEST.businessevent.route";
template.send(routingKey, amqpMessage);
Run Code Online (Sandbox Code Playgroud)
我的配置:
<rabbit:connection-factory id="rabbitConnectionFactory"
connection-factory="clientConnectionFactory"
host="localhost"
port="5671"
username="username"
password="password"
virtual-host="test_host" />
<rabbit:admin connection-factory="rabbitConnectionFactory" />
<rabbit:template id="rabbitTemplate"
connection-factory="rabbitConnectionFactory" exchange="test_topic" />
<rabbit:topic-exchange name="test_topic" durable="true" />
<bean id="clientConnectionFactory" class="org.springframework.amqp.rabbit.connection.RabbitConnectionFactoryBean">
<property name="useSSL" value="true" />
<property name="sslPropertiesLocation" value="/testconfig/rabbitSSL.properties"/>
</bean>
Run Code Online (Sandbox Code Playgroud)
rabbitSSL.properties:
keyStore=file:/client/keycert.p12
trustStore=file:/lib/security/rabbitStore
keyStore.passPhrase=testpassword
trustStore.passPhrase=testpassword
Run Code Online (Sandbox Code Playgroud)
但是,当我使用上述代码和配置通过 SSL 连接到 RabbitMQ 时,我收到致命警报:protocol_version。
当我查看org.springframework.amqp.rabbit.connection.RabbitConnectionFactoryBeanSpring 用于连接到 RabbitMQ 的类时,我可以看到该协议似乎被硬编码为 SSLv3。
keyStore=file:/client/keycert.p12
trustStore=file:/lib/security/rabbitStore
keyStore.passPhrase=testpassword
trustStore.passPhrase=testpassword
Run Code Online (Sandbox Code Playgroud)
如果我不在 RabbitMQ 上禁用 SSLv3,此代码可以正常工作。但是我需要使用 Tlsv1.2 连接到 RabbitMQ。我可以使用 Spring AMQP 1.4.3 来做到这一点还是需要使用其他版本。
感谢您为我提供的有关此问题的任何帮助。
小智 5
在搜索 RabbitMQ 远程访问时,我遇到了以下 Springapplication.properties配置设置,可以在 Spring 中完成这些设置来配置 RabbitMQ 连接。
https://www.oodlestechnologies.com/blogs/Connect-to-SSL-enabled-RabbitMQ-server-Springboot/
spring.rabbitmq.host=hostURL
spring.rabbitmq.port = hostPort
spring.rabbitmq.username = username
spring.rabbitmq.password = password
spring.rabbitmq.virtual-host=virtualHost
spring.rabbitmq.ssl.enabled=true
spring.rabbitmq.ssl.algorithm=TLSv1.2
Run Code Online (Sandbox Code Playgroud)
https://www.baeldung.com/spring-remoting-amqp#2-configuration
| 归档时间: |
|
| 查看次数: |
17322 次 |
| 最近记录: |