E2E sign+verify: real valid FNMT cert (current-cert.p12) + generated self-signed p12 #54

Closed
EduarD3V wants to merge 0 commits from issue/39-e2e-sign-verify-real-valid-fnm into bullet-develop
Owner

Implements #39.

Refs #39

Automated by bullet: reviewed (independent model) → gates green on merged tree. Auto-merge follows.

Implements **#39**. Refs #39 Automated by bullet: reviewed (independent model) → gates green on merged tree. Auto-merge follows.
The real FNMT citizen keystore of #39 is written the way the Windows PKCS#12
exporter writes: no definite length above the leaves, chunked OCTET STRINGs,
and an implicit [0] encryptedContent built from chunks. Rejected as
"not a PKCS#12 container" before this.

- readTlv: indefinite lengths (X.690 8.1.3.6), flattening a constructed string
  into the primitive form every consumer expects.
- openSafeContents: ciphertext of a chunked implicit [0] is the concatenation
  of its chunks.
- verify/x509: DN table gains 2.5.4.42 (GN), so the verify report prints the
  same subject as the certificate picker.
- pkcs12.test.ts: DER -> BER re-encoder, round trip + openssl-checked signature.
scripts/smoke-real.sh drives the app's own modules end to end — load the
container, CAdES-sign a document, verify the .csig — and cross-checks the
result with openssl cms -verify and openssl x509 -subject -dates:

- --cert/--pin-file for the real keystore (gitignored, read at runtime, never
  printed); missing keystore or PIN file skips with a notice and exit 0.
- a generated self-signed container from src/test/fixtures.ts runs by default.
- asserts signature validity, signer identity (subject, issuer, serial,
  validity window) and the validity dates in the report output; the report's
  certChain status is printed as it is (signing embeds only the signer
  certificate, #6).
- pnpm verify:real runs it; README documents the headless run and the matching
  UI flow step by step.
The installed xmlsec1 1.3.12 prints `Verification status: OK` / `FAILED`, which the
oracle parser (built for a bare `OK`/1.3 `status: OK`) rejected as "no verdict" — five
XAdES/App tests failed on its output instead of on the signature. Accept the three
wordings; FAILED still maps to FAIL, so the tampered-document test keeps failing as
intended.
Every run of App.test.ts failed 1-2 tests, a different set each time: the PKCS#12 load
and the signing round trip (PBKDF2 + AES + RSA import over Node's WebCrypto under
jsdom) sometimes take longer than the 1 s default waitFor, so the assertion ran before
the DOM update. Reproduced with this branch's src/lib changes reverted (1 failure), so
it predates #39. Same assertions, a realistic bound (the file already used 15 s for the
same kind of wait).
One definition in src/test/fixtures.ts, used by the App, CertPicker and batch tests: the
asynchronous waits that follow a PKCS#12 load, a 250k-iteration seal, a signing round trip
or a store unlock were racing testing-library's 1 s default, so a full run failed a
different 1-2 tests every time. Assertions untouched.
The app opens in Spanish, so the step list is only screenshot-able with the labels the
user actually sees; keep the English wording in brackets.
EduarD3V closed this pull request 2026-10-15 07:16:14 +02:00

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
EduarD3V/AutoFirme!54
No description provided.