fritzy / SleekXMPP

Python 2.6+/3.1+ XMPP Library
http://groups.google.com/group/sleekxmpp-discussion
Other
1.1k stars 299 forks source link

unable to have ssl_invalid_cert event handler called #469

Open cyberswordman opened 7 years ago

cyberswordman commented 7 years ago

SleekXMPP version: 1.3.3 python 2.7.13 (really winpython 2.7.13)

I'm trying to work with the send_client example. Trying to connect with a public jabber server (007jabber.com), which uses connection encryption. I get reports from normal jabber clients that the certificate for the server is bad, but I can still connect to it with them (pidgin and Gajim). When connecting to it using SleekXMPP, the connection is refused:

SendMsgBot init start DEBUG Loaded Plugin: RFC 6120: Stream Feature: STARTTLS DEBUG Loaded Plugin: RFC 6120: Stream Feature: Resource Binding DEBUG Loaded Plugin: RFC 3920: Stream Feature: Start Session DEBUG Loaded Plugin: RFC 6121: Stream Feature: Roster Versioning DEBUG Loaded Plugin: RFC 6121: Stream Feature: Subscription Pre-Approval DEBUG Loaded Plugin: RFC 6120: Stream Feature: SASL SendMsgBot init end DEBUG Loaded Plugin: XEP-0030: Service Discovery DEBUG Loaded Plugin: XEP-0199: XMPP Ping Connecting... DEBUG DNS: Querying 007jabber.com for AAAA records. DEBUG DNS: Error retreiving AAAA address info for 007jabber.com. DEBUG DNS: Querying 007jabber.com for A records. DEBUG Socket Wrapped for SSL DEBUG Connecting to 43.231.234.102:5222 ERROR CERT: Invalid certificate trust chain. Unable to connect. doTest end

I implemented the method to catch the event

#def discard(self, event):
def discard(self, event, cert, direct):
    print("Handling invalid certificate")
    return

(tried both the variants fo the definition)

and registered it into the init:

self.add_event_handler("ssl_invalid_cert", self.discard)

but no matter what, the event handler is never called (the appended log is taken in this condition)

ammgws commented 7 years ago

Have you tried attaching it to ssl_invalid_chain instead of ssl_invalid_cert?

Neustradamus commented 5 years ago

Have you tried with 1.3.2?

Neustradamus commented 5 years ago

@cyberswordman @ammgws: Any news?

Have you tested with "master"?

It works?