目标:我正在研究RabbitMQ的无密码身份验证。我的目标是让一个简单的Java客户端通过TLS连接到RabbitMQ服务器
平台:
根据文档采取的步骤:
我指的是https://www.rabbitmq.com/ssl.html
上的文档1)我已经生成了(https://www.rabbitmq.com/ssl.html#manual-certificate-generation)中提到的CA,证书,私钥
2)与TLS相关的基本设置是在Rabbitmq.config中完成的,如下所示(https://www.rabbitmq.com/ssl.html#enabling-tls):
[{
rabbit, [
{
tcp_listeners, [5672]
},{
tcp_listeners, [{"127.0.0.1", 5672},
{"::1", 5672}]
},
{password_hashing_module, rabbit_password_hashing_sha512},
{auth_mechanisms, ['PLAIN', 'AMQPLAIN', 'EXTERNAL']},
{ssl_listeners, [5671]},
{ssl_options, [{cacertfile, "/path/to/ca_certificate_bundle.pem"},
{certfile, "/path/to/server_certificate.pem"},
{keyfile, "/path/to/server/private_key.pem"},
{password, "password"},
{verify, verify_peer},
{fail_if_no_peer_cert, false}]}
]
}].
3)我已验证日志文件(https://www.rabbitmq.com/ssl.html#enabling-tls-verify-configuration)中已启用TLS
4)我正在通过TLS为RabbitMQ服务器设置一个简单的示例Java客户端,而没有验证https://www.rabbitmq.com/ssl.html#java-client-connecting
中提到的证书问题:
运行代码后,出现如下所示的套接字超时异常:
Exception in thread "main" java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.socketRead(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at sun.security.ssl.InputRecord.readFully(Unknown Source)
at sun.security.ssl.InputRecord.read(Unknown Source)
at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
at sun.security.ssl.SSLSocketImpl.writeRecord(Unknown Source)
at sun.security.ssl.AppOutputStream.write(Unknown Source)
at java.io.BufferedOutputStream.flushBuffer(Unknown Source)
at java.io.BufferedOutputStream.flush(Unknown Source)
at java.io.DataOutputStream.flush(Unknown Source)
at com.rabbitmq.client.impl.SocketFrameHandler.sendHeader(SocketFrameHandler.java:147)
at com.rabbitmq.client.impl.SocketFrameHandler.sendHeader(SocketFrameHandler.java:153)
at com.rabbitmq.client.impl.AMQConnection.start(AMQConnection.java:285)
at com.rabbitmq.client.impl.recovery.RecoveryAwareAMQConnectionFactory.newConnection(RecoveryAwareAMQConnectionFactory.java:62)
at com.rabbitmq.client.impl.recovery.AutorecoveringConnection.init(AutorecoveringConnection.java:99)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:900)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:859)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:817)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:954)
at Example1.main(Example1.java:17)
在Example1.java中,该行在Connection conn = factory.newConnection();处失败
我已经在网上搜索了此异常,但是提供的解决方案似乎无关。您能告诉我我要去哪里了吗?