【发布时间】:2015-04-30 23:39:48
【问题描述】:
我正在尝试使用以下脚本连接到 GCM CCS 服务器:
#!/usr/bin/perl
use Net::XMPP;
my $con = Net::XMPP::Client->new(
debuglevel => 5,
debugfile => "stdout",
debugtime => 1
);
print "trying ... \n";
my $status = $con->Connect(
hostname => 'gcm-preprod.googleapis.com',
connectiontype => 'tcpip',
port => 5236,
tls => 1
ssl_ca_path => '/etc/ssl/localcerts/gcm.key'
);
die('ERROR: XMPP connection failed') if ! defined($status);
$con->Disconnect();
我收到以下错误:
[17:25:00] XML::Stream: new: hostname = (gcmsender.com)
[17:25:00] XML::Stream: SetCallBacks: tag(node) func(CODE(0x90fe390))
[17:25:00] XMPP::Conn: xmppCallbackInit: start
[17:25:00] XMPP::Conn: SetCallBacks: tag(message) func(CODE(0x90fe530))
[17:25:00] XMPP::Conn: SetCallBacks: tag(presence) func(CODE(0x90fe4b0))
[17:25:00] XMPP::Conn: SetCallBacks: tag(iq) func(CODE(0x90fe3e0))
[17:25:00] XMPP::Conn: SetPresenceCallBacks: type(subscribe) func(CODE(0x90fe4a0))
[17:25:00] XMPP::Conn: SetPresenceCallBacks: type(subscribed) func(CODE(0x90fe6f0))
[17:25:00] XMPP::Conn: SetPresenceCallBacks: type(unsubscribe) func(CODE(0x90fe670))
[17:25:00] XMPP::Conn: SetPresenceCallBacks: type(unsubscribed) func(CODE(0x90fe770))
[17:25:00] XMPP::Conn: SetDirectXPathCallBacks: xpath(/[@xmlns="urn:ietf:params:xml:ns:xmpp-tls"]) func(CODE(0x90fe6e0))
[17:25:00] XMPP::Conn: SetDirectXPathCallBacks: xpath(/[@xmlns="urn:ietf:params:xml:ns:xmpp-sasl"]) func(CODE(0x9102ba8))
[17:25:00] XMPP::Conn: xmppCallbackInit: stop
trying ...
[17:25:00] XMPP::Conn: Connect: host(gcm-preprod.googleapis.com:5236) namespace(jabber:client)
[17:25:00] XMPP::Conn: Connect: timeout(10)
[17:25:00] XML::Stream: Connect: timeout(10)
[17:25:00] XML::Stream: Connect: type(tcpip)
[17:25:00] XML::Stream: Connect: Got a connection
[17:25:00] XML::Stream: MarkActivity: sid(newconnection)
[17:25:00] XML::Stream: Send: (<?xml version='1.0'?><stream:stream version='1.0' xmlns:stream='http://etherx.jabber.org/streams' xmlns='jabber:client' to='gcm-preprod.googleapis.com' from='gcmsender.com' xml:lang='en' >)
[17:25:00] XML::Stream: Send: sid(newconnection)
[17:25:00] XML::Stream: Send: status(0)
[17:25:00] XML::Stream: Send: socket(IO::Socket::INET=GLOB(0x90fe580))
[17:25:00] XML::Stream: Send: can_write
[17:25:00] XML::Stream: Send: SENDWRITTEN(196)
[17:25:00] XML::Stream: Send: no exceptions
[17:25:00] XML::Stream: MarkActivity: sid(newconnection)
[17:25:00] XML::Stream: Connect: can_read( )
[17:25:00] XML::Stream: Read: sid(newconnection)
[17:25:00] XML::Stream: Read: connectionType(tcpip)
[17:25:00] XML::Stream: Read: socket(IO::Socket::INET=GLOB(0x90fe580))
[17:25:00] XML::Stream: Read: buff()
[17:25:00] XML::Stream: Read: status(0)
[17:25:00] XML::Stream: Read: ERROR
[17:25:00] XML::Stream: GetErrorCode: sid(newconnection)
ERROR: XMPP connection failed at ccsclient.pl line 18.
Google 的文档提到:
您必须启动传输层安全 (TLS) 连接。请注意,CCS 目前不支持 STARTTLS 扩展。
因此,如果我在不指定路径的情况下启用 tls,则会出现以下错误:
Invalid or unreadable path specified for ssl_ca_path. at /usr/local/share/perl/5.10.1/XML/Stream.pm line 640.
是因为 perls Net::XMPP 模块正在使用 STARTTLS 吗?如何使用 perl 连接到 CCS?
【问题讨论】: