Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close TLS connection if handshake timeout #671

Open
Oleglacto opened this issue Jul 17, 2024 · 3 comments
Open

Close TLS connection if handshake timeout #671

Oleglacto opened this issue Jul 17, 2024 · 3 comments

Comments

@Oleglacto
Copy link

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
Copy link
Collaborator

stevenh commented Jul 17, 2024

Looks reasonable @Oleglacto happy to take a PR.

@Oleglacto
Copy link
Author

How to make pr? I can't push into rep

@stevenh
Copy link
Collaborator

stevenh commented Jul 17, 2024

You create a fork, push to your fork on a new branch e.g. fix/tls-close then raise a PR from that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants