Skip to content

Use HandshakeContext when possible #409

@benpbrown

Description

@benpbrown

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:

if err := tlsConn.Handshake(); err != nil {

Metadata

Metadata

Assignees

Labels

priority: p0Highest priority. Critical issue. P0 implies highest priority.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions