On this page
Signing with your own database¶
Requires the Beta 9 release candidate or a newer server. If you installed Beta 7, start with the PostgreSQL signing pilot.
PressJet can run a multi-signer agreement without keeping any of it. Your application stores each
agreement, called an envelope, in its own database: PostgreSQL, MySQL, MongoDB or any store that
can save a JSON value under a key with a version check. It calls the stateless /v1/signing/* routes
of an ordinary pressjet serve through an SDK, or runs the same steps in-process with the
Rust SDK. Every envelope PressJet returns is sealed
with a key that only the PressJet server holds, so a copy changed in your database is refused.
The other way to sign is the native signing pilot, pressjet signing serve. It keeps
the agreements in its own PostgreSQL, sends the emails and serves the sender and signer pages.
Choose your own database when you already have users, email and storage, want the signing records
next to your own data, or want to sign your own PDFs with drawn signatures.
Pilot: pressjet signing serve |
Your own database | |
|---|---|---|
| Where agreements live | PressJet's PostgreSQL | Your database, any engine |
| What runs | The pilot server, its mail worker and its closing worker | An ordinary pressjet serve, or nothing extra with the Rust SDK |
| Sender and signer pages | Built in, or yours on the pilot's API | Yours |
| Emails | Sent by the mail worker | Sent by you, from the effects PressJet returns |
| Documents | Templates from the registry | Templates, or your own PDF with signature boxes |
| Signatures | Typed name and initials | Typed, or a drawn PNG |
| After completion | Download the sealed PDF and evidence | Also void the agreement and issue a VOIDED copy |
| The signer's IP address and browser | Seen by PressJet on the connection | Reported by your application |
| Evidence format | pressjet-signing-evidence-v1 |
pressjet-signing-evidence-v2 |
The Python, TypeScript, Go and PHP SDKs each have a signing group with the same eleven methods. The Rust SDK runs the same steps in-process:
| SDK | Group | Reference |
|---|---|---|
| Python | client.signing (coroutines on AsyncClient) |
Python SDK |
| TypeScript | pressjet.signing |
TypeScript SDK |
| Go | client.Signing() |
Go SDK |
| PHP | $client->signing() |
PHP SDK |
| Rust, in-process | pressjet::signing and four Renderer methods |
Rust SDK |
The server needs a key ring (PRESSJET_SIGNING_KEYS), a certificate for seal and void-copy, and
your application needs a secret API key with the signing permission. See
Envelope signing keys. The samples on this page use Python.
import json
import pressjet
client = pressjet.Client(api_key=api_key, base_url="https://pressjet.internal:8080")
The flow¶
prepare ──▶ open ──▶ view ─▶ decide ──▶ seal ──▶ void (optional)
└─ once per signer ─┘
in signing order
Every call that changes the envelope returns a transition: the new envelope, the new events
and the effects you now owe, such as an invitation to send. You save the first two, then perform
the third.
| Step | You send | You store |
|---|---|---|
prepare |
A template id and its data, or your PDF and its signature boxes | The revision, as the JSON you received. The PDF, by its SHA-256. |
open |
The revision and one email address per signer, in signing order | The new envelope, only if it does not exist yet, and its first event. Then send the invitation. |
view |
The stored envelope and the signer's invitation token | Nothing. It only reads. |
decide |
The stored envelope, the token, the decision, the signer's IP address and browser, a drawn PNG if any | The PNG, by its hash. The new envelope, only if the stored version is the one you loaded, and the new event. Then the effects. |
seal |
The stored envelope, the PDF and every drawn PNG | The sealed PDF and the evidence, by hash. The new envelope and event. Then the completion notices. |
void |
The stored envelope and a reason | The new envelope and event. |
revoke stops an open envelope and is stored like decide. void-copy returns a PDF marked VOIDED
and changes nothing. effects recomputes what you owe. verify checks a stored envelope and its
events.
Prepare¶
from hashlib import sha256
pdf = open("agreement.pdf", "rb").read()
revision = client.signing.prepare_pdf(pdf, [
{"role": "cliente", "mark": "signature", "page": 1, "x": 72, "y": 640, "width": 180, "height": 40},
{"role": "empresa", "mark": "signature", "page": 1, "x": 320, "y": 640, "width": 180, "height": 40},
])
files.put(sha256(pdf).hexdigest(), pdf) # your file storage
revision_text = json.dumps(revision) # keep it as JSON text until you open it
For a template of the server's registry, client.signing.prepare_template("servicio", data) returns
the revision and the PDF it rendered; keep that PDF. Store the revision as text, the way you store
the envelope: never rebuild it through your own classes. open checks its seal.
Other SDKs: TypeScript · Go · PHP · Rust
Open¶
opened = client.signing.open(json.loads(revision_text), ["ana@example.com", "luis@example.com"])
if save_new(opened): # insert only if absent; see the recipes below
perform(opened.effects) # the first invitation
Without expires_at, the envelope stays open seven days; the latest is 365 days from now. Opening
the same revision twice gives the same envelope id, so the second insert finds the first envelope.
Load it instead of creating another.
View and decide¶
Your signer page sends you the token. The part before the first . is the envelope id, so you can
load the envelope from the token alone.
envelope_id = token.split(".", 1)[0]
envelope = load(envelope_id)
view = client.signing.view(envelope, token)
# Show the PDF, the boxes in view["fields"] and the consent text view["consent"].
decided = client.signing.decide(
envelope,
token,
{
"action": "accept",
"name": "Ana Ruiz",
"revisionId": view["revisionId"],
"pdfSha256": view["pdfSha256"],
"priorAcceptanceId": (view["priorAcceptance"] or {}).get("receiptId"),
"consentVersion": view["consentVersion"],
"consent": True,
},
client={"ipAddress": ip_address, "userAgent": user_agent},
)
if decided.transition is not None: # None: the same decision was already recorded
if save_next(decided.transition, envelope["version"]):
perform(decided.transition.effects)
When save_next reports a conflict, follow the retry loop below.
Other SDKs: TypeScript · Go · PHP · Rust
Seal¶
When the last signer accepts, the envelope is finalizing and the transition carries a seal
effect.
envelope = load(envelope_id)
pdf = files.get(envelope["revision"]["pdfSha256"])
images = [files.get(digest) for digest in drawn_image_hashes(envelope)]
sealed = client.signing.seal(envelope, pdf, images=images)
files.put(sha256(sealed.pdf).hexdigest(), sealed.pdf)
files.put(sha256(sealed.evidence).hexdigest(), sealed.evidence)
if save_next(sealed.transition, envelope["version"]):
perform(sealed.transition.effects) # the completion notices
drawn_image_hashes collects the signatureImageSha256 and initialsImageSha256 of the
participants' decisions. If the answer is lost before you save it, call seal again: the envelope
is still finalizing. The saved envelope's final member names the hashes of the sealed PDF and
evidence that count; a pair from a call whose save lost is not part of the agreement.
Other SDKs: TypeScript · Go · PHP · Rust
The storage contract¶
This is everything PressJet asks of your database.
- Save the returned envelope under its
envelopeId, but only if the storedversionis the one you loaded. For a new envelope, save it only if none exists. On a mismatch, reload and repeat the call.
If you skip the check, two calls that loaded the same version both save, and the second
overwrites the first: an acceptance or a revocation disappears without an error. A second open
of the same revision overwrites an envelope that signers have already acted on.
2. Append the returned events, unique on (envelopeId, seq), in the same transaction as the
envelope. This is optional and recommended.
If you skip it, you have no history: verify can check the envelope's seal but not how it got
there, and the sealed agreement cannot be checked offline with --events. If you save the events
outside the envelope's transaction, a crash leaves a gap in the chain, and verify answers
event_chain_broken.
3. Then perform the returned effects. They can always be recomputed from the envelope with
effects, so a crash between saving and performing loses nothing.
If you perform them before saving, a signer can receive an invitation for a state you failed to store. If you never perform them, the next signer is never invited and the envelope waits until it expires. 4. Keep the files by hash: the PDF to sign, every drawn signature image, then the sealed PDF and the evidence. PressJet keeps none of them.
If you lose one, seal cannot run: it needs the exact PDF (revision_hash_mismatch for any
other) and every drawn image (signature_image_missing). Losing the sealed PDF or the evidence
loses the proof of the agreement.
What you may do with the stored envelope¶
Store the envelope, the revision and each event as the JSON PressJet returned. In Python they arrive
as parsed dicts: store json.dumps(value), load with json.loads(text), and pass the dict back.
Never rebuild them from your own classes, and keep your own data in columns beside the envelope,
not inside it.
You may store the envelope whole, as one JSON value, or split it across columns. Your database may
reorder keys, change whitespace and respell numbers: PostgreSQL jsonb and MySQL JSON reorder
keys and change whitespace, and the seal still verifies. The seal covers the values, not the text.
An instant may come back in any RFC 3339 spelling, so a date column works if it keeps milliseconds
and gives back the same instant.
What breaks the seal is changing a value. A changed value makes the next call answer
envelope_seal_invalid. Avoid these:
| Change | How it happens |
|---|---|
| Changing a value | Editing a status, an email or a name in the database. |
| Dropping a member | A class, ORM mapping or serializer that ignores members it does not know, or leaves out nulls. |
| Instants with less than millisecond precision | Moving createdAt or acceptedAt into a date column that keeps only seconds. |
Padded CHAR |
A fixed-width CHAR(n) column that pads shorter text with spaces. |
| Trimming | A layer that strips leading or trailing spaces from text. |
| A case-folding collation on ids | Ids are case-sensitive. A collation that compares them without case can treat two envelopes as one, or load the wrong one. Use a binary collation. |
PHP decoding {} as [] |
json_decode($json, true) turns an empty object into an empty array. See the PHP SDK. |
Recipes¶
These schemas and statements were run end to end by
scripts/check-signing-recipes.py on PostgreSQL 18, MySQL 9
and MongoDB 8. The script prepares a PDF for two signers, opens it, records one drawn and one typed
signature, seals it and verifies the stored envelope with its events. Before each call it reads the
envelope back from the database's own JSON output. It also replays a stale version and checks that
nothing changes. Its header shows how to run it against a PressJet server; add --postgres-url,
--mysql-url or --mongodb-url to test your own database instead of a fresh container.
PostgreSQL¶
CREATE TABLE IF NOT EXISTS envelopes (
id text PRIMARY KEY,
version integer NOT NULL,
body jsonb NOT NULL
);
CREATE TABLE IF NOT EXISTS events (
envelope_id text NOT NULL REFERENCES envelopes (id),
seq integer NOT NULL,
body jsonb NOT NULL,
UNIQUE (envelope_id, seq)
);
| Purpose | Statement |
|---|---|
| Open: insert if absent | INSERT INTO envelopes (id, version, body) VALUES (%s, %s, %s::jsonb) ON CONFLICT (id) DO NOTHING |
| Advance: save if the version matches | UPDATE envelopes SET version = %s, body = %s::jsonb WHERE id = %s AND version = %s |
| Append an event | INSERT INTO events (envelope_id, seq, body) VALUES (%s, %s, %s::jsonb) |
| Load the envelope | SELECT body::text FROM envelopes WHERE id = %s |
| Load the events | SELECT body::text FROM events WHERE envelope_id = %s ORDER BY seq |
With psycopg 3, in autocommit mode with each write in its own transaction:
import psycopg
conn = psycopg.connect(database_url, autocommit=True)
def write(statement, params, transition):
envelope = transition.envelope
with conn.transaction(), conn.cursor() as cur:
cur.execute(statement, params)
saved = cur.rowcount == 1 # read before the events are appended
if saved:
for event in transition.events:
cur.execute("INSERT INTO events (envelope_id, seq, body) VALUES (%s, %s, %s::jsonb)",
(envelope["envelopeId"], event["seq"], json.dumps(event)))
return saved
def save_new(transition):
e = transition.envelope
return write("INSERT INTO envelopes (id, version, body) VALUES (%s, %s, %s::jsonb) "
"ON CONFLICT (id) DO NOTHING",
(e["envelopeId"], e["version"], json.dumps(e)), transition)
def save_next(transition, loaded_version):
e = transition.envelope
return write("UPDATE envelopes SET version = %s, body = %s::jsonb WHERE id = %s AND version = %s",
(e["version"], json.dumps(e), e["envelopeId"], loaded_version), transition)
def load(envelope_id):
row = conn.execute("SELECT body::text FROM envelopes WHERE id = %s", (envelope_id,)).fetchone()
return json.loads(row[0])
save_new returning False means the envelope was already opened: load it. save_next returning
False is a version conflict. At the default isolation level, READ COMMITTED, a conflict shows as
zero rows. At REPEATABLE READ or SERIALIZABLE, PostgreSQL may instead fail the transaction with
SQLSTATE 40001; treat that the same way.
MySQL¶
CREATE TABLE IF NOT EXISTS envelopes (
id VARCHAR(64) CHARACTER SET ascii COLLATE ascii_bin PRIMARY KEY,
version INT NOT NULL,
body JSON NOT NULL
);
CREATE TABLE IF NOT EXISTS events (
envelope_id VARCHAR(64) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
seq INT NOT NULL,
body JSON NOT NULL,
UNIQUE KEY events_envelope_seq (envelope_id, seq),
FOREIGN KEY (envelope_id) REFERENCES envelopes (id)
);
| Purpose | Statement |
|---|---|
| Open: insert | INSERT INTO envelopes (id, version, body) VALUES (%s, %s, %s) |
| Advance: save if the version matches | UPDATE envelopes SET version = %s, body = %s WHERE id = %s AND version = %s |
| Append an event | INSERT INTO events (envelope_id, seq, body) VALUES (%s, %s, %s) |
| Load the envelope | SELECT CAST(body AS CHAR) FROM envelopes WHERE id = %s |
| Load the events | SELECT CAST(body AS CHAR) FROM events WHERE envelope_id = %s ORDER BY seq |
- Ids use
ascii_bin, a binary collation. The default collation compares text without case, and two ids can differ only in case. - Open with a plain
INSERT. Catch only the duplicate-key error1062, which means the envelope was already opened: load it. Never useINSERT IGNORE. It turns other errors into warnings too, so a failed insert would look like an existing envelope. - Transactions. The recipe uses pymysql with
charset="utf8mb4"and autocommit off. It commits or rolls back each write explicitly, and inserts the events only when the envelope statement changed one row. It ends each read with a commit, so the next read sees later commits. - Deadlocks. MySQL may fail a write with error
1213. Roll back, then reload and repeat the call as for a version conflict.
MongoDB¶
Keep one document per envelope, with its events inside: {_id, envelope, events: [...]}. A
single-document write is atomic even on a standalone server, so the envelope and its events can
never disagree. Advance with one update_one that sets the envelope and pushes the events, guarded
by envelope.version. Because seq equals the version, that guard keeps the events unique, and
replaces the unique (envelopeId, seq) index of the SQL recipes. An envelope has at most 35 events
of a few kilobytes each.
from pymongo import MongoClient
from pymongo.errors import DuplicateKeyError
envelopes = MongoClient(mongodb_url)["app"]["envelopes"]
def save_new(transition):
e = transition.envelope
try:
envelopes.insert_one({"_id": e["envelopeId"], "envelope": e, "events": transition.events})
except DuplicateKeyError:
return False # already opened: load the existing envelope
return True
def save_next(transition, loaded_version):
e = transition.envelope
result = envelopes.update_one(
{"_id": e["envelopeId"], "envelope.version": loaded_version},
{"$set": {"envelope": e}, "$push": {"events": {"$each": transition.events}}})
return result.matched_count == 1 # 0: a version conflict
def load(envelope_id):
return envelopes.find_one({"_id": envelope_id})["envelope"]
Read the events from doc["events"], sorted by seq. The script sent back MongoDB's own JSON of
the stored sub-document (bson.json_util.dumps in relaxed mode); passing the dict that find_one
returns sends the same values.
A separate events collection is safe only on a replica set, with both writes inside one
with_transaction. On a standalone server, two separate writes can leave the envelope and its
events disagreeing after a crash.
Concurrency¶
Two requests can act on the same envelope at once, for example a signer's acceptance and your revocation. The version guard lets one win. The other must reload the stored envelope and repeat its call, which then answers for the new state:
def advance(envelope_id, call):
"""Run `call` on the stored envelope and save its transition; repeat on a conflict."""
for _ in range(10):
envelope = load(envelope_id)
transition = call(envelope)
if transition is None: # an identical decision was already recorded
return None
if save_next(transition, envelope["version"]):
perform(transition.effects)
return transition
# Someone saved a newer version first: reload and repeat.
raise RuntimeError("the envelope keeps changing; try again later")
advance(envelope_id, lambda envelope: client.signing.revoke(envelope))
Treat PostgreSQL's SQLSTATE 40001 and MySQL's deadlock 1213 as a conflict too: roll back and go
round the loop again. Bound the loop, as above: ten rounds are plenty, and an envelope that keeps
changing is better reported to the caller than retried forever. Repeating a call is safe, because the routes keep no state.
Effects¶
An effect is something your application owes. Each has a stable effectId. Record the ids you
performed, and skip an effect whose id you already have.
kind |
Members | What to do | When it is due |
|---|---|---|---|
invite |
participantId, role, email, token |
Send that signer a link to your signer page carrying the token. | While the envelope is open and not expired, for the next signer who has not decided. |
seal |
none | Call seal. |
While the envelope is finalizing. |
notifyCompletion |
participantId, role, email |
Tell that signer the agreement is complete. | Once the envelope is available, one per signer. |
A seal effect is done only once the sealed envelope is saved, not when seal answers: keep the
sealed PDF, the evidence and the new envelope, and save the envelope with the version check. If
effects still lists seal, sealing is still due, whatever you did before.
The invitation token is a bearer secret: whoever holds it can sign as that signer.
- Send it to that signer only.
- Put it in the URL fragment, for example
https://app.example.com/sign#<token>. Browsers do not send the fragment to servers, so it stays out of access logs andRefererheaders. - Never log it.
Effects can always be recomputed. client.signing.effects(envelope) returns what the envelope
calls for now, with the same ids. Run it from a periodic job to recover from a crash between saving
and performing. To remind a signer, send the same link again on purpose; the effectId does not
change.
The signer's page¶
You build the page; PressJet decides what it may show and accept. view returns:
| Member | Meaning |
|---|---|
status |
open, declined, revoked, finalizing, available, voided, or expired for an open envelope past its expiry |
revisionId, pdfSha256 |
Which document this is; send both back in the decision |
fields, pages |
The signature boxes of the whole document, and each page's size |
role |
The role this token signs for |
decision |
This signer's receipt, once they have decided |
priorAcceptance |
The earlier signer's acceptance (receiptId, name, role), to show and send back as priorAcceptanceId |
consent, consentVersion |
The consent text to show next to the checkbox, and its version to send back |
Placing the boxes. A box's x, y, width and height are points from the top-left corner of
its page, as rasterize draws the page. Rasterize the PDF at a scale and multiply:
scale = 1.5
raster = client.rasterize(pdf, {"scale": scale})
for box in view["fields"]:
image = raster.pages[box["page"] - 1] # PageImage: png, width, height in pixels
left, top = box["x"] * scale, box["y"] * scale
width, height = box["width"] * scale, box["height"] * scale
Drawn signatures. Pass a PNG as signature_image (and initials_image) to decide. Each image
is at most 128 KiB and 1,000,000 pixels, or the call answers signature_image_invalid. The receipt
records the image's SHA-256 as signatureImageSha256 or initialsImageSha256. PressJet keeps no
image, so store the PNG by that hash and send it again to seal in images, in any order. Without
it, seal answers signature_image_missing. The typed name is still required; with a drawn
signature it is recorded, not drawn.
decided = client.signing.decide(envelope, token, decision,
client={"ipAddress": ip_address, "userAgent": user_agent},
signature_image=png)
files.put(sha256(png).hexdigest(), png)
Declining. Send "action": "decline" with "consent": False, the same revisionId, pdfSha256
and priorAcceptanceId, and no name, initials, consent version or image.
examples/signing/custom-ui is a signer page written for the
pilot. Its review, consent and name steps carry over. In this mode, point its requests at your own
backend, which loads the envelope and calls view and decide.
examples/signing/own-database is a complete runnable app: a
signer page, SQLite storage that follows the contract, and the effects, on the Python SDK.
Other SDKs: TypeScript · Go · PHP · Rust
Your own PDFs¶
prepare_pdf takes a PDF and its signature boxes. PressJet reads the PDF and never rewrites, returns
or keeps it. The revision's pdfSha256 is the hash of exactly the bytes you sent, so a document you
have already archived keeps the hash you recorded.
The PDF is at most 16 MiB and within the server's page limit. It is refused when it:
- carries a signature, a timestamp, a filled signature field or a permissions dictionary
(
pdf_already_signed), because drawing on it would break that signature; - has interactive form fields (
pdf_has_form_fields); flatten the form first; - is encrypted, even with an empty password, damaged or needs repair (
invalid_document).
Each box is {role, mark, page, x, y, width, height}. Measure it from the top-left of the
page as /v1/rasterize draws it. See Placing the boxes.
A box that breaks a rule answers signing_field_invalid, and detail names it.
- Roles.
clienteis signer 1,empresasigner 2, andsigner-Nsigner N, up to 32. Signers are numbered from 1 with no gaps and sign in that order.clienteneedsempresa. - Marks.
signatureorinitials. Every signer needs at least onesignaturebox. - Sizes. A signature box is at least 100 by 20 points, an initials box 44 by 20.
- Placement. Every box lies inside its page and overlaps no other box. At most 256 boxes.
Voiding¶
There are two separate things.
Voiding a completed agreement. client.signing.void(envelope, reason) moves an available
envelope to voided. Store it like any transition; no effects follow. The reason is plain text of at
most 256 characters. The evidence signed at sealing is not rewritten; the voiding is recorded in the
envelope and its event. Who may void, and when, is your business rule. To stop an agreement that is
still open, use revoke instead.
A VOIDED copy. client.signing.void_copy(envelope, pdf, label="VOIDED") returns the PDF with a
diagonal watermark on every page, certified with the server's certificate. The envelope must be
declined, revoked, expired or voided. An available envelope must be voided first; otherwise the
call answers envelope_closed. The PDF is the one being signed, or for a voided agreement the
sealed one. The label is Latin-1 text of up to 24 characters, VOIDED by default. The call changes
nothing, so you can repeat it.
voided = advance(envelope_id, lambda envelope: client.signing.void(envelope, "Replaced by contract 2027-014"))
copy = client.signing.void_copy(voided.envelope, sealed_pdf, label="ANULADO")
Errors you will meet¶
Every refusal raises pressjet.APIError with a stable code. The full list is in
Error codes.
| Code | What happened | What to do |
|---|---|---|
envelope_seal_invalid |
The stored envelope or revision has a changed value, or was sealed with a key this server does not hold. | Find what changed it in your storage (see what you may do). After a key rotation, keep the old key id in the ring. |
clock_behind |
The server's clock, or the replica that answered, is earlier than an instant the envelope records. | Fix the clock (NTP on every replica), then repeat the call. It is transient. |
envelope_expired |
The envelope is open but past its expiry. | Prepare the document again and open the new revision. Issue a VOIDED copy of the old one if needed. |
decision_already_recorded |
This signer already decided differently. | Nothing; the first decision stands. Show the signer a fresh view. |
signature_image_missing |
seal did not get a drawn image whose hash a receipt records. |
Load every PNG named by the receipts from your storage and send them in images. |
| A version conflict in your database | Another call saved a newer version first: zero rows, matched_count 0, SQLSTATE 40001 or MySQL 1213. |
Reload the stored envelope and repeat the call. See Concurrency. |
An identical repeat of a decision is not an error: decide returns the stored receipt and no
transition.
What is guaranteed¶
PressJet rejects a stored envelope or event that was changed without the signing key, and the sealed PDF and evidence fix the final history under the organisation's certificate. In this mode PressJet does not witness the signer: your application reports who accepted, from where and when the request arrived. PressJet cannot detect an older, valid copy of an envelope restored before sealing, nor any change by someone who holds both the database and the key. Keep the key in the PressJet server, away from the database.
After sealing you hold two files:
- The sealed PDF, with every signer's marks drawn and one certification by the organisation's certificate covering the whole file.
- The evidence, a CMS file signed by the same certificate. It holds the
pressjet-signing-evidence-v2JSON: the envelope and revision ids, the hash of the PDF the signers reviewed, the signature boxes, each acceptance receipt, the hash of the last event before sealing (chainHead) and the hash of the sealed PDF. It records"custody": "integrator", and each receipt's IP address and browser carryipAddressSource: "integrator", because your application reported them. Drawn signatures appear as hashes.
Check both offline, with no PressJet server and no signing key.
scripts/verify_signing_agreement.py needs the
dependencies of scripts/verify_recipient_pdf.py, OpenSSL and your certificate's public root.
events.json is a JSON array of every stored event of the envelope, in seq order.
python3 scripts/verify_signing_agreement.py signed-agreement.pdf signing-evidence.p7m \
--trust-anchor root.pem --original agreement.pdf --events events.json
It checks that the PDF has one trusted certification, that the evidence is signed by the same
certificate and names this PDF, and that the original matches the reviewed hash. With --events
it also checks the event chain: each event links to the previous hash, the chain head matches the
evidence, the accepted events match the receipts, and the sealed event records the hashes of this
PDF and this evidence. Only a single voided event may follow it.
To check a stored envelope's seal and events at any time, before or after sealing, call
client.signing.verify(envelope, events=events). That check runs on the server, which holds the key.
An empty event list is checked too: it is refused with event_chain_broken for any envelope that has
events. To check the seal alone, leave events out (VerifySeal in Go).
Operating it¶
The key ring, its rotation, the server clock and the load that signing puts on the worker pool are covered in Self-hosting: Envelope signing keys. Request size limits for large PDFs and many drawn images are covered there too.