mirror of
https://blitiri.com.ar/repos/chasquid
synced 2025-12-17 14:37:02 +00:00
smtpsrv: Get TLS information for direct connections
For direct TLS connections, such as submission-over-TLS, we currently don't get the TLS information so it appears in the headers as "plain text", which is misleading. This patch fixes the problem by getting the connection information early. Note it explicitly triggers the handshake, which would otherwise happen transparently on the first read/write, so we can use the hostname (if any) in our hello message.
This commit is contained in:
@@ -158,6 +158,17 @@ func (c *Conn) Handle() {
|
|||||||
defer c.tr.Finish()
|
defer c.tr.Finish()
|
||||||
c.tr.Debugf("Connected, mode: %s", c.mode)
|
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)
|
c.tc.PrintfLine("220 %s ESMTP chasquid", c.hostname)
|
||||||
|
|
||||||
var cmd, params string
|
var cmd, params string
|
||||||
|
|||||||
Reference in New Issue
Block a user