我在将Php客户端应用程序连接到启用了Ssl的ActiveMq安装时遇到问题。我查看了许多资料,并且在我前进时变得越来越困惑。
到目前为止,我的设置使用通过users / groups.properties和authorizationPlugin进行身份验证。在常规连接上效果很好
对于ActiveMq Ssl,我关注了几篇文章,并创建了Jks存储区和证书,并配置了以下内容
<sslContext>
<sslContext keyStore="file:${activemq.base}/conf/server.ks"
keyStorePassword="$STORE_PASS"
trustStore="file:${activemq.base}/conf/server.ts"
trustStorePassword="$STORE_PASS" />
</sslContext>
<transportConnector
name="stomp+ssl" uri="stomp+ssl://0.0.0.0:61617?needClientAuth=true"/>
我还尝试了ACTIVEMQ_SSL_OPTS方法。启动服务器时,两者均加载正常。日志显示Sll连接器已启动。我还检查了php cli以确保在stomp安装中启用了Sll
我遇到的问题是Php踩踏客户端。首先,这些是我阅读的文章。
http://activemq.apache.org/how-do-i-use-ssl.html
http://php.net/manual/en/stomp.construct.php
https://github.com/stomp-php/stomp-php/wiki/Connectivity
据我了解,有两个基于文档的php stomp库,我不知道如何设置所有这些。 php网站的文档只是简单地给出了将构造函数与ssl协议结合使用的示例
$link = stomp_connect('ssl://localhost:61612', $user, $pass, $headers);
这不起作用,我在日志中得到一个空证书错误。
另一篇使用FuseSource stomp的文章提供了在建立连接时包括客户端证书的选项,但深入该文章后,似乎只是通过Sll证书而不是用户/密码进行身份验证。
https://github.com/rethab/php-stomp-cert-example/blob/master/README.md
所以我回到以前的stomp安装,以为有一种方法可以传递客户端证书文件,但是似乎没有接口,并且我假设标头param上没有文档,去做这个。
有人误会我错了吗?
答案 0 :(得分:1)
我不知道您是否仍然感兴趣,但是以防万一有人偶然发现了这个问题,希望得到答案。
我们将https://github.com/stomp-php/stomp-php/用于我们的Stomp连接,这大致就是我们创建客户端的方式:
function createClient($broker_url, $login, $password) {
$client = new \Stomp\Client($broker_url);
$sslContext = [
'ssl' => [
'cafile' => '/path/to/cert',
'verify_peer' => true,
'verify_peer_name' => false,
'ciphers' => 'HIGH',
],
];
$client->getConnection()->setContext($sslContext);
$client->setLogin($login, $password);
$client->connect();
return new \Stomp\StatefulStomp($client);
}
$ broker_url的格式应为ssl://host:port
。