crypto: ignore directory paths in OPENSSL_CONF#63273
Open
haramj wants to merge 1 commit into
Open
Conversation
Collaborator
|
Review requested:
|
0ac0c7d to
09c23bb
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #63273 +/- ##
==========================================
+ Coverage 90.03% 90.07% +0.03%
==========================================
Files 714 714
Lines 225427 225435 +8
Branches 42626 42635 +9
==========================================
+ Hits 202968 203056 +88
+ Misses 14241 14171 -70
+ Partials 8218 8208 -10
🚀 New features to boost your workflow:
|
09c23bb to
8979aad
Compare
Contributor
There was a problem hiding this comment.
Why is nix being updated here?
Member
Author
There was a problem hiding this comment.
I'm so sorry. I had a major issue with my local git branch sync, which caused irrelevant commits to be merged. I've performed a hard reset and cleaned up the history. Now only the node.cc fix is included in this PR. Thank you
8979aad to
d331383
Compare
Signed-off-by: haramjeong <04harams77@gmail.com>
d331383 to
b4ee1f4
Compare
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.
Summary
This PR improves the robustness of Node.js startup when the OPENSSL_CONF environment variable points to a directory instead of a file. Currently, such cases cause a fatal OpenSSL configuration error, preventing Node.js from starting. This change detects directory paths early, emits a descriptive warning, and allows Node.js to continue booting using default settings.
Root Cause Analysis
In src/node.cc, the InitializeOncePerProcessInternal function attempts to load the OpenSSL configuration. If OPENSSL_CONF is set to a directory (e.g., /tmp or C:), OpenSSL's internal fopen() fails, raising a fatal error that triggers an early return and process exit.
Changes
• Pre-check with stat(): Detects if conf_file is a directory before passing it to OpenSSL.
• Cross-platform Compatibility: Implemented directory detection using S_ISDIR and bitwise masks for environments where the macro is unavailable.
• Warning Instead of Exit: Replaced the fatal error exit with a fprintf(stderr, ...) warning to inform the user that the directory path is being ignored.
• Error Queue Management: Ensured the OpenSSL error queue is cleared using ERR_clear_error() to prevent side effects for subsequent operations.
Validation & Testing
I performed a clean build after running make distclean and verified the fix:
$ export OPENSSL_CONF=/tmp
$ ./node --use-system-ca -e "console.log('Final Validation: I am alive!')"
Actual Output:
Warning: OPENSSL_CONF path is a directory; ignoring: /tmp
Final Validation: I am alive!
I ran the full test suite using python3 tools/test.py:
• Passed: 5284 tests.
• Failed: 7 tests (All verified as missing FFI test fixtures, unrelated to this change).
• All parallel/test-crypto-* tests passed successfully.
• Passed make lint-cpp (Ensured all lines are 80 characters or less).
Fixes: #63256