GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — crypto: add X.509 generation with CSR support by panva · Pull Request #67245 · nodejs/node

Conversation

@panva

@panva panva commented Nov 4, 2026

Copy link
Copy Markdown
Member

Expose callback-based generateX509Certificate() and synchronous generateX509CertificateSync(), producing X509Certificate objects for self-signed and issuer-signed X.509 v3 certificates. Accept grouped distinguished names or exact subject DER, public keys, serial numbers, validity dates, and an explicit signing digest. Reuse crypto.sign() key inputs and RSA options, including OpenSSL STORE-backed keys.

A PKCS#10 request can supply the subject and public key instead. Require a synchronous selectExtensions callback to accept, replace, or amend the requested extensions. Verify the request signature before signing the certificate, in the selected sync or async mode.

Provide typed Basic Constraints, Key Usage, Extended Key Usage, SAN, SKI, and AKI, plus arbitrary raw extensions. Add none implicitly and leave raw extension semantics to the caller. Copy mutable inputs before queueing asynchronous work. Certificate trust and CA authorization remain the caller's responsibility.

This is PR 4 out of 4 in an X.509 series addressing #48730 and #51169.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
panva added 2 commits November 4, 2026 10:52
@panva
crypto: add X.509 generation with CSR support
d1eec0f
Expose callback-based generateX509Certificate() and synchronous
generateX509CertificateSync(), producing X509Certificate objects for
self-signed and issuer-signed X.509 v3 certificates. Accept grouped
distinguished names or exact subject DER, public keys, serial numbers,
validity dates, and an explicit signing digest. Reuse crypto.sign() key
inputs and RSA options, including OpenSSL STORE-backed keys.

A PKCS#10 request can supply the subject and public key instead.
Require a synchronous selectExtensions callback to accept, replace, or
amend the requested extensions. Verify the request signature before
signing the certificate, in the selected sync or async mode.

Provide typed Basic Constraints, Key Usage, Extended Key Usage, SAN,
SKI, and AKI, plus arbitrary raw extensions. Add none implicitly and
leave raw extension semantics to the caller. Copy mutable inputs
before queueing asynchronous work. Certificate trust and CA
authorization remain the caller's responsibility.

Fixes: nodejs#51169
Assisted-by: Codex
Signed-off-by: Filip Skokan <[email protected]>
@panva
crypto: make X.509 inspection guards explicit
0087cef
Require a supported backend when selecting the BIT STRING length
capability. Reject other backends at compile time, matching the
surrounding checks used to catch unsupported OpenSSL backports.

Assisted-by: Codex
Signed-off-by: Filip Skokan <[email protected]>
@nodejs-github-bot

nodejs-github-bot commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/crypto
  • @nodejs/gyp
  • @nodejs/security-wg
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot nodejs-github-bot added 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 4, 2026
@panva
panva requested a review from pimterry November 4, 2026 10:43
@panva panva added the commit-queue-rebase PRs the Commit Queue should land as multiple self-contained commits. label Nov 4, 2026
@panva
panva requested a review from mcollina November 4, 2026 10:43
panva added 2 commits November 4, 2026 11:57
@panva
fixup! crypto: add X.509 generation with CSR support
e1037ac
@panva
fixup! crypto: add X.509 generation with CSR support
a44ae0e
@codecov

codecov Bot commented Nov 4, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 79.58188% with 293 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.63%. Comparing base (3b209b2) to head (a44ae0e).
⚠️ Report is 67 commits behind head on main.

Files with missing lines Patch % Lines
src/crypto/crypto_x509_gen.cc 68.26% 102 Missing and 149 partials ⚠️
lib/internal/crypto/x509_generation.js 93.47% 39 Missing and 1 partial ⚠️
src/crypto/crypto_x509_gen.h 33.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #67245      +/-   ##
==========================================
- Coverage   90.68%   90.63%   -0.06%     
==========================================
  Files         797      800       +3     
  Lines      279367   280794    +1427     
  Branches    53737    54083     +346     
