gessnerfl / fake-smtp-server

A simple SMTP Server for Testing purposes. Emails are stored in an in-memory database and rendered in a Web UI
Apache License 2.0
414 stars 86 forks source link

STARTTLS closes the SSLSocket after creation #373

Closed danielabeledo closed 6 months ago

danielabeledo commented 6 months ago

Hi, it seems you are wrapping the creation of the SSLSocket with a try-with-resources.

https://github.com/gessnerfl/fake-smtp-server/blob/main/src/main/java/de/gessnerfl/fakesmtp/smtp/command/StartTLSCommand.java#L42

SSLSocketImpl implements Autocloseable so the TLS socket closes before the STARTTLS command finishes

How to reproduce Java version 21

Running application with self-signed certificate

openssl s_client -starttls smtp -connect <HOST:PORT> -crlf -CAfile certificate.pem

Remediation

Running the application without wrapping the socket creation with try-with-resources solves the issue

gessnerfl commented 6 months ago

@danielabeledo you are right. Issue is fixed with version 2.2.0

gessnerfl commented 6 months ago

Can you please cross check and reopen if the issue persists

danielabeledo commented 6 months ago

Yeah, looks fine to me now - thanks for the quick turnaround