[GODRIVER-2285] Use HandshakeContext for TLS handshakes when using Go 1.17+ Created: 27/Jan/22  Updated: 10/Feb/22  Resolved: 10/Feb/22

Status: Closed
Project: Go Driver
Component/s: None
Affects Version/s: None
Fix Version/s: 1.9.0

Type: Improvement Priority: Major - P3
Reporter: Divjot Arora (Inactive) Assignee: Benji Rewis (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Documentation Changes: Not Needed

 Description   

For connections that require TLS, the driver asynchronously performs the TLS handshake in a goroutine here. The main goroutine waits for either the handshake to complete or the context to expire. In the latter case, the driver just stops waiting for the goroutine here and returns "ctx.Err()".

This is undesirable because it assumes that Handshake() will eventually return, which could be considered a goroutine leak. It also results in an error like "context deadline exceeded" being propagated to the application with no other information. We should consider using the new "tls.Conn#HandshakeContext" function when the application is using Go 1.17+.



 Comments   
Comment by Githook User [ 10/Feb/22 ]

Author:

{'name': 'Benjamin Rewis', 'email': '32186188+benjirewis@users.noreply.github.com', 'username': 'benjirewis'}

Message: GODRIVER-2285 Use HandshakeContext for TLS handshakes when using Go 1.17+ (#846)
Branch: master
https://github.com/mongodb/mongo-go-driver/commit/dc14b6c2ff1a72c43ee74692fb1c7e54ea21aeac

Comment by Benji Rewis (Inactive) [ 02/Feb/22 ]

PR: https://github.com/mongodb/mongo-go-driver/pull/846

Generated at Thu Feb 08 08:38:14 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.