==========================================
+ Hits       253344   254493    +1149     
- Misses      16319    16443     +124     
- Partials     9704     9858     +154     
Files with missing lines Coverage Δ
lib/crypto.js 94.56% <100.00%> (+0.22%) ⬆️
lib/internal/crypto/sig.js 98.46% <100.00%> (+<0.01%) ⬆️
src/crypto/crypto_util.h 68.53% <ø> (ø)
src/crypto/crypto_x509.cc 71.52% <100.00%> (-0.20%) ⬇️
src/crypto/crypto_x509.h 65.21% <ø> (ø)
src/node_crypto.cc 81.81% <ø> (ø)
src/crypto/crypto_x509_gen.h 33.33% <33.33%> (ø)
lib/internal/crypto/x509_generation.js 93.47% <93.47%> (ø)
src/crypto/crypto_x509_gen.cc 68.26% <68.26%> (ø)

... and 28 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.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@panva panva mentioned this pull request Nov 6, 2026
crypto: X509Certificate returns "Bad time value" instead of throwing for an unreadable validity time #67285
Closed
mcollina
mcollina approved these changes Nov 9, 2026
View reviewed changes

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

lgtm

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@panva panva added author ready PRs with CI started, the required approvals, and no outstanding review comments. request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. labels Nov 9, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Nov 9, 2026
@nodejs-github-bot

nodejs-github-bot commented Nov 9, 2026

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/78928/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@panva panva added the resume-ci Add this label to resume the latest eligible Jenkins CI run on a PR with an approving review. label Nov 9, 2026
@github-actions github-actions Bot removed the resume-ci Add this label to resume the latest eligible Jenkins CI run on a PR with an approving review. label Nov 9, 2026
@nodejs-github-bot

nodejs-github-bot commented Nov 9, 2026

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/78933/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sxa sxa mentioned this pull request Nov 10, 2026
test-perf-hooks-histogram-external-memory failures on node-test-comit-plinux #67374
Closed
@panva panva added semver-minor PRs that contain new features and should be released in the next minor version. baking-for-lts PRs whose changes need more time before an LTS backport. commit-queue PRs queued for automated landing through the Commit Queue. labels Nov 11, 2026
@nodejs-github-bot nodejs-github-bot added the lacks-second-approval Commit Queue PRs awaiting a second collaborator approval or completion of the required wait. label Nov 11, 2026
@nodejs-github-bot

nodejs-github-bot commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator

Landed in 77e6379...2336a1f

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

nodejs-github-bot pushed a commit that referenced this pull request Nov 11, 2026
@panva @nodejs-github-bot
crypto: add X.509 generation with CSR support
5498ee6
Expose callback-based generateX509Certificate() and synchronous
generateX509CertificateSync(), producing X509Certificate objects for
self-signed and issuer-signed X.509 v3 certificates. Accept grouped
distinguished names or exact subject DER, public keys, serial numbers,
validity dates, and an explicit signing digest. Reuse crypto.sign() key
inputs and RSA options, including OpenSSL STORE-backed keys.

A PKCS#10 request can supply the subject and public key instead.
Require a synchronous selectExtensions callback to accept, replace, or
amend the requested extensions. Verify the request signature before
signing the certificate, in the selected sync or async mode.

Provide typed Basic Constraints, Key Usage, Extended Key Usage, SAN,
SKI, and AKI, plus arbitrary raw extensions. Add none implicitly and
leave raw extension semantics to the caller. Copy mutable inputs
before queueing asynchronous work. Certificate trust and CA
authorization remain the caller's responsibility.

Fixes: #51169
Assisted-by: Codex
Signed-off-by: Filip Skokan <[email protected]>
PR-URL: #67245
Reviewed-By: Matteo Collina <[email protected]>
nodejs-github-bot pushed a commit that referenced this pull request Nov 11, 2026
@panva @nodejs-github-bot
crypto: make X.509 inspection guards explicit
2336a1f
Require a supported backend when selecting the BIT STRING length
capability. Reject other backends at compile time, matching the
surrounding checks used to catch unsupported OpenSSL backports.

