Skip to content

stomp+ssl #34

Open
Open
@josecelano

Description

@josecelano

I am trying to connect to stomp over ssl and I get this error

SSL/TLS handshake failed

My sample:

<?php

echo "stomb test";

$queue  = '/queue/foo';
$msg    = 'bar';

$user = 'admin';
$pwd = 'XXXXX';

/* connection */
try {
    $stomp = new Stomp('ssl://XXX.XXX.XX.XXX:61612', $user, $pwd);
} catch(StompException $e) {
    //var_dump($stomp->error());
    die('Connection failed: ' . $e->getMessage());
}

/* send a message to the queue 'foo' */
$stomp->send($queue, $msg);

/* subscribe to messages from the queue 'foo' */
$stomp->subscribe($queue);

/* read a frame */
$frame = $stomp->readFrame();

if ($frame->body === $msg) {

    var_dump($frame);

    // acknowledge that the frame was received
    $stomp->ack($frame);
}

/* close connection */
unset($stomp);

And my activemq.xml config file:

    <sslContext>
        <sslContext 
              keyStore="file:${activemq.base}/conf/broker.ks" 
              keyStorePassword="password" trustStore="file:${activemq.base}/conf/broker.ts" 
              trustStorePassword="password"/>
    </sslContext>

Server is up and accepting stomp connections.

This is the ActiveMQ guide to use stomp+ssl
http://activemq.apache.org/how-do-i-use-ssl.html

I suppose:

  • I have to create two certificates for broker and client.
  • Restart ActiveMQ.
  • And configure PHP client to use server certificate, something like this:
$context = stream_context_create(); 
$result = stream_context_set_option($context, 'ssl', 'local_cert', '/path/to/keys.pem'); 
$result = stream_context_set_option($context, 'ssl', 'passphrase', 'pass_to_access_keys'); 

Does somebody knows any good step by step tutorial/sample code?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions