Preserve evidence
A Witness gateway can issue long-term evidence records
for its receipts. Anyone holding the export can take over preserving them with
witness-custodian, including after the issuing gateway has shut down. This
page covers both sides. The format and checks are described in the
architecture page.
On the gateway: issuing records
Evidence issuance is off by default. To turn it on, choose an RFC 3161 time-stamp authority (TSA) and give the gateway:
| Flag | Environment | Purpose |
|---|---|---|
--tsa-url |
WITNESS_TSA_URL |
The TSA's request URL. Turns issuance on. |
--tsa-trust-anchor |
WITNESS_TSA_TRUST_ANCHORS |
PEM file with the TSA root certificate(s) you trust. Required. |
--tsa-intermediates |
WITNESS_TSA_INTERMEDIATES |
Optional PEM file with intermediate certificates, if the TSA's tokens leave them out. |
--tsa-crl-url |
WITNESS_TSA_CRL_URLS |
URL of a CRL covering the TSA's certificate path. Repeat the flag (or separate URLs with commas) for each CA. |
--evidence-period-secs |
WITNESS_EVIDENCE_PERIOD_SECS |
Seconds between batches (default 600; 0 stops issuance). |
--evidence-max-receipts |
WITNESS_EVIDENCE_MAX_RECEIPTS |
Receipts per batch (default 5000). |
Each batch timestamps two records for every new confirmed receipt (the
document hash and the signed receipt) with one TSA request. A batch is
published only after the gateway has a CRL issued after the token, so expect a
delay of up to the TSA's CRL publishing interval. Until then
GET /v1/evidence/{hash} returns 404.
The gateway contacts only the URLs you configure; it does not follow URLs found inside certificates, and it does not follow redirects. The TSA must publish CRLs: TSAs that only offer OCSP status are not supported yet.
If the TSA is unreachable or refuses a request, the gateway keeps the batch and retries, waiting one batch period after the first failure and doubling the wait after each further failure, up to six hours. While a batch is waiting for a token, new receipts are held back for the next batch instead of starting more batches, so an outage does not multiply requests to a TSA that charges per token. If you switch to a different TSA, waiting batches are sent to the new one. Batches waiting for a CRL are checked at least once an hour.
To notice problems, watch these metrics on /metrics (see
Monitoring):
witness_evidence_oldest_unfinished_age_seconds,
witness_evidence_receipts_waiting, and
witness_evidence_failures_total.
Clients download a package with:
witness evidence export --hash HASH --out ./evidence/HASH
The directory then contains package.json, document.ers, receipt.json,
receipt.ers, key-history.json, and proof.json if the receipt is in the
Witness log. Exporting does not verify anything; import or validate the files
to do that.
As a custodian: importing and renewing
witness-custodian keeps records in its own SQLite database. Back it up like
any other evidence store.
Import each package using trust settings you obtained yourself, not from the package:
witness-custodian --database custodian.db import \
--package ./evidence/HASH/package.json \
--tsa-trust tsa-root.pem \
--network-config pinned-network.json
Import refuses the package unless both records validate under your TSA roots with complete revocation evidence, the receipt verifies against your pinned Witness key file, and the receipt is for the document's hash. Importing again never replaces a newer chain with an older one.
Check deadlines with witness-custodian --database custodian.db status
(add --json for scripts). Each record has one of these states:
| State | Meaning |
|---|---|
ok |
More than the margin (default 90 days) before the earliest certificate expiry behind its newest timestamp. |
due |
Within the margin. The next renewal should renew it. |
overdue |
Due for more than a day and still not renewed. Renewals are failing; investigate. |
expired |
The newest timestamp can no longer be checked. The record cannot be renewed. |
--margin-days (or WITNESS_CUSTODIAN_MARGIN_DAYS) changes the margin.
Renew due records through the TSA you choose:
witness-custodian --database custodian.db renew \
--tsa-url https://tsa.example/ \
--tsa-trust old-tsa-root.pem new-tsa-root.pem \
--tsa-crl-url https://tsa.example/crl
--tsa-trust must include the roots for both the existing timestamps and the
renewal TSA. Records that share a timestamp are renewed together with one TSA
request, and each record's update happens only if nobody else renewed it
first. Expired records are skipped: renewing them would be too late, and they
cannot be repaired. renew exits non-zero if a renewal failed or any record
is overdue or expired, so a scheduler can alert on it. Waiting for the
TSA's CRL is reported but is not a failure.
Keep renewing with watch, which runs a renewal pass immediately and then
every hour (--interval-secs, at least 60) until it is stopped. A failed pass
is logged and retried on the next pass; watch exits only on a configuration
or database error. Each pass logs a summary line, at error level when
something needs attention.
Every option can also be set in the environment, which suits services and containers:
| Variable | Option |
|---|---|
WITNESS_CUSTODIAN_DATABASE |
--database |
WITNESS_CUSTODIAN_TSA_URL |
--tsa-url |
WITNESS_CUSTODIAN_TSA_TRUST |
--tsa-trust (comma-separated files) |
WITNESS_CUSTODIAN_TSA_INTERMEDIATES |
--tsa-intermediates (comma-separated files) |
WITNESS_CUSTODIAN_TSA_CRL_URLS |
--tsa-crl-url (comma-separated URLs) |
WITNESS_CUSTODIAN_NETWORK_CONFIG |
--network-config |
WITNESS_CUSTODIAN_MARGIN_DAYS |
--margin-days |
WITNESS_CUSTODIAN_INTERVAL_SECS |
--interval-secs |
In Docker, the witness-custodian image runs watch by default, with its
database on the /data volume. With the repository's Compose file, put the
trusted TSA root PEM file(s) at ./custodian/tsa-roots.pem and the pinned
network config at ./custodian/network-pin.json (or set
WITNESS_CUSTODIAN_CONFIG_DIR), set WITNESS_CUSTODIAN_TSA_URL and
WITNESS_CUSTODIAN_TSA_CRL_URLS, and run:
docker compose --profile custodian run --rm custodian import --package /config/package.json
docker compose --profile custodian up -d custodian
docker compose --profile custodian run --rm custodian status
Export renewed records for someone else to check or take over:
witness-custodian --database custodian.db export --hash HASH --out ./renewed/HASH
Checking records independently
A recipient can check an exported record with the European Commission's
open-source DSS library, without any Witness software:
interop/dss/run.sh verify --ers document.ers --file ORIGINAL --trust tsa-root.pem.
interop/evidence/handoff.sh runs the complete handoff between two operators
and a third party.
Limits
- The TSA's clock and practices are only as trustworthy as the TSA. Witness does not make a TSA qualified.
- Renewal must happen before the newest timestamp expires. If no custodian
renews in time, the record cannot be repaired. Alert on
overdue. - If SHA-256 itself weakens, records must be rebuilt from the original files. That is not supported yet.