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

crypto/tls: tls.Conn.Close sends unnecessary close_notify if the underlying connection was already closed #45709

Open
ameshkov opened this issue Apr 22, 2021 · 2 comments
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@ameshkov
Copy link

Consider the following code:

	conn, _ := tls.Dial("tcp", "8.8.8.8:443", &tls.Config{ServerName: "dns.google"})
	_, _ = conn.Write([]byte("GET / HTTP/1.1\r\nHost: dns.google\r\nConnection: close\r\n\r\n"))
	_, _ = ioutil.ReadAll(conn)
	_ = conn.Close()

The problem with the way tls.Conn works in the current Golang version is that this code will guarantee that the underlying connection won't be closed gracefully and every time it'll cause RST packets sent from the remote endpoint.

image

Is it feasible to extend tls.Conn to take the underlying connection status into account? For instance, look for io.EOF when it reads from it?

@cherrymui cherrymui added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Apr 26, 2021
@cherrymui cherrymui added this to the Backlog milestone Apr 26, 2021
@cherrymui
Copy link
Member

cc @FiloSottile

@networkimprov
Copy link

cc @bradfitz @ianlancetaylor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants