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: the whole http body is read, but an Unexpected EOF is return at the same time #49422

Open
Jarvis-Zhou opened this issue Nov 7, 2021 · 11 comments
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@Jarvis-Zhou
Copy link

What version of Go are you using (go version)?

$ go version
go1.16.6 linux/amd64

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

amd64 ubuntu

What did you do?

I just send a http request and use ioutil.ReadAll to read body, all the body is read, but I got an unexpected error at the same time.

May my env is special, I use tcpdump and wareshark the trace the connection, I found that the last packet from server end with part of Alert meg 0x15 0x03 0x03, and later the server send a RST packet.

After reading golang code, I find out that after the whole body is read, we will check the alert packet. But as the alert packet is not full, will return the Unexpected EOF.

https://github.com/golang/go/blame/9e6ad46bccfa7a63e768236bcd1fd54dab38e4d1/src/crypto/tls/conn.go#L1305

What did you expect to see?

I think We should add a check here, this error show in resp.Body.Close or next read.

What did you see instead?

@Jarvis-Zhou
Copy link
Author

CC @FiloSottile @bradfitz

@Jarvis-Zhou Jarvis-Zhou changed the title the whole http body is read, but an Unexpected EOF is return at the same time crypto/tls: the whole http body is read, but an Unexpected EOF is return at the same time Nov 8, 2021
@cagedmantis cagedmantis added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Nov 8, 2021
@cagedmantis
Copy link
Contributor

Could you provide an example of the code that produced the error, preferably as a Go playground link?

@Jarvis-Zhou
Copy link
Author

https://play.golang.org/p/hCyV1oEl4YC , my code is just like this, very normal. But in my environment, I got an Unexpected EOF with the whole body. Then I add log print in tls/conn, I found that it will return Unexpected EOF when TLS Alert packet is not right.

@Jarvis-Zhou
Copy link
Author

I also write my code using python or just using curl, it is ok. because they are not deal with the alert packet in body reading.

@Jarvis-Zhou
Copy link
Author

image

@Jarvis-Zhou
Copy link
Author

@cagedmantis

@cagedmantis cagedmantis added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. and removed WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels Nov 16, 2021
@cagedmantis cagedmantis added this to the Backlog milestone Nov 16, 2021
@cagedmantis
Copy link
Contributor

@Jarvis-Zhou Thank you for the updated information.

@bradfitz
Copy link
Contributor

Which web server is replying with this broken TLS interrupting its response?

@Jarvis-Zhou
Copy link
Author

It is a http server in my local environment. And I am keeping on finding out the problem why it is interrupted.

@Jarvis-Zhou
Copy link
Author

But other language does not return this error

@gzhh
Copy link

gzhh commented Feb 7, 2023

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

4 participants