2012-10-21 212 views
5

我很難與XMPP(Prosody)建立連接。但是,如果我使用PSI,它會正常工作,並請求您的建議。XMPP SSL握手失敗

這裏是我的Python代碼片段:

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)) 

在這個任何建議,將不勝感激。目標是連接到XMPP服務器並通過python加入MUC。

+1

哪個XMPP Python包你正在使用嗎? –

+1

您可以更改日誌級別以調試韻律並嘗試連接,並在此處發佈日誌? –

回答

0

正如我看到您使用的是Python 2.7,請確保您已更新到最新版本(2.7.11),因爲最近有一些SSL更改可能會破壞很多代碼。

0

當我沒有在服務器端提供證書鏈時,Pidgin(libpurple 2.10.11)中出現此錯誤。

我解決了這個通過在服務器上的證書的末尾添加CA-束(即中間證書):

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

另見https://prosody.im/doc/certificates#certificate_chains進一步信息