Skip to content

Commit 58319d5

Browse files
mildsunrisetargos
authored andcommitted
tls: forward new SecureContext options
We have a few places where we individually forward each parameter to tls.createSecureContext(). In #28973 and others, we added new SecureContext options but forgot to keep these places up to date. As per https.Agent#getName, I understand that at least `privateKeyIdentifier` and `privateKeyEngine` should be added too, since they're a substitute for `key`. I've also added sigalgs. Fixes: #36322 Refs: #28973 PR-URL: #36416 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent 30fe0ff commit 58319d5

File tree

3 files changed

+31
-4
lines changed

3 files changed

+31
-4
lines changed

lib/_tls_wrap.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -1330,6 +1330,9 @@ Server.prototype.setSecureContext = function(options) {
13301330
if (options.ticketKeys)
13311331
this.ticketKeys = options.ticketKeys;
13321332

1333+
this.privateKeyIdentifier = options.privateKeyIdentifier;
1334+
this.privateKeyEngine = options.privateKeyEngine;
1335+
13331336
this._sharedCreds = tls.createSecureContext({
13341337
pfx: this.pfx,
13351338
key: this.key,
@@ -1349,7 +1352,9 @@ Server.prototype.setSecureContext = function(options) {
13491352
crl: this.crl,
13501353
sessionIdContext: this.sessionIdContext,
13511354
ticketKeys: this.ticketKeys,
1352-
sessionTimeout: this.sessionTimeout
1355+
sessionTimeout: this.sessionTimeout,
1356+
privateKeyIdentifier: this.privateKeyIdentifier,
1357+
privateKeyEngine: this.privateKeyEngine,
13531358
});
13541359
};
13551360

@@ -1415,6 +1420,11 @@ Server.prototype.setOptions = deprecate(function(options) {
14151420
}
14161421
if (options.pskCallback) this[kPskCallback] = options.pskCallback;
14171422
if (options.pskIdentityHint) this[kPskIdentityHint] = options.pskIdentityHint;
1423+
if (options.sigalgs) this.sigalgs = options.sigalgs;
1424+
if (options.privateKeyIdentifier !== undefined)
1425+
this.privateKeyIdentifier = options.privateKeyIdentifier;
1426+
if (options.privateKeyEngine !== undefined)
1427+
this.privateKeyEngine = options.privateKeyEngine;
14181428
}, 'Server.prototype.setOptions() is deprecated', 'DEP0122');
14191429

14201430
// SNI Contexts High-Level API

lib/https.js

+13
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
const {
2525
ObjectAssign,
2626
ObjectSetPrototypeOf,
27+
JSONStringify,
2728
} = primordials;
2829

2930
require('internal/util').assertCrypto();
@@ -236,6 +237,18 @@ Agent.prototype.getName = function getName(options) {
236237
if (options.sessionIdContext)
237238
name += options.sessionIdContext;
238239

240+
name += ':';
241+
if (options.sigalgs)
242+
name += JSONStringify(options.sigalgs);
243+
244+
name += ':';
245+
if (options.privateKeyIdentifier)
246+
name += options.privateKeyIdentifier;
247+
248+
name += ':';
249+
if (options.privateKeyEngine)
250+
name += options.privateKeyEngine;
251+
239252
return name;
240253
};
241254

test/parallel/test-https-agent-getname.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const agent = new https.Agent();
1212
// empty options
1313
assert.strictEqual(
1414
agent.getName({}),
15-
'localhost:::::::::::::::::::'
15+
'localhost::::::::::::::::::::::'
1616
);
1717

1818
// Pass all options arguments
@@ -34,11 +34,15 @@ const options = {
3434
secureOptions: 0,
3535
secureProtocol: 'secureProtocol',
3636
servername: 'localhost',
37-
sessionIdContext: 'sessionIdContext'
37+
sessionIdContext: 'sessionIdContext',
38+
sigalgs: 'sigalgs',
39+
privateKeyIdentifier: 'privateKeyIdentifier',
40+
privateKeyEngine: 'privateKeyEngine',
3841
};
3942

4043
assert.strictEqual(
4144
agent.getName(options),
4245
'0.0.0.0:443:192.168.1.1:ca:cert:dynamic:ciphers:key:pfx:false:localhost:' +
43-
'::secureProtocol:c,r,l:false:ecdhCurve:dhparam:0:sessionIdContext'
46+
'::secureProtocol:c,r,l:false:ecdhCurve:dhparam:0:sessionIdContext:' +
47+
'"sigalgs":privateKeyIdentifier:privateKeyEngine'
4448
);

0 commit comments

Comments
 (0)