cosullivan / SmtpServer

A SMTP Server component written in C#
MIT License
690 stars 163 forks source link

SecureServerExample blocked by telnet #175

Closed mrFred489 closed 1 year ago

mrFred489 commented 2 years ago

I have a problem where the server stops receiving emails if a telnet connection is open. The telnet connection is stuck in AuthenticateAsServerAsync within SecurableDuplexPipe. I can reproduce this issue by using the SecureServerExample from the repo. If this can either be fixed, or you have a workaround allowing me to block/reject the telnet connects, I would be happy.

I test it by:

  1. Running the server.
  2. Starting a jmeter script that continuously sends emails.
  3. Starting telnet - Observe that the jmeter script stops sending emails.
  4. Stop telnet - Observe that jmeter starts sending emails again.
karol-gro commented 2 years ago

Looking at the code it seams that the server performs SSL upgrade syncronously (i.e. it'll start listening to next connection, when previous is authenticated with SSL). I can see 3 possible ways, you could try to fix it:

  1. disable SSL (only, if you're sure it's safe - closed network, vpn etc.)
  2. Decrease read timeout - by default it's 2 minutes, you probably can have it safely much lower
  3. Fix code, so that this line is called in background: https://github.com/cosullivan/SmtpServer/blob/master/Src/SmtpServer/SmtpServer.cs#L160

BTW, @cosullivan - what's the status of this project? Is it still supported?

cosullivan commented 2 years ago

Hi @karol-gro yes it is still supported, but only when time permits.

I will have a look at this in the next few days.

mrFred489 commented 2 years ago

Hi @cosullivan What is the status on this? Do you expect to get the time to look into it?

cosullivan commented 2 years ago

Hi @mrFred489 ,

I've uploaded 9.0.2-beta1 which should solve this. If you are able to test to confirm that would be good.

mrFred489 commented 2 years ago

Hi @cosullivan

It seems to be working. It looks like you took the suggestion from @karol-gro, so the server can handle messages while attempting to secure another connection.

Thank you for fixing this!