Skip to content

Conversation

@StefanStojanovic
Copy link
Contributor

As suggested in the linked issue, this PR relaxes the X509 to PEM conversion by skipping failures for system certs. If conversion fails, Node.js will try to give info about the failed certs if it can. This new behavior is used only on system certs, since for others, the user has control. AFAIK, there is no way to add a reliable test for this, but if someone has an idea, feel free to share it with me.

Fixes: #61636

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/crypto

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. crypto Issues and PRs related to the crypto subsystem. needs-ci PRs that need a full CI run. labels Feb 12, 2026
@codecov
Copy link

codecov bot commented Feb 12, 2026

Codecov Report

❌ Patch coverage is 22.58065% with 24 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.72%. Comparing base (9a237cd) to head (88ad793).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/crypto/crypto_context.cc 22.58% 22 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #61784      +/-   ##
==========================================
- Coverage   89.73%   89.72%   -0.02%     
==========================================
  Files         675      675              
  Lines      204674   204700      +26     
  Branches    39330    39338       +8     
==========================================
  Hits       183667   183667              
- Misses      13283    13307      +24     
- Partials     7724     7726       +2     
Files with missing lines Coverage Δ
src/crypto/crypto_context.cc 69.62% <22.58%> (-1.22%) ⬇️

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

Comment on lines +1103 to +1108
std::string subject_str = "<unknown>";
if (subject_bio) {
auto subject_size =
BIO_get_mem_data(subject_bio.get(), &subject_data);
if (subject_size > 0 && subject_data) {
subject_str = std::string(subject_data, subject_size);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
std::string subject_str = "<unknown>";
if (subject_bio) {
auto subject_size =
BIO_get_mem_data(subject_bio.get(), &subject_data);
if (subject_size > 0 && subject_data) {
subject_str = std::string(subject_data, subject_size);
std::string_view subject_str = "<unknown>";
if (subject_bio) {
auto subject_size =
BIO_get_mem_data(subject_bio.get(), &subject_data);
if (subject_size > 0 && subject_data) {
subject_str = std::string_view(subject_data, subject_size);

No good reason to do an extra heap allocation here

per_process::Debug(DebugCategory::CRYPTO,
"Skipping system certificate with subject "
"'%s' because X509 to PEM conversion failed\n",
subject_str.c_str());
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
subject_str.c_str());
subject_str);

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++. crypto Issues and PRs related to the crypto subsystem. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve ergonomics of tls.getCACertificates('system') errors on Windows

3 participants