1
0
mirror of https://github.com/jhillyerd/inbucket.git synced 2025-12-17 17:47:03 +00:00

pop3 TLS: don't do server-side handshake explicitly... (#386)

This commit is contained in:
Benson Margulies
2023-09-07 09:56:19 -07:00
committed by GitHub
parent 9f0fef3180
commit 00736cc704

View File

@@ -2,7 +2,6 @@ package pop3
import (
"bufio"
"context"
"crypto/tls"
"fmt"
"io"
@@ -110,14 +109,6 @@ func (s *Server) startSession(id int, conn net.Conn) {
if s.config.ForceTLS {
logger.Debug().Msg("Setting up TLS for ForceTLS")
tlsConn := tls.Server(conn, s.tlsConfig)
toCtx, toCtxCancel := context.WithTimeout(context.Background(), 5*time.Second)
defer toCtxCancel()
if err := tlsConn.HandshakeContext(toCtx); err != nil {
logger.Error().Msgf("TLS handshake failed: %v.", err)
conn.Close()
s.wg.Done()
return
}
s.tlsState = new(tls.ConnectionState)
*s.tlsState = tlsConn.ConnectionState()
conn = tlsConn