Skip to content

Commit 7c0accb

Browse files
committed
tls: permit null as a pfx value
Allow null along with undefined for pfx value. This is to avoid breaking change when upgrading v14 to v16 and 3rd party library passing null to pfx Fixes: #36292
1 parent 85d4cd3 commit 7c0accb

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

lib/internal/tls/secure-context.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ function configSecureContext(context, options = {}, name = 'options') {
261261
context.setSessionIdContext(sessionIdContext);
262262
}
263263

264-
if (pfx !== undefined) {
264+
if (pfx != null) {
265265
if (ArrayIsArray(pfx)) {
266266
ArrayPrototypeForEach(pfx, (val) => {
267267
const raw = val.buf ? val.buf : val;

test/parallel/test-tls-connect-secure-context.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,20 @@ connect({
2323
assert.ifError(err);
2424
return cleanup();
2525
});
26+
27+
connect({
28+
client: {
29+
servername: 'agent1',
30+
secureContext: tls.createSecureContext({
31+
ca: keys.agent1.ca,
32+
pfx: null,
33+
}),
34+
},
35+
server: {
36+
cert: keys.agent1.cert,
37+
key: keys.agent1.key,
38+
},
39+
}, function(err, pair, cleanup) {
40+
assert.ifError(err);
41+
return cleanup();
42+
});

0 commit comments

Comments
 (0)