Use HandshakeContext when possible
benpbrown opened this issue · 1 comments
Feature Description
When performing an explicit TLS handshake, use the HandshakeContext method introduced in Go 1.17 instead of Handshake. The difference is that HandshakeContext
will respect context deadlines or cancelation.
In a previous iteration of this connector (cloud-sql-proxy), we an issue where Handshake could hang for minutes (like five minutes): GoogleCloudPlatform/cloud-sql-proxy#986.
Alternatives Considered
I am not able to come up with a workaround as the standard library method Handshake
is not cancelable (so the goroutine is hung no matter what we do).
Additional Context
Equivalent fix in cloud-sql-proxy: GoogleCloudPlatform/cloud-sql-proxy#987
Handshake line in this repo:
cloud-sql-go-connector/dialer.go
Line 231 in 2a88f23
Sorry for missing this @benpbrown. I can port the same fix to the connector here.