1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# Optional external timestamps
Signet still records server-authenticated sign-offs and facsimiles, not
certificate-based PDF signatures. Optional detached RFC3161 evidence confirms
that the **unchanged released PDF** existed by a timestamp authority's time.
It does not independently establish an earlier sign-off time, signer identity,
consent, Indian DSC/eSign recognition or any other legal qualification.
It is **not PAdES B-T**; PDF readers will not show a PDF digital-signature panel.
The original release/audit behavior is unchanged.
## Enable deliberately
This is source/disposable-development verified, not production deployment
acceptance. Do not upgrade a production or preserved preview without approval.
1. Back up coordinated database, document files, configuration and trust bundles.
Stop writers and apply `sql/migrations/004-detached-timestamps.sql` as database
owner **before installing the new API**, even if timestamps will be disabled.
Fresh installs use `sql/schema.sql`; grant `signetd` SELECT/INSERT/UPDATE on
`document_timestamps` as shown in the install guide. No old PDF/sign-off is
rewritten or backdated by the migration.
2. Build with `curl-dev` and `openssl-dev`. The timestamp executable uses
**libcurl and OpenSSL libcrypto**; it does not launch curl/openssl or require
either command-line executable in production. Keep the platform's HTTPS CA
bundle available. Other Signet binaries do not link the timestamp module.
3. Independently choose an HTTPS RFC3161 endpoint and provision its approved TSA
signing trust anchors in a local PEM file readable by `signetd`. Neither the
endpoint nor trust is selected/downloaded automatically. Configure:
```ini
timestamp.url = https://your-selected-authority.example/timestamp
timestamp.ca_file = /etc/signet/tsa-trust.pem
timestamp.tls_ca_file =
```
The first two values enable attempts. The last is normally empty: HTTPS uses
platform trust, independently of the TSA signing trust file. A private test
endpoint can use a separate explicit HTTPS trust bundle there. Keep trust
files/configuration administrator-owned and non-writable by service users;
do not put private keys or signature images in them. No provider account or
private signing key is required by this feature.
4. Install `etc/timestamp.cron.example` in **signetd's user crontab**, using the
established system cron service and the actual installation prefix. Preserve
existing user-crontab entries; do not blindly replace the whole crontab.
Confirm system cron runs and captures worker stderr/syslog. Example entry:
```cron
* * * * * /usr/local/libexec/signet-timestamp
```
A supervised manual invocation of that executable (with optional `-c PATH`)
uses the same persistent budget, not a new retry window. There is no new
resident Signet service. Installing the example file alone does not schedule
anything. Leave the endpoint/trust unset and do not schedule it to stay off.
Only the SHA-256 imprint, fresh random nonce and protocol fields go to the TSA,
not PDF contents, names or facsimiles. Network timing and the digest can still
be correlated; timestamping is an explicit external network dependency.
HTTPS certificate/hostname verification is required; redirects and proxies are
disabled. Replies are limited to 65,536 bytes. Each HTTPS operation has at most
10 seconds (or the remaining window), with at most 3 seconds for connection.
## Four attempts, one release-anchored hour
The cron runner discovers recent released documents without changing release.
Attempt slots are approximately the first scheduled run after release, then
release +5, +20 and +55 minutes. Late runs keep the original deadline; at least
one minute separates rescheduled attempts when a slot was missed. There are
**four total attempts**, not four retries, and no attempt after release +1 hour.
An offline/overloaded scheduler can make fewer attempts; there is no guarantee
that all four occur. Old releases are never put into a fresh one-hour window.
The database records/consumes each attempt before hashing/network I/O, so a
crash also consumes its slot. A session advisory lock serializes overlapping
runners; no document row remains locked during HTTPS. The runner spaces its
requests by at least one second, processes at most 20 jobs per invocation and
stops starting jobs after approximately 20 seconds. A current bounded operation
can finish after that invocation budget. One-hour eligibility is independently
checked before HTTP and when storing successful evidence.
The on-disk final PDF must still hash to the released revision's recorded hash.
A response succeeds only after full DER parsing and OpenSSL verification of
requested SHA-256 imprint, nonce/version, signature, certificate chain/validity
and timestamping EKU against the explicitly configured trust. The CMS signer
must use SHA-256, SHA-384 or SHA-512; legacy SHA-1 evidence is rejected even if
the library can verify it cryptographically. Unverified,
malformed, rejected or late evidence is not advertised or downloadable.
There is no online OCSP/CRL fetching, revocation-status guarantee, archival
renewal or long-term-validation claim; trust provisioning/updates and later
independent assessment remain operator responsibilities.
## What users see and download
Document details keep status `RELEASED` regardless of timestamp outcomes:
- **Signed at**: last sign-off of the current revision, from Signet's server.
Individual parties' decision times remain in the existing route/history.
- **Released**: the existing server release time.
- **Externally timestamped at**: the validated TSA time, never copied from a
server time or displayed before verification.
- **Pending**, **unavailable**, or **not requested**: separate timestamp state,
never a replacement signing/release status. Pending expires at the release
deadline; enabling the scheduler later cannot revive an expired window.
Without a stored record, a configured recent release is pending, a configured
expired release is unavailable, and a disabled feature is not requested.
Previously stored outcomes remain visible even if configuration is disabled.
The pending view has an explicit status-refresh button, not an hour-long poll.
Authorized users can download `GET /api/docs/<UUID>/file/timestamp` as
`timestamp.tsr`, MIME `application/timestamp-reply`. Authorization is the same
as for that document's final PDF. This is the **complete RFC3161 response**,
not a raw CMS token; it is bound to the current released revision and PDF hash.
No original facsimile endpoint or new access grant is introduced.
Keep `final.pdf`, the response and the relevant public trust/chain material
with ordinary coordinated backups. The evidence bytes live in PostgreSQL;
`GET /api/docs/<UUID>` exposes `signed_at`, `timestamp_status`,
`timestamp_attempts` and `timestamped_at`, not a replacement PDF or retry API.
On a separate verification machine with the OpenSSL command-line tools already
available, a full-response check can use:
```sh
openssl ts -verify -in timestamp.tsr -data final.pdf -CAfile tsa-trust.pem
```
Independent verification needs the appropriate trust/chain and a deliberate
validation policy. Do not silently treat any certificate embedded in a response
as a trust anchor. Changing PDF bytes breaks this evidence. Keep its original
hash and bytes; do not append the token/audit note to the released PDF.
## Development checks
Only explicitly disposable stacks; these create synthetic documents/decisions
and isolate synthetic released-document evidence from other fixture jobs:
```sh
podman exec signet sh /src/test/e2e.sh timestamp-contract
podman exec signet env SIGNET_TIMESTAMP_TEST_CRON=yes SIGNET_TIMESTAMP_TEST_RSS=yes \
sh /src/test/e2e.sh timestamp-contract
```
The first is also part of full E2E. A local native HTTPS TSA creates ephemeral
keys in memory; only public CA certificates and synthetic protocol replies
are temporary files. Tests cover valid evidence; wrong imprint/nonce/signature;
expired/untrusted signer and HTTPS trust; SHA-1 refusal and SHA-2 support;
malformed/oversized/rejected/HTTP-failure replies;
HTTP refusal/timeouts; four attempts; crash-slot consumption/restarts; missed deadline; overlapping
runners; migration preservation/repeatability/grants; authorized download; original
PDF hash and sign-off preservation; and another document releasing while a TSA
request is held. The optional scheduler check uses real disposable cron without
changing host/VM time. Optional RSS sampling is a non-atomic Linux `/proc` cohort
sample, not native aggregate/adversarial resource certification.
No live TSA, preserved preview, native deployment or browser acceptance is
implied by these fixture checks. Ticket20's parser-overlap/native resource gates
remain open independently of timestamping. Disable the cron entry to stop future
work; retain existing evidence/database rows and original PDFs. Do not delete
history or blindly restore an old database after newer document activity.