author | Alberto Bertogli
<albertito@blitiri.com.ar> 2017-09-10 10:20:57 UTC |
committer | Alberto Bertogli
<albertito@blitiri.com.ar> 2017-09-10 10:20:57 UTC |
parent | 0972964722c3d525e116609f32fdaded4a9f41b5 |
internal/smtpsrv/conn.go | +11 | -0 |
diff --git a/internal/smtpsrv/conn.go b/internal/smtpsrv/conn.go index c347cea..864e56b 100644 --- a/internal/smtpsrv/conn.go +++ b/internal/smtpsrv/conn.go @@ -158,6 +158,17 @@ func (c *Conn) Handle() { defer c.tr.Finish() c.tr.Debugf("Connected, mode: %s", c.mode) + if tc, ok := c.conn.(*tls.Conn); ok { + // For TLS connections, complete the handshake and get the state, so + // it can be used when we say hello below. + tc.Handshake() + cstate := tc.ConnectionState() + c.tlsConnState = &cstate + if name := c.tlsConnState.ServerName; name != "" { + c.hostname = name + } + } + c.tc.PrintfLine("220 %s ESMTP chasquid", c.hostname) var cmd, params string