0

I'm trying to run the SSL example "amqps_listenq" in rabbitmq-c library (ssl-plumbing branch) using the command line

$./amqps_listenq [ServerIP]  5671 hello ./cacert.pem ./key.pem ./cert.pem

i got the following error

opening SSL/TLS connection

when i try to debug the code it fails in the following block in main

status = amqp_socket_open(socket, hostname, port);
if (status) {
    die("opening SSL/TLS connection");
}

when i debug into "amqp_socket_open" method i found that it fails in the following block in amqp_openssl.c

if (self->verify) {
    int status = amqp_ssl_socket_verify(self, host);
    if (status) {
        return -1;
    }
}

I traced the error inside amqp_ssl_socket_verify and found that i fails in the following block

#ifdef _MSC_VER
#define strcasecmp _stricmp
#endif
    if (strcasecmp(host, (char *)utf8_value)) {
        goto error; //<-- it fails here
    }
#ifdef _MSC_VER
#undef strcasecmp
#endif
exit:
    OPENSSL_free(utf8_value);
    return status;
error:
    status = -1;
    goto exit;

status was equal to -1 any idea where is the problem??

Note that i can easily connect to RabbitMq with SSL on the same server using java even i didn't set certificates using the following code

ConnectionFactory factory = new ConnectionFactory();
factory.setHost("[ServerIP]");
factory.setPort(5671);
factory.useSslProtocol();
factory.setUsername("guest");
factory.setPassword("guest");
Connection connection = factory.newConnection();
Channel channel = connection.createChannel();

channel.queueDeclare("hello_ssl", false, false, false, null);
System.out.println(" [*] Waiting for messages. To exit press CTRL+C");

QueueingConsumer consumer = new QueueingConsumer(channel);
channel.basicConsume(QUEUE_NAME, true, consumer);

while (true){
  QueueingConsumer.Delivery delivery = consumer.nextDelivery();
  String message = new String(delivery.getBody());
  System.out.println(" [" + i + "] Received '" + message + "'");
}

2 Answers 2

1

I have been debugging librabbitmq and I see exactly the same behavior. The utf8_value variable contains "amqp" while the host variable contains the amqp server hostname.

I have a work around:

-  if (strcasecmp(host, (char *)utf8_value)) {
-    goto error;
+
+  if(strcasecmp((char *)utf8_value, "amqp")) {
+    if (strcasecmp(host, (char *)utf8_value) ) {
+      goto error;
+    }
   }

I have forked and patched here: https://github.com/drainware/rabbitmq-c

Sign up to request clarification or add additional context in comments.

Comments

0

The problem is the certificate, verify that the domain matches in the certificate details.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.