Skip to content

tools: generate distrust-after dates from certdata.txt - #67414

Draft
UlisesGascon wants to merge 2 commits into
nodejs:mainfrom
UlisesGascon:tools/root-certs-distrust-after
Draft

UlisesGascon wants to merge 2 commits into
nodejs:mainfrom
UlisesGascon:tools/root-certs-distrust-after

Conversation

@UlisesGascon

Copy link
Copy Markdown
Member

The distrust-after table added in #67412 had to be typed by hand: find the root in certdata.txt, hash its public key, convert the date to an epoch. The first draft of the G1 entry had the wrong year.

This adds tools/mk-root-certs-distrust.mjs, which reads tools/certdata.txt and src/node_root_certs.h and writes src/node_root_certs_distrust.h with one entry per bundled root that carries a distrust-after date. The verify callback includes that header; the hand-written table shrinks to dates Mozilla publishes between NSS releases and the test fixture. update-root-certs.mjs runs the generator after mk-ca-bundle.pl and lists date changes in the commit message it produces, so the weekly root-certificates job picks new dates up with no extra step. A test regenerates the header and fails when the committed copy is out of date with certdata.txt.

With the current certdata.txt snapshot the generated header holds Izenpe.com only. emSign Root CA - G1 and Firmaprofesional stay in the hand-written table until the next root certificate update brings their dates in, at which point those two entries can be dropped.

Depends on

This branch includes the commit (c67c30c) from #67412, which must land first. Only the second commit (93d1f5d) is for review here.


⚠️ I will keep the PR as draft until #67412 has landed and I can rebase and sync with any relevant cert chagnes from main


Context

Refs: #67391
Assisted-by: Claude, Codex, Mistral

Mozilla keeps emSign Root CA - G1, Izenpe.com and Firmaprofesional CIF
A62634068 in its root store but distrusts TLS server certificates they
issued after 2026-11-16, 2026-04-15 and 2026-08-06 respectively
(CKA_NSS_SERVER_DISTRUST_AFTER). tools/mk-ca-bundle.pl does not carry
that attribute into node_root_certs.h, so Node.js keeps accepting new
certificates from these roots that browsers reject.

Add a distrust-after table next to the SPKI blocklist in the certificate
verify callback. When a client verifies a server chain through a listed
key and the leaf's notBefore is after the key's cutoff, the chain fails
with CERT_REVOKED; certificates issued up to the cutoff keep working.
Client certificates are not affected: the attribute is Mozilla's server
authentication policy, the roots stay trusted anchors otherwise, and
this matches the scope of the 2016 StartCom/WoSign cutoff. Node.js has
no Certificate Transparency checking, so a backdated notBefore is not
detected, as with that cutoff.

Fixes: nodejs#67391
Refs: https://bugzilla.mozilla.org/show_bug.cgi?id=2089115
Assisted-by: Claude, Codex, Mistral
Signed-off-by: Ulises Gascon <ulisesgascongonzalez@gmail.com>
Mozilla's CKA_NSS_SERVER_DISTRUST_AFTER dates are enforced by the
distrust-after table in src/crypto/crypto_context.cc, which so far had to
be typed by hand: find the root in certdata.txt, hash its public key,
convert the date to an epoch. The emSign G1 entry was first written with
the wrong year, which is the kind of slip a generator avoids.

Add tools/mk-root-certs-distrust.mjs, which reads tools/certdata.txt and
src/node_root_certs.h and writes src/node_root_certs_distrust.h with one
entry per bundled root that carries a distrust-after date. The verify
callback includes that header as kDistrustAfterBundled and keeps the
hand-written table for dates Mozilla publishes between NSS releases and
for the test fixture. update-root-certs.mjs runs the generator after
mk-ca-bundle.pl and reports date changes in the commit message it
produces, so the weekly root-certificates job picks new dates up with
no extra step. A test regenerates the header and fails when the
committed copy is out of date with certdata.txt.

With the current certdata.txt snapshot the generated table holds
Izenpe.com only; emSign Root CA - G1 and Firmaprofesional stay in the
hand-written table until the next root certificate update brings their
dates in.

Refs: nodejs#67391
Assisted-by: Claude, Codex, Mistral
Signed-off-by: Ulises Gascon <ulisesgascongonzalez@gmail.com>
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

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

@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
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++. lib / src Issues and PRs involving general changes in the lib/ or src/ directories. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants