gpt4 book ai didi

perl - 在 Perl 中使用 Net::STOMP::Client 模块通过 SSL 连接到 JMS 主题代理时出错

转载 作者:太空宇宙 更新时间:2023-11-03 14:50:15 26 4
gpt4 key购买 nike

我正在尝试借助 Perl 中的 Net::STOMP::Client 包连接到 TIBCO JMS 主题代理。

我在创建新的 Net::STOMP::Client 对象并传递属性“uri”和“sockopts”时使用 SSL 方法,它采用主题 Uri 和 SSL 证书文件进行身份验证。

当我尝试运行此脚本时,它会抛出一条错误消息:-

无法通过 SSL 连接到 mmx-nprd1-06:7222:IO::Socket::INET6 配置失败

代码如下:-

use Net::Stomp;
use Net::STOMP::Client;

use Moose;
use strict;
use warnings;
use FindBin qw($Bin);

print "\n$Bin\n";

my $stomp;

$stomp = Net::STOMP::Client->new(
uri => "stomp+ssl://mmx-nprd1-06:7222",
sockopts => {
# path of the directory containing trusted certificates
SSL_ca_path => "$Bin/JmsCertificate/",
# client certificate to present
SSL_cert_file => "$Bin/JmsCertificate/aix_jms_cert.pem",
# # client private key
SSL_key_file => "$Bin/JmsCertificate/aix_jms_key.pem",
# passphrase of the client private key
SSL_passwd_cb => sub { return("password") },
},
);

$stomp->connect();

my $peer = $stomp->peer();
printf("connected to broker %s (IP %s), port %d\n", $peer->host(), $peer->addr(), $peer->port());

my $sid = $stomp->uuid();
$stomp->subscribe(
destination => "/queue/test",
# we use the generated subscription id
id => $sid,
# we want a receipt on our SUBSCRIBE frame
receipt => $stomp->uuid(),
);
my $count = 0;
my $frame;

while ($count < 10) {
$frame = $stomp->wait_for_frames(timeout => 1);
if ($frame) {
if ($frame->command() eq "MESSAGE") {
$count++;
printf("received message %d with id %s\n",
$count, $frame->header("message-id"));
} else {
# this will catch the RECEIPT frame
printf("%s frame received\n", $frame->command());
}
} else {
print("waiting for messages...\n");
}
}
$stomp->unsubscribe(id => $sid);
$stomp->disconnect();

谁能帮我解决这个问题,因为我无法弄清楚这里出了什么问题。

最佳答案

我在使用 uri key 时也遇到了一些问题,请尝试以下操作:

$stomp = Net::STOMP::Client->new(host => "mmx-nprd1-06", port => 7222,
sockopts => {
# path of the directory containing trusted certificates
SSL_ca_path => "$Bin/JmsCertificate/",
# client certificate to present
SSL_cert_file => "$Bin/JmsCertificate/aix_jms_cert.pem",
# # client private key
SSL_key_file => "$Bin/JmsCertificate/aix_jms_key.pem",
# passphrase of the client private key
SSL_passwd_cb => sub { return("password") }, # Leave this out if your key doesn't require a passphrase
},
);

$stomp->connect(login => "aix_jms", passcode => "some_password");

关于perl - 在 Perl 中使用 Net::STOMP::Client 模块通过 SSL 连接到 JMS 主题代理时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35031477/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com