Skip to content

Commit 08ed233

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 3701e5d commit 08ed233

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
@@ -1320,6 +1320,9 @@ Server.prototype.setSecureContext = function(options) {
13201320
if (options.ticketKeys)
13211321
this.ticketKeys = options.ticketKeys;
13221322

1323+
this.privateKeyIdentifier = options.privateKeyIdentifier;
1324+
this.privateKeyEngine = options.privateKeyEngine;
1325+
13231326
this._sharedCreds = tls.createSecureContext({
13241327
pfx: this.pfx,
13251328
key: this.key,
@@ -1339,7 +1342,9 @@ Server.prototype.setSecureContext = function(options) {
13391342
crl: this.crl,
13401343
sessionIdContext: this.sessionIdContext,
13411344
ticketKeys: this.ticketKeys,
1342-
sessionTimeout: this.sessionTimeout
1345+
sessionTimeout: this.sessionTimeout,
1346+
privateKeyIdentifier: this.privateKeyIdentifier,
1347+
privateKeyEngine: this.privateKeyEngine,
13431348
});
13441349
};
13451350

@@ -1405,6 +1410,11 @@ Server.prototype.setOptions = deprecate(function(options) {
14051410
}
14061411
if (options.pskCallback) this[kPskCallback] = options.pskCallback;
14071412
if (options.pskIdentityHint) this[kPskIdentityHint] = options.pskIdentityHint;
1413+
if (options.sigalgs) this.sigalgs = options.sigalgs;
1414+
if (options.privateKeyIdentifier !== undefined)
1415+
this.privateKeyIdentifier = options.privateKeyIdentifier;
1416+
if (options.privateKeyEngine !== undefined)
1417+
this.privateKeyEngine = options.privateKeyEngine;
14081418
}, 'Server.prototype.setOptions() is deprecated', 'DEP0122');
14091419

14101420
// 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)