mirror of
https://blitiri.com.ar/repos/chasquid
synced 2025-12-17 14:37:02 +00:00
smtpsrv: Check TLS Handshake result
When receiving a message on a TLS socket, we currently don't check the Handshake result, so connections often fail in a way that is not easy to troubleshoot. This patch fixes that by checking the result and emitting a nicer error message before closing the connection.
This commit is contained in:
@@ -174,7 +174,12 @@ func (c *Conn) Handle() {
|
|||||||
if tc, ok := c.conn.(*tls.Conn); ok {
|
if tc, ok := c.conn.(*tls.Conn); ok {
|
||||||
// For TLS connections, complete the handshake and get the state, so
|
// For TLS connections, complete the handshake and get the state, so
|
||||||
// it can be used when we say hello below.
|
// it can be used when we say hello below.
|
||||||
tc.Handshake()
|
err := tc.Handshake()
|
||||||
|
if err != nil {
|
||||||
|
c.tr.Errorf("error completing TLS handshake: %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
cstate := tc.ConnectionState()
|
cstate := tc.ConnectionState()
|
||||||
c.tlsConnState = &cstate
|
c.tlsConnState = &cstate
|
||||||
if name := c.tlsConnState.ServerName; name != "" {
|
if name := c.tlsConnState.ServerName; name != "" {
|
||||||
|
|||||||
Reference in New Issue
Block a user