Skip to content

crypto/tls: handshake hangs when running over synchronous/unbuffered connection #24198

Description

@runeaune

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeWaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions