Skip to content

v8: support X509Certificate serialization - #67083

Merged
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
panva:x509-v8-serialization
Nov 4, 2026
Merged

nodejs-github-bot merged 1 commit into
nodejs:mainfrom
panva:x509-v8-serialization

Conversation

@panva

@panva panva commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

v8.serialize() currently rejects X509Certificate objects. Add a host object encoding containing the certificate's DER snapshot, including its issuerCertificate chain, and reconstruct fresh X509Certificate objects in v8.deserialize().

Read the stored snapshot rather than the cached raw Buffer, which can be modified by callers. Decode each certificate independently without imposing issuer relationships on the serialized sequence.

This is PR 3 out of 4 in an X.509 series addressing #48730 and #51169. (it can land independently of PR 2 https://redirect.github.com/nodejs/node/pull/67082)

v8.serialize() currently rejects X509Certificate objects. Add a host
object encoding containing the certificate's DER snapshot, including
its issuerCertificate chain, and reconstruct fresh X509Certificate
objects in v8.deserialize().

Read the stored snapshot rather than the cached raw Buffer, which can
be modified by callers. Decode each certificate independently without
imposing issuer relationships on the serialized sequence.

Assisted-by: Codex
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
@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. typings Issues and PRs related to internal TypeScript declarations. v8 module Issues and PRs related to the node:v8 module. labels Oct 28, 2026
@panva
panva requested review from jasnell and pimterry October 28, 2026 13:54
@codecov

codecov Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 79.59184% with 30 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.65%. Comparing base (663f666) to head (586410f).
⚠️ Report is 94 commits behind head on main.

Files with missing lines Patch % Lines
src/crypto/crypto_x509.cc 68.91% 10 Missing and 13 partials ⚠️
lib/internal/crypto/x509.js 75.00% 4 Missing ⚠️
lib/v8.js 94.73% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #67083      +/-   ##
==========================================
- Coverage   90.65%   90.65%   -0.01%     
==========================================
  Files         797      797              
  Lines      278593   278740     +147     
  Branches    53570    53610      +40     
==========================================
+ Hits       252561   252686     +125     
- Misses      16377    16383       +6     
- Partials     9655     9671      +16     
Files with missing lines Coverage Δ
src/crypto/crypto_x509.h 57.89% <ø> (+2.33%) ⬆️
lib/v8.js 98.42% <94.73%> (-0.37%) ⬇️
lib/internal/crypto/x509.js 95.77% <75.00%> (-0.77%) ⬇️
src/crypto/crypto_x509.cc 71.54% <68.91%> (+<0.01%) ⬆️

... and 29 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 request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. and removed request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. labels Oct 28, 2026
@panva
panva requested review from addaleax and joyeecheung November 3, 2026 15:06
@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 3, 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 3, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Comment thread lib/v8.js
if (typeIndex === kX509CertificateHostObject) {
const count = this.readUint32();
if (!hasOpenSSL || count === 0) {
throw new ERR_INVALID_STATE('Invalid serialized X509Certificate');

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.

Nit: in the !hasOpenSSL case this error message is wrong. The cert is valid (probably) we just can't read it.

@panva panva added the commit-queue PRs queued for automated landing through the Commit Queue. label Nov 4, 2026
@nodejs-github-bot
nodejs-github-bot merged commit d36e9ba into nodejs:main Nov 4, 2026
96 checks passed
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in d36e9ba

@nodejs-github-bot nodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Nov 4, 2026
@panva
panva deleted the x509-v8-serialization branch November 4, 2026 05:58
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. 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. typings Issues and PRs related to internal TypeScript declarations. v8 module Issues and PRs related to the node:v8 module.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants