Skip to content

Commit

Permalink
tls: permit null as a pfx value
Browse files Browse the repository at this point in the history
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
  • Loading branch information
CallMeLaNN committed Dec 14, 2021
1 parent 85d4cd3 commit 7c0accb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/internal/tls/secure-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ function configSecureContext(context, options = {}, name = 'options') {
context.setSessionIdContext(sessionIdContext);
}

if (pfx !== undefined) {
if (pfx != null) {
if (ArrayIsArray(pfx)) {
ArrayPrototypeForEach(pfx, (val) => {
const raw = val.buf ? val.buf : val;
Expand Down
17 changes: 17 additions & 0 deletions test/parallel/test-tls-connect-secure-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,20 @@ connect({
assert.ifError(err);
return cleanup();
});

connect({
client: {
servername: 'agent1',
secureContext: tls.createSecureContext({
ca: keys.agent1.ca,
pfx: null,
}),
},
server: {
cert: keys.agent1.cert,
key: keys.agent1.key,
},
}, function(err, pair, cleanup) {
assert.ifError(err);
return cleanup();
});

0 comments on commit 7c0accb

Please sign in to comment.