Close TLS connection if handshake timeout
Oleglacto opened this issue · 4 comments
Oleglacto commented
If TLS enabled and we got tlsHandshakeTimeoutError, we will not close TLS connection here
I suggest next improvements:
innerCtx, cancel := context.WithCancel(ctx) // new
if d := do.tlsHandshakeTimeout; d != 0 {
timer := time.AfterFunc(d, func() {
cancel()
errc <- tlsHandshakeTimeoutError{}
})
defer timer.Stop()
}
go func() {
errc <- tlsConn.HandshakeContext(innerCtx) // new
}()
If we got timeout, TLS package close connection by cancel ctx here.
I think it's easiest solution of connection leak
stevenh commented
Looks reasonable @Oleglacto happy to take a PR.
Oleglacto commented
How to make pr? I can't push into rep
stevenh commented
You create a fork, push to your fork on a new branch e.g. fix/tls-close
then raise a PR from that.
Oleglacto commented
Sorry, i made deep research for this issue, and it's works fine.