Skip to content

Respect context when connecting and close each connection - #59

Open
misiektoja wants to merge 2 commits into
globalsign:masterfrom
misiektoja:fix/client-connection
Open

misiektoja wants to merge 2 commits into
globalsign:masterfrom
misiektoja:fix/client-connection

Conversation

@misiektoja

Copy link
Copy Markdown

Hi,

We use an internal fork of this library (disclosure: I work at Nokia). Over the past few months, we've found and fixed several issues. I'm submitting those fixes as separate PRs to bring them upstream and reduce the differences between our fork and this repository.

This PR: connection setup uses tls.Dial before the HTTP request context takes effect. A stalled TLS handshake can therefore block past the deadline. Connections also remain open after operations return.

Use tls.Dialer.DialContext and close each connection when its operation returns, including errors before sending the request. This makes estclient -timeout cover connection setup.

Tests cover stalled handshakes and connection cleanup.

@toddgaunt-gs

Copy link
Copy Markdown
Collaborator

Thank you so much for making your internal fixes available for us @misiektoja! I will review your PRs in the days to come this week when I can, and have asked anyone on my team available to review as well.

@toddgaunt-gs

Copy link
Copy Markdown
Collaborator

Sorry it's taken longer than I initially hoped to get to these. Reviewing now.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused changes consistently propagate context and handle connection ownership across all affected operations, with no blocking issues identified.

No open issues 🎉

What changed in this PR

This PR makes EST client operations respect context cancellation during connection setup and close their TLS connections when they return, extending timeout coverage to stalled TLS handshakes.

Changes:

  • Use tls.Dialer.DialContext with the operation context.
  • Defer connection cleanup in every affected operation while preserving enrollment’s TLS-unique handling.
  • Add tests for stalled-handshake deadlines and connection cleanup.
File Description
est_test.go Adds deadline and connection-cleanup regression tests.
client.go Propagates context into TLS dialing and closes connections after operations.

Review effort: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants