https: encode all TLS fields in agent names

`https.Agent#getName()` joined several TLS options with `:` without
encoding them, so a value containing `:` could shift into the next field
and produce the same name as a different set of options. A `DataView`
passed as `dhparam` was also reduced to its type name.

Encode the remaining string, boolean, number, buffer and array valued
options, including `sigalgs`, with `getTlsOptionKey()`, which prefixes
the type and the length, like the options that were already encoded.

Assisted-By: OpenAI GPT-5.6 Sol <openai/gpt-5.6-sol>
Signed-off-by: Paolo Insogna <paolo@cowtech.it>
PR-URL: https://github.com/nodejs/node/pull/67641
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Paolo Insogna authored and Antoine du Hamel committed 2026-11-23 12:34:28 +01:00
1 parent 7363c8efe1
commit 930a71cb55
3 files changed
+69 -30

No files matched your search

+12 -13
View File
@@ -30,7 +30,6 @@ const {
ArrayPrototypeSplice,
ArrayPrototypeUnshift,
FunctionPrototypeCall,
JSONStringify,
NumberParseInt,
ObjectAssign,
ObjectSetPrototypeOf,
@@ -606,7 +605,7 @@ Agent.prototype.getName = function getName(options = kEmptyObject) {
name += ':';
if (options.ciphers)
name += options.ciphers;
name += getTlsOptionKey(options.ciphers);
name += ':';
if (options.key) {
@@ -622,23 +621,23 @@ Agent.prototype.getName = function getName(options = kEmptyObject) {
name += ':';
if (options.rejectUnauthorized !== undefined)
name += options.rejectUnauthorized;
name += getTlsOptionKey(options.rejectUnauthorized);
name += ':';
if (options.servername && options.servername !== options.host)
name += options.servername;
name += getTlsOptionKey(options.servername);
name += ':';
if (options.minVersion)
name += options.minVersion;
name += getTlsOptionKey(options.minVersion);
name += ':';
if (options.maxVersion)
name += options.maxVersion;
name += getTlsOptionKey(options.maxVersion);
name += ':';
if (options.secureProtocol)
name += options.secureProtocol;
name += getTlsOptionKey(options.secureProtocol);
name += ':';
if (options.crl)
@@ -646,27 +645,27 @@ Agent.prototype.getName = function getName(options = kEmptyObject) {
name += ':';
if (options.honorCipherOrder !== undefined)
name += options.honorCipherOrder;
name += getTlsOptionKey(options.honorCipherOrder);
name += ':';
if (options.ecdhCurve)
name += options.ecdhCurve;
name += getTlsOptionKey(options.ecdhCurve);
name += ':';
if (options.dhparam)
name += options.dhparam;
name += getTlsOptionKey(options.dhparam);
name += ':';
if (options.secureOptions !== undefined)
name += options.secureOptions;
name += getTlsOptionKey(options.secureOptions);
name += ':';
if (options.sessionIdContext)
name += options.sessionIdContext;
name += getTlsOptionKey(options.sessionIdContext);
name += ':';
if (options.sigalgs)
name += JSONStringify(options.sigalgs);
name += getTlsOptionKey(options.sigalgs);
name += ':';
if (options.secureContext)