Skip to content

Fix three small issues in x509 generation - #67781

Open
pimterry wants to merge 4 commits into
nodejs:mainfrom
pimterry:fix-x509-gen-pss
Open

pimterry wants to merge 4 commits into
nodejs:mainfrom
pimterry:fix-x509-gen-pss

Conversation

@pimterry

Copy link
Copy Markdown
Member

This is work following on from #67245 after I've finally found some time to review it. This covers three tiny bugs that I found in review, easier to fix than discuss I think:

  • The default config when using RSA keys with PSS padding is broken. The salt length for signing defaults to max, while TLS certs must have the salt length match the digest length (32 bytes for SHA-256, etc). In practice this means some clients (e.g. Go) would reject all these certs with default params as invalid, so every use of PSS has to override the salt length to be usable. This PR changes the default salt length to match the RFC requirement (while still observing any PSS params from the key itself). It reverts the small change to getSaltLength from that PR, since it's no longer used here.
    • Aside: we could consider changing the default in getSaltLength too, currently we pin a historical default there that both OpenSSL and BoringSSL have moved away from. Likely a breaking change though, and I can't say I fully understand the implications. Safer to change just for the new API for now.
  • The PR validates against \0 with SAN names, but not the cert subject. This extends coverage to that too.
  • Accidentally, the validation for AKI & SKI extensions differed. Due to some irrelevant implementation details, OpenSSL rejects empty SKI identifiers (silently dropping the extension, which results in a confusing error in Node) but preserves empty AKI. This PR now validates and rejects empty identifiers in both cases.

Broken into separate commits for each change for easier review, I've tried to keep each fairly small & focused.

Signed-off-by: Tim Perry <pimterry@gmail.com>
Signed-off-by: Tim Perry <pimterry@gmail.com>
Signed-off-by: Tim Perry <pimterry@gmail.com>
@pimterry
pimterry requested a review from panva November 25, 2026 23:11
@nodejs-github-bot

Copy link
Copy Markdown
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 Nov 25, 2026
@pimterry pimterry added the commit-queue-rebase PRs the Commit Queue should land as multiple self-contained commits. label Nov 25, 2026
@codecov

codecov Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.89189% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.50%. Comparing base (1d069af) to head (8594e89).
⚠️ Report is 19 commits behind head on main.

Files with missing lines Patch % Lines
src/crypto/crypto_x509_gen.cc 85.00% 0 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #67781      +/-   ##
==========================================
- Coverage   90.51%   90.50%   -0.02%     
==========================================
  Files         805      805              
  Lines      285753   285831      +78     
  Branches    55165    55187      +22     
==========================================
+ Hits       258652   258681      +29     
- Misses      17192    17250      +58     
+ Partials     9909     9900       -9     
Files with missing lines Coverage Δ
lib/internal/crypto/sig.js 98.46% <100.00%> (ø)
lib/internal/crypto/x509_generation.js 93.55% <100.00%> (+0.08%) ⬆️
src/crypto/crypto_x509_gen.cc 68.93% <85.00%> (+0.66%) ⬆️

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

@panva panva added dont-land-on-v22.x PRs that should not land on the v22.x-staging branch and should not be released in v22.x. dont-land-on-v24.x PRs that should not land on the v24.x-staging branch and should not be released in v24.x. dont-land-on-v26.x PRs that should not land on the v26.x-staging branch and should not be released in v26.x. baking-for-lts PRs whose changes need more time before an LTS backport. and removed dont-land-on-v22.x PRs that should not land on the v22.x-staging branch and should not be released in v22.x. dont-land-on-v24.x PRs that should not land on the v24.x-staging branch and should not be released in v24.x. dont-land-on-v26.x PRs that should not land on the v26.x-staging branch and should not be released in v26.x. labels Nov 26, 2026
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
@panva panva added the author ready PRs with CI started, the required approvals, and no outstanding review comments. label Nov 26, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@pimterry pimterry added the commit-queue PRs queued for automated landing through the Commit Queue. label Nov 26, 2026
Comment thread doc/api/crypto.md
-->

> Stability: 1.2 - Release candidate
> Stability: 1.1 - Active development

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.

We normally don't regress on the stability index.

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.

This is only released on an alpha for now. It's baking-for-lts.

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.

Yeah, I know, it's still not something we do often. There's no explanation about why it's being regressed in the PR description.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Very good point yes, sorry. I should've highlighted this in the description separately, it's just that I forgot to raise it.

Came in for two reasons:

  1. We've only just implemented and added this 2 weeks ago, it's just in alpha, and I think there will be active development here, so I'm not sure 'release candidate' is right yet. Each of the 3 changes here is arguably a breaking change we'd mostly avoid for release candidates, for starters, and I think there's more breaking changes we should consider - see my points in crypto: add X.509 generation with CSR support #67245 (comment)
  2. As discussed in that same comment, I think we should consider pulling back the CSR part of this even further, to something we can exclude from the security policy (which I think means behind a CLI flag, which requires 1.1 here) so that we can let it mature and clean up issues there in public for now. Right now, in theory any bug we find in this brand new code is immediately a vulnerability we have to fix in secret, I'd prefer to defer that a bit.

Not married to this, and definitely should've been discussed yes, I can drop it from this PR if we'd prefer.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Hahaha, no, I didn't forget - it's here because Panva pushed it on top separately, it's just that it matches my local changes from the CSR tests I was playing with already so I've got confused 😆

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

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. baking-for-lts PRs whose changes need more time before an LTS backport. c++ Issues and PRs that require attention from people who are familiar with C++. commit-queue PRs queued for automated landing through the Commit Queue. commit-queue-rebase PRs the Commit Queue should land as multiple self-contained commits. 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.

4 participants