In Tls_lwt dont throw EPIPE error if we got close_notify#371
Conversation
According to SSL_shutdown(3): "The shutdown procedure consists of 2 steps: the sending of the “close notify” shutdown alert and the reception of the peer's “close notify” shutdown alert. According to the TLS standard, it is acceptable for an application to only send its shutdown alert and then close the underlying connection without waiting for the peer's response"
|
this seems to me to handle more Isn't a viable solution to add |
|
The test code already sets sigpipe to ignore https://github.com/mirage/ocaml-conduit/blob/b74dbbda7cbcce1b3d398d7499efd99eec7c62b4/tests/unix/cdtest_tls.ml#L62, however that only means that instead of raising a signal you get The original problem in the referenced bug was that when that exception is raised we actually loose the last message sent by the other side; I haven't checked exactly what happens but my guess is you get a short read and then if the code insists reading again it gets an EPIPE. We should first return whatever the last message was, process it through the TLS state machine, and raise the exception only if we get EPIPE and we haven't reached EOF yet. |
|
@edwintorok thanks for explanation. from what I read in the spec, if you find the time to test this PR, I'd be very interested whether it fixes the issue for you. please report back. |
|
I'm also seeing reproducible |
|
I just opened #387 with an alternative to this PR that I think is less invasive and actually fixes the symptom in my application. |
|
thanks, tls 0.9.3 is released (PRed to opam-repository ocaml/opam-repository#13231) which fixes this issue |
I don't really have any understanding of this lib, but i think this would fix #347.