SmtpServer icon indicating copy to clipboard operation
SmtpServer copied to clipboard

Server going down on SSL errors: Wider exception catching in ListenAsync

Open nopap opened this issue 4 years ago • 3 comments

Hi, With IsSecure enabled, if a client sends crap to the server it simply goes down with Exception 'The handshake failed due to an unexpected packet format.' In ListenAsync only the OperationCanceledException is currently catched, i propose to catch a wider range to prevent the server from going completely down on errors. I'm running right now with all exceptions catched, but maybe a subset only would be necessary.

What do you think ?

nopap avatar Nov 17 '20 08:11 nopap

Hi,

When you say that the client sends crap, are you saying that the client doesn't complete the SSL handshake but starts sending commands instead?

cosullivan avatar Nov 18 '20 13:11 cosullivan

Hi, yes whe the client send something/anything which is not the expected TLS handshake. For example a simple curl to the server will put it down due to invalid handshake.

nopap avatar Nov 18 '20 13:11 nopap

Hi @nopap ,

I've just pushed a fix for this so it now also catches the IOException that can be thrown here and then also ensures that the original Pipe is disposed.

Thanks, Cain.

cosullivan avatar Nov 20 '20 08:11 cosullivan