Skip to Content
NexPDF

Long-term signatures (B-LTA)

PAdES signature levels, document timestamps and archive timestamps in NexPDF for Electron - signing at B-T, B-LT and B-LTA in the window and the main process, your own time-stamp authority, and validating B-LTA files.

English

License module

Signature levels and document timestamps need the signatures module (Business tier and above). Verification needs the same module.

PAdES B-LTA keeps a signature verifiable for decades. On top of a timestamped signature with its validation data (B-LT), it adds a document timestamp: an RFC 3161 timestamp over the whole file, in an invisible signature field. Before the timestamp authority's certificate expires, you add another one (an archive timestamp), and so on.

Every level above B-B needs a timestamp authority (TSA) on the network, and B-LT and B-LTA also fetch OCSP responses and CRLs:

levelWhat you getIn the windowIn the document API
B-BSignature onlyYesYes
B-TPlus a signature timestampYes, with a TSA URLYes
B-LTPlus certificates, OCSP responses and CRLs (DSS)Yes, with a TSA URL and LTVYes
B-LTAPlus a document timestampNoYes

Sign in the window

The digital signature dialog of the Sign mode makes B-T with a trusted timestamp (TSA URL) and B-LT when revocation data for long-term validation (LTV) is also checked. The engine contacts the TSA and the OCSP and CRL servers from the user's machine. See Signatures.

Sign in the main process

The document API runs NexPDF compiled to WebAssembly. The engine makes no network calls itself: it signs, then builds each request, and the SDK sends them with the main process's fetch and gives the answers back to the engine. doc.signOnline(p12, password, options) signs at any level:

const fs = require('node:fs');
const { openDocumentFile } = require('@nexdevit/nexpdf-electron');

const doc = await openDocumentFile('contract.pdf');
const signed = await doc.signOnline(fs.readFileSync('signer.p12'), 'p12-password', {
  level: 'B-LTA',
  tsaUrl: 'http://timestamp.digicert.com',
  reason: 'Approved',
});
fs.writeFileSync('contract-lta.pdf', signed);
doc.close();

The options are those of sign plus level, tsaUrl, tsa, hash, ltv, timestamp, fetch, headers and maxRounds; see the Node.js long-term signatures guide. On the bytes of a signed file, documents() also has:

CallDoes
timestampSignature(pdf, { tsaUrl })B-T: a signature timestamp on the last signature
addLtvOnline(pdf)B-LT: OCSP responses, CRLs and certificates of every signature into the DSS
timestampDocument(pdf, { tsaUrl })A document timestamp; with ltv: true the DSS is added first (B-LTA, archive renewal)
upgradeSignature(pdf, level, options)Raises a freshly signed B-B file to level
completeExternalSignatureOnline(prepared, cert, signature, { algorithm, level, tsaUrl })External signing, last step, at any level
const { addLtvOnline, timestampDocument } = require('@nexdevit/nexpdf-electron').documents();

let pdf = fs.readFileSync('contract-signed.pdf');
pdf = await addLtvOnline(pdf);
pdf = await timestampDocument(pdf, { tsaUrl: 'http://timestamp.digicert.com', ltv: true });
fs.writeFileSync('contract-renewed.pdf', pdf);

From a renderer

A sandboxed renderer asks the main process through the preload script. handleSigning(ipcMain, options) answers window.nexpdfSigning calls; its tsaUrl, fetch and headers are used for every call, and the renderer cannot change them:

// main
const { handleSigning } = require('@nexdevit/nexpdf-electron');
handleSigning(ipcMain, { tsaUrl: 'http://timestamp.digicert.com' });
new BrowserWindow({ webPreferences: { preload: require.resolve('@nexdevit/nexpdf-electron/preload'), sandbox: true, contextIsolation: true } });

// renderer
const signed = await window.nexpdfSigning.signOnline(pdfBytes, p12Bytes, password, { level: 'B-LTA', reason: 'Approval' });

window.nexpdfSigning has signOnline, prepareExternalSignature, externalSignatureData, completeExternalSignatureOnline, upgradeSignature, timestampSignature, addLtvOnline, timestampDocument and verifySignatures; documents travel as bytes.

Your own TSA

In the main process, pass tsa instead of tsaUrl: a function that receives the RFC 3161 request (DER bytes) and returns the TSA's response (or a Promise of it), for an authority behind your own client, a signing service or a test TSA. If it throws, the call fails with "TSA callback failed".

const tsa = async (request) => {
  const res = await fetch(myTsaUrl, { method: 'POST', headers: { 'Content-Type': 'application/timestamp-query' }, body: request });
  return new Uint8Array(await res.arrayBuffer());
};
const signedBt = await doc.signOnline(fs.readFileSync('signer.p12'), 'p12-password', { level: 'B-T', tsa });

A function cannot cross IPC: renderer calls and handleSigning take tsaUrl, not tsa. To use your own client for renderer calls, give handleSigning a fetch.

The engine steps behind these calls are in documents() too: signatureTimestampRequest, addSignatureTimestamp, ltvRequestsJson, addLtvWithResponses, doc.raw.prepareDocumentTimestamp, documentTimestampRequest and completeDocumentTimestamp.

Validate B-LTA

validateLtaJson(pdf, trustRootsPem) from documents() checks, for each document timestamp, whether the DSS of the revision it timestamps holds every certificate and revocation entry needed for the earlier signatures, their TSAs and earlier document timestamps. OCSP responses are verified: their signature, the responder (the issuing CA or a delegated id-kp-OCSPSigning certificate), the responder's chain to your roots, thisUpdate and nextUpdate around the protecting timestamp, and the status.

const { validateLtaJson } = require('@nexdevit/nexpdf-electron').documents();

const lta = JSON.parse(validateLtaJson(fs.readFileSync('contract-lta.pdf'), fs.readFileSync('roots.pem', 'utf8')));
console.log(lta.complete);
for (const t of lta.timestamps) {
  console.log(t.field, t.time, t.valid, t.has_dss, t.complete, t.covers);
  for (const i of t.issues) console.log(' ', i.field, i.role, i.subject, i.kind);
}

Issue kinds: missing-certificate, missing-revocation, revoked, ocsp-bad-signature, ocsp-unauthorized-responder, ocsp-untrusted-responder, ocsp-not-current and ocsp-unknown-status.

Verify

verifySignatures from documents() reports every signature and every document timestamp, also in files made elsewhere. Two fields are new in 1.1:

FieldMeaning
document_timestamptrue for a document timestamp. Then signer is the TSA, digest_ok checks the message imprint and trusted checks the TSA chain against your roots
pades_levelB-B, B-T, B-LT or B-LTA
const { verifySignatures } = require('@nexdevit/nexpdf-electron').documents();

for (const s of verifySignatures(fs.readFileSync('contract-lta.pdf'))) {
  const kind = s.document_timestamp ? 'timestamp' : 'signature';
  console.log(kind, s.signer, s.pades_level, s.digest_ok && s.signature_ok);
}

The window's Verify shows each signature with its signer, revocation status and PAdES level. See Digital signatures.

On this page