Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (go version)?
go1.9.4
Does this issue reproduce with the latest release?
Most likely
What operating system and processor architecture are you using (go env)?
darwin and amd64
What did you do?
I'm writing a test that relies on crypto/tls but mocks out the underlying net.Conn with https://github.com/jordwest/mock-conn/blob/master/end.go (this implements an unbuffered, local net.Conn based on two io.Pipes).
(I can help provide full example code if I get confirmation that fixing this issue is likely to be prioritized)
What did you expect to see?
I expected a completed handshake, and a useable TLS tunnel to be set up over the pipe. As far as I can tell, this can be achieved by never flushing multiple records together, or by reading responses in parallel with the flushing.
What did you see instead?
The TLS handshake hangs and eventually times out.
My limited digging points towards this flush as a likely culprit:
|
if _, err := c.flush(); err != nil { |
There seems to be multiple records being flushed together. The receiver wants to respond to the first one, but the sender needs to complete the flush before accepting any responses. Thus they are both blocked trying to write to the connection.
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version)?go1.9.4Does this issue reproduce with the latest release?
Most likely
What operating system and processor architecture are you using (
go env)?darwinandamd64What did you do?
I'm writing a test that relies on
crypto/tlsbut mocks out the underlyingnet.Connwith https://github.com/jordwest/mock-conn/blob/master/end.go (this implements an unbuffered, localnet.Connbased on twoio.Pipes).(I can help provide full example code if I get confirmation that fixing this issue is likely to be prioritized)
What did you expect to see?
I expected a completed handshake, and a useable TLS tunnel to be set up over the pipe. As far as I can tell, this can be achieved by never flushing multiple records together, or by reading responses in parallel with the flushing.
What did you see instead?
The TLS handshake hangs and eventually times out.
My limited digging points towards this
flushas a likely culprit:go/src/crypto/tls/handshake_server.go
Line 444 in 4c1aff8
There seems to be multiple records being flushed together. The receiver wants to respond to the first one, but the sender needs to complete the flush before accepting any responses. Thus they are both blocked trying to write to the connection.