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: nodejs#36292
  • Loading branch information
CallMeLaNN committed Dec 15, 2021
1 parent 6267e55 commit 8fd11f9
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
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
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 8fd11f9

Please sign in to comment.