Assisted-by: Codex
Signed-off-by: Filip Skokan <[email protected]>
PR-URL: #67245
Reviewed-By: Matteo Collina <[email protected]>
@nodejs-github-bot nodejs-github-bot closed this Nov 11, 2026
@nodejs-github-bot nodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Nov 11, 2026
@nodejs-github-bot nodejs-github-bot removed the lacks-second-approval Commit Queue PRs awaiting a second collaborator approval or completion of the required wait. label Nov 11, 2026
@panva
panva deleted the x509-generation branch November 11, 2026 11:03
@panva panva mentioned this pull request Nov 11, 2026
test: fix X.509 generation with OpenSSL 4.1 FIPS #67409
Closed
aduh95 pushed a commit that referenced this pull request Nov 11, 2026
@panva @aduh95
crypto: add X.509 generation with CSR support
0882e97
Expose callback-based generateX509Certificate() and synchronous
generateX509CertificateSync(), producing X509Certificate objects for
self-signed and issuer-signed X.509 v3 certificates. Accept grouped
distinguished names or exact subject DER, public keys, serial numbers,
validity dates, and an explicit signing digest. Reuse crypto.sign() key
inputs and RSA options, including OpenSSL STORE-backed keys.

A PKCS#10 request can supply the subject and public key instead.
Require a synchronous selectExtensions callback to accept, replace, or
amend the requested extensions. Verify the request signature before
signing the certificate, in the selected sync or async mode.

Provide typed Basic Constraints, Key Usage, Extended Key Usage, SAN,
SKI, and AKI, plus arbitrary raw extensions. Add none implicitly and
leave raw extension semantics to the caller. Copy mutable inputs
before queueing asynchronous work. Certificate trust and CA
authorization remain the caller's responsibility.

Fixes: #51169
Assisted-by: Codex
Signed-off-by: Filip Skokan <[email protected]>
PR-URL: #67245
Reviewed-By: Matteo Collina <[email protected]>
aduh95 pushed a commit that referenced this pull request Nov 11, 2026
@panva @aduh95
crypto: make X.509 inspection guards explicit
edc7ec4
Require a supported backend when selecting the BIT STRING length
capability. Reject other backends at compile time, matching the
surrounding checks used to catch unsupported OpenSSL backports.

Assisted-by: Codex
Signed-off-by: Filip Skokan <[email protected]>
PR-URL: #67245
Reviewed-By: Matteo Collina <[email protected]>
@github-actions github-actions Bot mentioned this pull request Nov 11, 2026
2026-11-12, Version 27.0.0-alpha.0.1.0 (Alpha) #67415
Merged
nodejs-github-bot added a commit that referenced this pull request Nov 11, 2026
@nodejs-github-bot
2026-11-12, Version 27.0.0-alpha.0.1.0 (Alpha)
dd138af
Notable changes:

child_process:
  * (SEMVER-MINOR) add subprocess.timedOut (Marco) #66639
crypto:
  * (SEMVER-MINOR) make X.509 inspection guards explicit (Filip Skokan) #67245
  * (SEMVER-MINOR) add X.509 generation with CSR support (Filip Skokan) #67245
dns:
  * (SEMVER-MINOR) coalesce identical concurrent lookup() requests (Orgad Shaneh) #62599
doc:
  * add efekrskl to collaborators (Efe Karasakal) #67376
  * add Philipp Dunkel to contributors (Philipp Dunkel) #67378
  * add christianaurichzm to collaborators (Christian Aurich Zanettini Martins) #67377
http:
  * (SEMVER-MINOR) batch body spans per parser execute (Guilherme Araújo) #67187
sea:
  * (SEMVER-MINOR) generate a compile cache for the VFS modules (Matteo Collina) #66768
worker:
  * (SEMVER-MINOR) preload streams into startup snapshot (Matteo Collina) #66311

