【问题标题】:XMPP SSL Handshake failedXMPP SSL 握手失败
【发布时间】:2012-10-11 14:11:08
【问题描述】:

我很难与 XMPP (Prosody) 建立连接。但是,如果我使用 PSI,它可以正常工作并请求您的建议。

这是我的python的代码sn-p:

client = xmpp.Client(host)
client.connect(server=(host,port))
client.auth(username, passwd,resource='', sasl=1)
client.sendInitPresence()

在调试模式下:

DEBUG: dispatcher  warn  Registering protocol "error" as <class 'xmpp.protocol.Protocol'>(http://etherx.jabber.org/streams)
DEBUG: socket      sent  <?xml version='1.0'?><stream:stream xmlns="jabber:client" to="localhost" version="1.0" xmlns:stream="http://etherx.jabber.org/streams" >
DEBUG: socket      error Socket error while receiving data
                         Traceback (most recent call last):
                            File "/usr/local/lib/python2.7/dist-packages/xmpp/transports.py", line 161, in receive
                            try: received = self._recv(BUFLEN)
                            error: [Errno 104] Connection reset by peer
DEBUG: client      stop  Disconnect detected
DEBUG: socket      error Socket operation failed
                         Traceback (most recent call last):
                            File "/usr/local/lib/python2.7/dist-packages/xmpp/transports.py", line 161, in receive
                            try: received = self._recv(BUFLEN)
                            error: [Errno 104] Connection reset by peer
DEBUG: socket      error Socket error while receiving data
DEBUG: client      stop  Disconnect detected

**Prosody logs :** 
Oct 20 23:46:39 c2s94ba718      info    Client connected
Oct 20 23:46:39 c2s94ba718      info    Client disconnected: ssl handshake failed
Oct 20 23:46:39 c2s94ba718      info    Destroying session for (unknown) ((unknown)@(unknown))
Oct 20 23:48:57 c2s96052a0      info    Client connected
Oct 20 23:48:57 c2s96052a0      info    Client disconnected: ssl handshake failed
Oct 20 23:48:57 c2s96052a0      info    Destroying session for (unknown) ((unknown)@(unknown))

对此的任何建议将不胜感激。目的是通过python连接到XMPP服务器并加入MUC。

【问题讨论】:

  • 您使用的是哪个 xmpp Python 包?
  • 您可以将日志级别更改为调试韵律并尝试连接,然后在此处发布日志吗?

标签: python xmpp


【解决方案1】:

当我没有在服务器端提供证书链时,我在 Pidgin (libpurple 2.10.11) 中遇到了这个错误。

我通过在服务器上的证书末尾添加 CA 捆绑包(即 中间证书)解决了这个问题:

cat /path/to/ica.crt >> /path/to/prosody.crt

另请参阅https://prosody.im/doc/certificates#certificate_chains 了解更多信息

【讨论】:

    【解决方案2】:

    我看到您使用的是 Python 2.7,请确保您已更新到最新版本 (2.7.11),因为最近有一些 SSL 更改可能会破坏大量代码。

    【讨论】:

      猜你喜欢
      • 2018-10-14
      • 2018-07-28
      • 2015-03-16
      • 2021-12-28
      • 2018-10-17
      • 2016-04-29
      • 2014-03-05
      • 1970-01-01
      相关资源
      最近更新 更多