Fix handling of empty subject names in certs#102
Merged
Conversation
kspearrin
approved these changes
Mar 11, 2021
sso-bitwarden
pushed a commit
to sso-bitwarden/directory-connector
that referenced
this pull request
Aug 28, 2025
Fix handling of empty subject names in certs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
bwdcCLI uses the locally installed node version, so users on older node versions are still susceptible.Code changes
The bug resides in node's TLS
checkServerIdentityfunction. We can provide our owncheckServerIdentityfunction in theldapjsclient 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).