PR-URL: #67415
aduh95 pushed a commit that referenced this pull request Nov 12, 2026
@nodejs-github-bot @aduh95
2026-11-12, Version 27.0.0-alpha.0.1.0 (Alpha)
4f23168
Notable changes:

child_process:
  * (SEMVER-MINOR) add subprocess.timedOut (Marco) #66639
crypto:
  * (SEMVER-MINOR) make X.509 inspection guards explicit (Filip Skokan) #67245
  * (SEMVER-MINOR) add X.509 generation with CSR support (Filip Skokan) #67245
dns:
  * (SEMVER-MINOR) coalesce identical concurrent lookup() requests (Orgad Shaneh) #62599
doc:
  * add efekrskl to collaborators (Efe Karasakal) #67376
  * add Philipp Dunkel to contributors (Philipp Dunkel) #67378
  * add christianaurichzm to collaborators (Christian Aurich Zanettini Martins) #67377
http:
  * (SEMVER-MINOR) batch body spans per parser execute (Guilherme Araújo) #67187
sea:
  * (SEMVER-MINOR) generate a compile cache for the VFS modules (Matteo Collina) #66768
worker:
  * (SEMVER-MINOR) preload streams into startup snapshot (Matteo Collina) #66311

PR-URL: #67415
@pimterry pimterry mentioned this pull request Nov 25, 2026
Fix three small issues in x509 generation #67781
Closed
@pimterry

pimterry commented Nov 25, 2026

Copy link
Copy Markdown
Member

I has taken me millennia, but sorry @panva, but I've now had a change to properly look at this and play with it. I've built out a local version of my setup on top to test it in practice, and it does work nicely! Speeds up my cert generation code up to 6x, which is very nice indeed 😃 There are some non-breaking additions which would simplify using it in my setup (we'll get to those later) but excluding that, some other bits worth mentioning here in the meantime:

I found a few small specific tiny issues, which I've opened quick fixes to cover in #67781.

I think the CSR API design could be improved. I think it falls in an unhappy valley right now: it's a specialized feature that most users won't need, but for the users who do need it it's too limited.

I'm particularly thinking about the selectExtensions approach, which doesn't seem like it'd cover most real cases where people use CSRs, where they need real validation and control over what gets signed and how. That means you may well want policy on other CSR params (not just extensions), you might want extension policy to relate to other cert params (selectExtensions only receives the extension data - there's no way to read the rest of the CSR data without a separate parser), you might want async policy decisions, and you'll want to cleanly reject some CSRs up front rather than just filtering details during generation.

If we consider that the current CSR flow looks roughly like this:

generateX509CertificateSync({
  csr, issuer, serialNumber, notBefore, notAfter, signature,
  selectExtensions(requestedExts) { return applyPolicy(requestedExts); }
});

I wonder if it should look more like:

const req = X509CertificateRequest.parse(csr);
doCustomValidation(req); // Read any field, do anything

generateX509Certificate({
  subject: req.subjectName.raw,
  publicKey: req.publicKey,
  extensions: await applyCustomExtensionPolicy(req),
  ...
});

That shape has the advantage of making cert generation completely independent of CSRs, instead of mixing the CSR code into cert generation. They can be separate implementations that users glue together themselves. Makes it much easier to apply policy & transformations freely, and makes both implementations simpler.

Separately: even without that change, I think we might want to consider moving the CSR part of this API back to stage 1.1 experimental, behind a CLI flag, because it's security sensitive. CSRs mean feeding parsing of attacker input into trusted cert generation. I don't see any obvious issues today, but I bet a wave of AI scanners will find some soon enough. It will be much easier to find & fix those bugs in public while this is fully experimental, instead of having to treat all issues as serious vulnerabilities that we have to fix in secret.

Only applies to CSRs specifically since they're generally external input. I think most other X509 generation (barring extremely horrible bugs) wouldn't be security issues, the most likely failure cases just result in broken certs I think. Passing untrusted input into a X509 generation APIs is a bug in your code, not ours.

