Skip to content

https: key agent on empty servername and ecdhCurve - #67935

Open
ShogunPanda wants to merge 1 commit into
nodejs:mainfrom
ShogunPanda:https-agent-empty-option-keys
Open

ShogunPanda wants to merge 1 commit into
nodejs:mainfrom
ShogunPanda:https-agent-empty-option-keys

Conversation

@ShogunPanda

Copy link
Copy Markdown
Contributor

https.Agent.prototype.getName() only appended servername and ecdhCurve to the agent name when they were truthy. An explicitly empty value (servername: '' or ecdhCurve: '') therefore produced the same name as the option being absent, and since sockets and the TLS session cache are keyed by that name, they were shared between the two configurations.

This change encodes an empty string for these two options with the existing TLS option key encoding, so they get distinct names. Names for absent options, other values, and a servername equal to host are unchanged.

An empty ecdhCurve is not a valid curve: with this change such a request no longer silently reuses a socket created for the default configuration, and fails consistently when its TLS context is created instead.

test/parallel/test-https-agent-getname.js is extended with the new cases.

Release notes

https.Agent no longer shares sockets and TLS sessions between requests that pass an explicitly empty servername or ecdhCurve and requests that omit the option.

Agent.prototype.getName() only appended servername and ecdhCurve when
they were truthy, so an explicitly empty value produced the same agent
name as an absent option. Sockets and TLS sessions are keyed by that
name, so they were shared between the two configurations.

Encode an empty string for these options with the existing TLS option
key encoding. Names for absent options, other values and a servername
equal to host are unchanged.

Signed-off-by: Paolo Insogna <paolo@cowtech.it>
Assisted-By: OpenAI:GPT-6-Sol <openai/gpt-6-sol>
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/crypto
  • @nodejs/http
  • @nodejs/net

@nodejs-github-bot nodejs-github-bot added https Issues and PRs related to the https subsystem. needs-ci PRs that need a full CI run. labels Dec 1, 2026
@codecov

codecov Bot commented Dec 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.59%. Comparing base (f2d9356) to head (84f6d77).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #67935      +/-   ##
==========================================
- Coverage   92.96%   90.59%   -2.37%     
==========================================
  Files         432      802     +370     
  Lines      201044   286657   +85613     
  Branches    30702    55367   +24665     
==========================================
+ Hits       186900   259700   +72800     
- Misses      13816    17071    +3255     
- Partials      328     9886    +9558     
Files with missing lines Coverage Δ
lib/https.js 97.26% <100.00%> (+0.12%) ⬆️

... and 504 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Labels

https Issues and PRs related to the https subsystem. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants