【问题标题】:Trouble with ActiveMq with Ssl using Php Stomp使用 Php Stomp 与 Ssl 的 ActiveMq 出现问题
【发布时间】:2019-03-12 01:47:00
【问题描述】:

我在将 PHP 客户端应用程序连接到启用了 Ssl 的 ActiveMq 安装时遇到问题。我查看了许多来源,并且随着我的去向越来越困惑。

到目前为止,我的设置使用通过 users/groups.properties 和 authenticationPlugin 进行的身份验证。这适用于常规连接

对于 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 stomp 客户端。首先,这些是我阅读的文章。

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 安装,认为有一种方法可以传递客户端证书文件,但似乎没有它的接口,并且我假设标题参数上没有文档不是如何去吧。

谁能解释一下我在这个复杂的混乱中出错了。

【问题讨论】:

    标签: php ssl activemq stomp


    【解决方案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

    【讨论】:

      猜你喜欢
      • 2017-03-06
      • 2018-03-27
      • 2012-04-28
      • 2021-04-23
      • 2011-05-29
      • 2015-10-12
      • 2014-09-01
      • 1970-01-01
      • 2016-01-27
      相关资源
      最近更新 更多