gpt4 book ai didi

java - RabbitMQ SSL 在使用 SpringAMQP 时出现握手失败

转载 作者:行者123 更新时间:2023-11-30 08:21:19 25 4
gpt4 key购买 nike

我使用以下配置安装了 rabbitMQ

[
{rabbit, [
{ssl_listeners, [5671]},
{ssl_options, [{cacertfile,"C:\\dev\\rabbitcert\\testca\\cacert.pem"},
{certfile,"C:\\dev\\rabbitcert\\server\\cert.pem"},
{keyfile,"C:\\dev\\rabbitcert\\server\\key.pem"},
{verify,verify_peer},
{fail_if_no_peer_cert,false}]}
]}
].

我正在实例化连接工厂(数据替换为虚拟):

private static ConnectionFactory getConnectionFactoryForQueue(){
com.rabbitmq.client.ConnectionFactory connectionFactory = new com.rabbitmq.client.ConnectionFactory();
connectionFactory.setUsername("user");
connectionFactory.setHost("MyIpAddress.0.1.1");
connectionFactory.setPassword("pass");
connectionFactory.setPort(5671);
connectionFactory.setVirtualHost("/");
SsmProtos.SSLDetails ssl = listener.getSslDetails();
char[] keyPassphrase = "keyPassPhrase".toCharArray();
try {
KeyStore ks = KeyStore.getInstance("PKCS12");
ks.load(new FileInputStream("path/to/keycert.p12"), keyPassphrase);

KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
kmf.init(ks, keyPassphrase);

char[] trustPassphrase = "trustPassPhrase".toCharArray();
KeyStore tks = KeyStore.getInstance("JKS");
tks.load(new FileInputStream("path/to/trust/store"), trustPassphrase);

TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
tmf.init(tks);

SSLContext c = SSLContext.getInstance("SSLv3");
c.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
connectionFactory.useSslProtocol(c);

} catch (NoSuchAlgorithmException | CertificateException | IOException |
UnrecoverableKeyException | KeyStoreException | KeyManagementException e) {
throw new IllegalArgumentException("Failed Setting up SSL",e);
}
return new CachingConnectionFactory(connectionFactory);
}

当我尝试连接时,我从 Java 端收到以下错误

Errors encountered:Error creating bean with name 'getSsmRequestAmqpAdmin' defined in class com.ixaris.ssm.server.service.ServerConfiguration: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.springframework.amqp.core.AmqpAdmin com.ixaris.ssm.shared.busobject.ServerInfoConfiguration.getSsmRequestAmqpAdmin()] threw exception; nested exception is org.springframework.amqp.AmqpIOException: java.net.SocketException: Software caused connection abort: recv failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'getSsmRequestAmqpAdmin' defined in class com.ixaris.ssm.server.service.ServerConfiguration: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.springframework.amqp.core.AmqpAdmin com.ixaris.ssm.shared.busobject.ServerInfoConfiguration.getSsmRequestAmqpAdmin()] threw exception; nested exception is org.springframework.amqp.AmqpIOException: java.net.SocketException: Software caused connection abort: recv failed
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:597)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1094)
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.springframework.amqp.core.AmqpAdmin com.ixaris.ssm.shared.busobject.ServerInfoConfiguration.getSsmRequestAmqpAdmin()] threw exception; nested exception is org.springframework.amqp.AmqpIOException: java.net.SocketException: Software caused connection abort: recv failed
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:188)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:586)
Caused by: org.springframework.amqp.AmqpIOException: java.net.SocketException: Software caused connection abort: recv failed
at org.springframework.amqp.rabbit.support.RabbitExceptionTranslator.convertRabbitAccessException(RabbitExceptionTranslator.java:63)
at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:195)

Caused by: java.net.SocketException: Software caused connection abort: recv failed
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:150)

然后在rabbitMQ Logs上出现如下内容(192.168.24.75是我的IP)

=INFO REPORT==== 14-Aug-2014::11:25:07 ===
accepting AMQP connection <0.272.0> (192.168.24.75:49860 -> 192.168.24.75:5671)

=ERROR REPORT==== 14-Aug-2014::11:25:08 ===
SSL: certify: ssl_handshake.erl:1391:Fatal error: handshake failure

=ERROR REPORT==== 14-Aug-2014::11:25:13 ===
error on AMQP connection <0.272.0>:
{ssl_upgrade_error,{tls_alert,"handshake failure"}}

应用程序和队列目前都在我的机器上。我已经在我的防火墙上打开了 TCP 端口 5671 和 5672。

我错过了什么吗?

最佳答案

问题不在于该代码,而在于我的 Keycert 的路径我使用的是服务器证书而不是客户端证书。

关于java - RabbitMQ SSL 在使用 SpringAMQP 时出现握手失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25304789/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com