xmppo / Jabber-Net

A modern fork of Jabber-Net
https://github.com/xmppo/Jabber-Net
37 stars 13 forks source link

Handle exception on socket connection #93

Closed dsparkplug closed 6 years ago

dsparkplug commented 6 years ago

The SslStream.RemoteCertificate property accessed by SocketStanzaStream.OnConnect can throw exceptions e.g. handshake failed due to unexpected exception.

As ExecuteConnect is run async, this can cause the Jabber client to crash.

I've added a simple try ... catch to handle such errors.

ForNeVeR commented 6 years ago

Hello and thank you for your contribution!

I've changed your design a bit: now it's storing an initial exception in the InnerException property.

Also I've added a unit test that will check for the desired behavior.