Fix handling of empty subject names in certs #102
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Objective
Node had a bug which would reject public certificates as empty if their subject was empty, even if they had altNames defined. See nodejs/node#22906.
This bug was fixed in node 12.14.1. Our electron version uses a later node version, so it doesn't affect the electron app.
However, the
bwdc
CLI uses the locally installed node version, so users on older node versions are still susceptible.Code changes
The bug resides in node's TLS
checkServerIdentity
function. We can provide our owncheckServerIdentity
function in theldapjs
client options. Our function works by inserting a non-null subject line before calling the standard function.This is based on auth0's workaround which I have referenced in the comment. (Let me know if this is unnecessary.)
Testing
This now correctly validates a test certificate (provided by a customer) with an empty subject and altNames defined, in node v12.0 (pre-bugfix). I have also tested on v14.15.4 to make sure it doesn't interfere with later versions of Node (post-bugfix).