Skip to content

crypto: ignore directory paths in OPENSSL_CONF#63273

Open
haramj wants to merge 1 commit into
nodejs:mainfrom
haramj:haramj-patch-260512-1
Open

crypto: ignore directory paths in OPENSSL_CONF#63273
haramj wants to merge 1 commit into
nodejs:mainfrom
haramj:haramj-patch-260512-1

Conversation

@haramj
Copy link
Copy Markdown
Member

@haramj haramj commented May 13, 2026

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

  1. Manual Verification (macOS Apple Silicon)
    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!

  1. Automated Test Suite
    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.
  2. Linting
    • Passed make lint-cpp (Ensured all lines are 80 characters or less).

Fixes: #63256

@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/startup

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. labels May 13, 2026
Signed-off-by: haramjeong <04harams77@gmail.com>
@haramj haramj force-pushed the haramj-patch-260512-1 branch from 0ac0c7d to 09c23bb Compare May 13, 2026 05:52
@codecov
Copy link
Copy Markdown

codecov Bot commented May 13, 2026

Codecov Report

❌ Patch coverage is 28.57143% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.03%. Comparing base (78bbee3) to head (09c23bb).
⚠️ Report is 12 commits behind head on main.

Files with missing lines Patch % Lines
src/node.cc 28.57% 9 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #63273      +/-   ##
==========================================
- Coverage   90.04%   90.03%   -0.01%     
==========================================
  Files         713      714       +1     
  Lines      225003   225251     +248     
  Branches    42536    42583      +47     
==========================================
+ Hits       202606   202813     +207     
- Misses      14177    14232      +55     
+ Partials     8220     8206      -14     
Files with missing lines Coverage Δ
src/node.cc 75.79% <28.57%> (-0.37%) ⬇️

... and 57 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--use-system-ca fails to start with bad OPENSSL_CONF set

2 participants