Ensure that the TLS handshake has been done before using tls.ConnectionState()

otherwise handshake is performed on first read/write and peer.TLS is invalid.
This commit is contained in:
Bernhard Froehlich 2018-12-14 11:04:35 +00:00
parent 0857b2e4ed
commit 9fccea2351
No known key found for this signature in database
GPG key ID: 4DD88C3F9F3B8333

View file

@ -119,6 +119,9 @@ func (srv *Server) newSession(c net.Conn) (s *session) {
tlsConn, s.tls = c.(*tls.Conn)
if s.tls {
// run handshake otherwise it's done when we first
// read/write and connection state will be invalid
tlsConn.Handshake()
state := tlsConn.ConnectionState()
s.peer.TLS = &state
}