Skip to content

crypto: expose process.features.openssl_is_boringssl #58387

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

Merged
merged 1 commit into from
May 22, 2025

Conversation

codebytere
Copy link
Member

@codebytere codebytere commented May 19, 2025

This PR exposes process.features.openssl_is_boringssl. This allows knowing which crypto library is in use at the JS level - previously the only way to know was to check the version string, which would be 0.0.0 when built with BoringSSL.

This also sets the stage for adapting some of Node.js' crypto tests to run and pass with both BoringSSL and OpenSSL.

@codebytere codebytere requested a review from jasnell May 19, 2025 08:19
@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 19, 2025
Copy link

codecov bot commented May 19, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.22%. Comparing base (d2a1369) to head (1422921).
Report is 13 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #58387   +/-   ##
=======================================
  Coverage   90.21%   90.22%           
=======================================
  Files         635      635           
  Lines      187148   187150    +2     
  Branches    36740    36751   +11     
=======================================
+ Hits       168842   168849    +7     
+ Misses      11081    11073    -8     
- Partials     7225     7228    +3     
Files with missing lines Coverage Δ
lib/internal/bootstrap/node.js 99.57% <100.00%> (+<0.01%) ⬆️
src/node_config.cc 96.55% <100.00%> (+0.12%) ⬆️

... and 31 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.

Copy link
Member

@legendecas legendecas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we expose this bit on process.features instead? crypto.constants object does not seem to be a good place for feature detection.

@codebytere
Copy link
Member Author

@legendecas i don't feel super strongly either way but via crypto.constants is a bit more straightforward imo

@codebytere codebytere force-pushed the define-osslbssl branch 2 times, most recently from a2f1d52 to 978897f Compare May 19, 2025 13:03
@codebytere codebytere requested a review from addaleax May 19, 2025 13:49
#undef OPENSSL_IS_BORINGSSL
#define OPENSSL_IS_BORINGSSL 1
NODE_DEFINE_CONSTANT(target, OPENSSL_IS_BORINGSSL);
#endif
Copy link
Member

@jasnell jasnell May 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a big fan of redefining the existing define this way. Perhaps this could just be crypto.constants.BORINGSSL and the definition here could be:

#ifdef OPENSSL_IS_BORINGSSL
  constexpr auto BORINGSSL = 1;
#else
  constexpr auto BORINGSSL = 0;
#endif
  NODE_DEFINE_CONSTANT(target, BORINGSSL);

Copy link
Member

@jasnell jasnell May 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, I do wonder if this is better exposed via process.config or process.features. We do have the existing process.config.openssl_is_fips and process.config.openssl_quic flags in process.config.

ha... I missed the previous comment about this ;-)

Copy link
Member

@jasnell jasnell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change generally LGTM but there's one additional test that I think needs to be updated (test-process-features.js)

@codebytere codebytere changed the title crypto: expose crypto.constants.OPENSSL_IS_BORINGSSL crypto: expose process.features.openssl_is_boringssl May 20, 2025
Copy link
Member

@legendecas legendecas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but test/parallel/test-process-features.js has to be updated

@addaleax addaleax added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. labels May 21, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label May 21, 2025
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@codebytere codebytere added the commit-queue Add this label to land a pull request using GitHub Actions. label May 22, 2025
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label May 22, 2025
@nodejs-github-bot nodejs-github-bot merged commit 2b42534 into nodejs:main May 22, 2025
64 checks passed
@nodejs-github-bot
Copy link
Collaborator

Landed in 2b42534

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. 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.

5 participants