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: Dial returns io.EOF #19874

Open
joneskoo opened this issue Apr 7, 2017 · 7 comments
Open

crypto/tls: Dial returns io.EOF #19874

joneskoo opened this issue Apr 7, 2017 · 7 comments
Labels
NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made.
Milestone

Comments

@joneskoo
Copy link
Contributor

joneskoo commented Apr 7, 2017

If the server closes the connection before handshake completes, net/tls returns a non-descriptive error "EOF".

https://play.golang.org/p/zI-MazOG7v

Also locally go version go1.8 darwin/amd64

This may be same as #13523 (comment) @rsc @bradfitz .

What did you expect to see?

A more descriptive error similar to other errors from net/tls.

  • dial tcp 127.0.0.1:8081: getsockopt: connection refused
  • x509: cannot validate certificate for 216.58.209.132 because it doesn't contain any IP SANs

What did you see instead?

_, err := tls.Dial("tcp", "127.0.0.1:8080", nil)
if err != nil {
	fmt.Println(err)
	fmt.Printf("%#v == io.EOF: %v", err, err == io.EOF)
}

Output:

EOF
&errors.errorString{s:"EOF"} == io.EOF: true

Of course there is nothing that can be done, the closing of underlying connection is fatal, but is it possible to improve the error?

@bradfitz bradfitz changed the title net/tls: Error "EOF" from tls.Dial crypto/tls: Dial returns io.EOF Apr 7, 2017
@bradfitz bradfitz added this to the Go1.9Maybe milestone Apr 7, 2017
@bradfitz bradfitz added the NeedsFix The path to resolution is known, but the work has not been done. label Apr 7, 2017
@bradfitz
Copy link
Contributor

bradfitz commented Apr 7, 2017

Yes,Dial could probably return map io.EOF to something else if Handshake returns io.EOF. I wouldn't change Handshake's behavior, though.

@gopherbot
Copy link

CL https://golang.org/cl/40190 mentions this issue.

@gopherbot
Copy link

Change https://golang.org/cl/86715 mentions this issue: crypto/tls: make DialWithDialer return more descriptive error

@namusyaka namusyaka added the NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. label Feb 24, 2018
@gopherbot gopherbot removed the NeedsFix The path to resolution is known, but the work has not been done. label Feb 24, 2018
@namusyaka
Copy link
Member

I'd like to hear @mikioh's opinion, so I've just this issue marked NeedDecision.
/cc @bradfitz

@gopherbot gopherbot modified the milestones: Go1.11, Unplanned May 23, 2018
@joneskoo
Copy link
Contributor Author

joneskoo commented Dec 8, 2019

Hi, after 11 excellent patch sets by Kunpei Sakai (THANKS!) @mikioh commented about the concern for error type and TLS 1.3 but did not respond to clarifying question and nobody else jumped in to say if the error type is a problem or not so now the CL timed out. I’m sorry I didn’t ping this earlier. (@bradfitz There should also be a bot commenting on Github about CL being abandoned, earlier than 1 year maybe?)

Well TLS 1.3 is out. I see this EOF has confused others too based on linked issues, not just me, so unless there is a proposal for a different approach to fix the same can we resurrect this, please? Someone needs to say how to resolve the error type question.

@joneskoo
Copy link
Contributor Author

@FiloSottile ping?

@gopherbot
Copy link

Change https://golang.org/cl/299449 mentions this issue: crypto/tls: add error context to handshake error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made.
Projects
None yet
Development

No branches or pull requests

5 participants