问题
I have rabbitMQ installed using the following configuration
[
{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}]}
]}
].
And i am Instantiating the Connection Factory as such (data replaced with dummy):
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);
}
When I try to connect I get the following error from the Java side
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)
And the following appears on the rabbitMQ Logs (192.168.24.75 is my 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"}}
Both the application and the queue are on my machine at the moment. I have opened up TCP ports 5671 and 5672 on my firewall.
Am I missing something?
回答1:
The issue was not in that code, but rather with the path to my Keycert I was using the Server Certificate rather than the Client Certificate.
来源:https://stackoverflow.com/questions/25304789/rabbitmq-ssl-giving-handshake-failure-when-using-springamqp