Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions client/pkg/transport/listener_tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ import (
"os"
"strings"
"sync"
"time"
)

const (
// tlsHandshakeTimeout bounds how long a single TLS handshake may block.
tlsHandshakeTimeout = 10 * time.Second
)

// tlsListener overrides a TLS listener so it will reject client
Expand Down Expand Up @@ -143,6 +149,7 @@ func (l *tlsListener) acceptLoop() {
}()

tlsConn := conn.(*tls.Conn)
_ = tlsConn.SetDeadline(time.Now().Add(tlsHandshakeTimeout))
herr := tlsConn.Handshake()
pendingMu.Lock()
delete(pending, conn)
Expand All @@ -152,6 +159,7 @@ func (l *tlsListener) acceptLoop() {
l.handshakeFailure(tlsConn, herr)
return
}
_ = tlsConn.SetDeadline(time.Time{})

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
_ = tlsConn.SetDeadline(time.Time{})
if err := tlsConn.SetDeadline(time.Time{}); err != nil {
l.handshakeFailure(tlsConn, err)
return
}

we can fast-fail here

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I intentionally ignore the err, to avoid breaking any existing behaviour. Even SetDeadline fails, we still continue to execute the check

if err := l.check(ctx, tlsConn); err != nil {
l.handshakeFailure(tlsConn, err)
return
Expand Down