Skip to content

crypto: stop swallowing X.509 operation errors - #67408

Open
panva wants to merge 2 commits into
nodejs:mainfrom
panva:x509-major
Open

panva wants to merge 2 commits into
nodejs:mainfrom
panva:x509-major

Conversation

@panva

@panva panva commented Nov 11, 2026

Copy link
Copy Markdown
Member

Conversion failures can currently look like absent certificate fields. Invalid validity times produce "Bad time value" or Invalid Date, so date comparisons can fail without reporting the invalid input.

Throw for failed field conversion, certificate encoding, fingerprint calculation, and decoding of present AIA or EKU extensions. Stop legacy certificate conversion at the first error.

Report failed or unsupported private-key comparisons separately from a key mismatch. In verify(), throw on negative verification results except for a wrong key type or invalid unused bits in the signature BIT STRING. Those cases and a zero verification result return false.

Fixes: #67285

Conversion failures can currently look like absent certificate fields.
Invalid validity times produce "Bad time value" or Invalid Date, so date
comparisons can fail without reporting the invalid input.

Throw for failed field conversion, certificate encoding, fingerprint
calculation, and decoding of present AIA or EKU extensions. Stop legacy
certificate conversion at the first error.

Report failed or unsupported private-key comparisons separately from a
key mismatch. In verify(), throw on negative verification results except
for a wrong key type or invalid unused bits in the signature BIT STRING.
Those cases and a zero verification result return false.

Fixes: nodejs#67285
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Assisted-by: Codex
@panva panva added the semver-major PRs that contain breaking changes and should be released in the next major version. label Nov 11, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/crypto
  • @nodejs/security-wg

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs involving general changes in the lib/ or src/ directories. needs-ci PRs that need a full CI run. labels Nov 11, 2026
@panva

panva commented Nov 11, 2026

Copy link
Copy Markdown
Member Author

Blocked on #67406 landing first.

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

@codecov

codecov Bot commented Nov 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 67.20000% with 41 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.69%. Comparing base (1b99d7c) to head (f7dbe76).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/crypto/crypto_x509.cc 67.20% 19 Missing and 22 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #67408      +/-   ##
==========================================
- Coverage   90.70%   90.69%   -0.01%     
==========================================
  Files         801      801              
  Lines      281559   281603      +44     
  Branches    54248    54262      +14     
==========================================
+ Hits       255387   255406      +19     
- Misses      16308    16332      +24     
- Partials     9864     9865       +1     
Files with missing lines Coverage Δ
src/crypto/crypto_x509.cc 72.10% <67.20%> (+0.64%) ⬆️

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

blocked PRs that are blocked by other issues or PRs. c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs involving general changes in the lib/ or src/ directories. needs-ci PRs that need a full CI run. semver-major PRs that contain breaking changes and should be released in the next major version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

crypto: X509Certificate returns "Bad time value" instead of throwing for an unreadable validity time

3 participants