I have some other notable thoughts on the TBS side, which we briefly discussed in Slack, I still need to dig into that and explore it. I think there's some tiny API changes here that would make that easier to glue together, but nothing major. Otherwise everything looks great to me. Thanks for all the work on this @panva!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

gabylb pushed a commit to gabylb/node that referenced this pull request Nov 27, 2026
@panva @gabylb
crypto: add X.509 generation with CSR support
d16d781
Expose callback-based generateX509Certificate() and synchronous
generateX509CertificateSync(), producing X509Certificate objects for
self-signed and issuer-signed X.509 v3 certificates. Accept grouped
distinguished names or exact subject DER, public keys, serial numbers,
validity dates, and an explicit signing digest. Reuse crypto.sign() key
inputs and RSA options, including OpenSSL STORE-backed keys.

A PKCS#10 request can supply the subject and public key instead.
Require a synchronous selectExtensions callback to accept, replace, or
amend the requested extensions. Verify the request signature before
signing the certificate, in the selected sync or async mode.

Provide typed Basic Constraints, Key Usage, Extended Key Usage, SAN,
SKI, and AKI, plus arbitrary raw extensions. Add none implicitly and
leave raw extension semantics to the caller. Copy mutable inputs
before queueing asynchronous work. Certificate trust and CA
authorization remain the caller's responsibility.

Fixes: nodejs#51169
Assisted-by: Codex
Signed-off-by: Filip Skokan <[email protected]>
PR-URL: nodejs#67245
Reviewed-By: Matteo Collina <[email protected]>
gabylb pushed a commit to gabylb/node that referenced this pull request Nov 27, 2026
@panva @gabylb
crypto: make X.509 inspection guards explicit
bd35eb4
Require a supported backend when selecting the BIT STRING length
capability. Reject other backends at compile time, matching the
surrounding checks used to catch unsupported OpenSSL backports.

Assisted-by: Codex
Signed-off-by: Filip Skokan <[email protected]>
PR-URL: nodejs#67245
Reviewed-By: Matteo Collina <[email protected]>
gabylb pushed a commit to gabylb/node that referenced this pull request Nov 27, 2026
@nodejs-github-bot @gabylb
2026-11-12, Version 27.0.0-alpha.0.1.0 (Alpha)
d26c0f2
Notable changes:

child_process:
  * (SEMVER-MINOR) add subprocess.timedOut (Marco) nodejs#66639
crypto:
  * (SEMVER-MINOR) make X.509 inspection guards explicit (Filip Skokan) nodejs#67245
  * (SEMVER-MINOR) add X.509 generation with CSR support (Filip Skokan) nodejs#67245
dns:
  * (SEMVER-MINOR) coalesce identical concurrent lookup() requests (Orgad Shaneh) nodejs#62599
doc:
  * add efekrskl to collaborators (Efe Karasakal) nodejs#67376
  * add Philipp Dunkel to contributors (Philipp Dunkel) nodejs#67378
  * add christianaurichzm to collaborators (Christian Aurich Zanettini Martins) nodejs#67377
http:
  * (SEMVER-MINOR) batch body spans per parser execute (Guilherme Araújo) nodejs#67187
sea:
  * (SEMVER-MINOR) generate a compile cache for the VFS modules (Matteo Collina) nodejs#66768
worker:
  * (SEMVER-MINOR) preload streams into startup snapshot (Matteo Collina) nodejs#66311

PR-URL: nodejs#67415
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@mcollina mcollina mcollina approved these changes
@pimterry pimterry Awaiting requested review from pimterry

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

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. commit-queue-rebase PRs the Commit Queue should land as multiple self-contained commits. lib / src Issues and PRs involving general changes in the lib/ or src/ directories. needs-ci PRs that need a full CI run. semver-minor PRs that contain new features and should be released in the next minor version.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@panva @nodejs-github-bot @pimterry @mcollina
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.