-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tls: permit null as a pfx value #41170
tls: permit null as a pfx value #41170
Conversation
Review requested:
|
lib/internal/tls/secure-context.js
Outdated
@@ -261,7 +261,7 @@ function configSecureContext(context, options = {}, name = 'options') { | |||
context.setSessionIdContext(sessionIdContext); | |||
} | |||
|
|||
if (pfx !== undefined) { | |||
if (pfx != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would make it look like less of a mistake (using loose quality instead of strict equality) since strict equality is used more often than not:
if (pfx != null) { | |
if (pfx !== undefined && pfx !== null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer this pattern as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I quite like != null
pattern, especially since optional chaining and null coalescing are a thing 🤷♂️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. I prefer the same because strict equality more verbose. I was following the previous PR in the issue... So I'll include the strict for ciphers
option also.
Hold on, let me include |
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
Allow the expected null along with undefined for options value. This is to avoid breaking change when upgrading v14 to v16 and 3rd party library passing null to options Fixes: nodejs#36292
7c0accb
to
f474aa5
Compare
@mcollina done. I just check null value against the remaining options above but it seems like most of the options throw There are a couple of changes I can't write a test like when |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, could you also adjust the docs?
I don't think we need a doc update, the falsy values are not documented at the moment, and this is a restoration of previous behaviour we missed to have test covered. |
Yup, thanks @panva |
Commit Queue failed- Loading data for nodejs/node/pull/41170 ✔ Done loading data for nodejs/node/pull/41170 ----------------------------------- PR info ------------------------------------ Title tls: permit null as a pfx value (#41170) ⚠ Could not retrieve the email or name of the PR author's from user's GitHub profile! Branch CallMeLaNN:fix/pfx-cant-load -> nodejs:master Labels tls, author ready Commits 2 - tls: permit null as a pfx value - tls: permit null as an options value Committers 1 - CallMeLaNN PR-URL: https://github.com/nodejs/node/pull/41170 Fixes: https://github.com/nodejs/node/issues/36292 Reviewed-By: Matteo Collina Reviewed-By: Filip Skokan ------------------------------ Generated metadata ------------------------------ PR-URL: https://github.com/nodejs/node/pull/41170 Fixes: https://github.com/nodejs/node/issues/36292 Reviewed-By: Matteo Collina Reviewed-By: Filip Skokan -------------------------------------------------------------------------------- ℹ This PR was created on Tue, 14 Dec 2021 13:57:39 GMT ✔ Approvals: 2 ✔ - Matteo Collina (@mcollina) (TSC): https://github.com/nodejs/node/pull/41170#pullrequestreview-832783699 ✔ - Filip Skokan (@panva): https://github.com/nodejs/node/pull/41170#pullrequestreview-832785694 ✔ Last GitHub Actions successful ℹ Last Full PR CI on 2021-12-16T09:05:25Z: https://ci.nodejs.org/job/node-test-pull-request/41511/ - Querying data for job/node-test-pull-request/41511/ ✔ Last Jenkins CI successful -------------------------------------------------------------------------------- ✔ No git cherry-pick in progress ✔ No git am in progress ✔ No git rebase in progress -------------------------------------------------------------------------------- - Bringing origin/master up to date... From https://github.com/nodejs/node * branch master -> FETCH_HEAD ✔ origin/master is now up-to-date - Downloading patch for 41170 From https://github.com/nodejs/node * branch refs/pull/41170/merge -> FETCH_HEAD ✔ Fetched commits as a182a2163606..f474aa5f722c -------------------------------------------------------------------------------- [master 398b32f020] tls: permit null as a pfx value Author: CallMeLaNN Date: Fri Dec 10 20:52:41 2021 +0800 2 files changed, 18 insertions(+), 1 deletion(-) [master 20ba07821f] tls: permit null as an options value Author: CallMeLaNN Date: Wed Dec 15 15:01:36 2021 +0800 2 files changed, 33 insertions(+), 18 deletions(-) ✔ Patches applied There are 2 commits in the PR. Attempting autorebase. Rebasing (2/4)https://github.com/nodejs/node/actions/runs/1591586400 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use optional chaining? It's very wordy as is.
val !== undefined && val !== null && | ||
val.pem !== undefined ? val.pem : val); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
val !== undefined && val !== null && | |
val.pem !== undefined ? val.pem : val); | |
val?.pem !== undefined ? val.pem : val); |
val !== undefined && val !== null && | ||
val.passphrase !== undefined ? val.passphrase : passphrase); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
val !== undefined && val !== null && | |
val.passphrase !== undefined ? val.passphrase : passphrase); | |
val?.passphrase !== undefined ? val.passphrase : passphrase); |
Landed in 077c75b |
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 PR-URL: nodejs#41170 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Allow null along with undefined for pfx value.
This is to avoid breaking change when upgrading v14 to v16 and
third party library passing null to https option, pfx.
Fixes: #36292