fix(tunnel): read the served TLS leaf after the handshake #8
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/tls-certificate-kind-race"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
tls.NewListener hands back a *tls.Conn before any handshake has run, so the handshake happens on whichever goroutine reads the conn first. In Serve that goroutine is yamux's recvLoop, which meant selectCert's SetCertificateKind raced with Serve's own TLSServedKind read a line later, tripping the race detector in TestEndToEnd.
Make certificateKindConn.kind atomic, and read the served kind after the hello has arrived. The read was not just racy but nearly always empty there: the handshake had not run yet, so tlsKind silently fell back to whatever the node reported.