Why I built a self-hosted signing service for Habivelle, what makes its signatures checkable without it, and a step-by-step walkthrough from inkless serve to a tamper test.
An e-signature integration can look finished long before anyone asks it to prove a signature.
Day one: you need clients to sign a contract online. You pick a signing vendor, paste in an API key, and wire up a webhook. A client clicks a link, draws a squiggle, and a PDF with a green tick comes back. You feel very modern.
Day ninety: you store the PDF next to the deal. Somewhere in the vendor's dashboard sits an audit trail you have never opened.
Day seven hundred: there is a dispute. Someone says they never signed. Your lawyer asks a simple question: "Can you prove it?"
If you kept only the PDF and the vendor kept the audit trail, you may have to retrieve that evidence through their dashboard, subject to their retention policy and your subscription. And if they have gone out of business or changed their API, good luck.
That is the problem I wanted to avoid when we added offers and contracts to Habivelle, a property CRM we are building. The result is Inkless, an open-source, self-hosted signing service written in Go. The source is on GitHub under the Apache 2.0 license, and the package is on pkg.go.dev.
First, what Inkless is and why I built it this way. Then we'll send a lease to two signers, sign it, and verify the result offline. Finally, we'll change one bit and watch verification fail.
What is Inkless?
Your application uploads a PDF and names the signers. Inkless runs the signing ceremony: each signer reviews the document, gives consent, confirms a code sent to their email, then signs or declines. When everyone has signed, Inkless seals the final PDF with a PAdES signature and an RFC 3161 timestamp, and builds an evidence package.
Anyone holding the operator's published trust data can verify the package without contacting Inkless. No API call, no dashboard, no account. With the same files and trust data, a verifier on a laptop with no network gets the same answer as one sitting next to the server.
Your application
|
API (v1) and webhooks
|
Inkless ------------ Signer
| (link, email code, consent)
+-------------+-------------+
| | |
Database Signing key Timestamp
SQLite, AWS KMS authority
Postgres,
MySQL
|
final.pdf + evidence.zip
|
inkless verify (offline)
At a glance
- Language: Go 1.27, distributed as a single binary
- Storage: SQLite by default, or PostgreSQL or MySQL; documents on disk or S3
- Seal: PAdES baseline B-T with an RFC 3161 timestamp, key in AWS KMS
- Integration: a versioned HTTP API, a Go client, Standard Webhooks
- Verification: an
inkless verifycommand and a Go package, both fully offline - Distribution:
go install, a signed multi-arch Docker image, release binaries
Why a separate project?
In Habivelle, agents and property developers needed to invite clients, prepare offers and contracts from CRM data, and get them signed. The easy route was to build signing into the CRM.
I didn't take it, for one reason: a signature has to outlive the software that made it. Contacts, deals and templates change all the time. A signed contract must not change at all, and its proof must survive the CRM being rewritten, migrated or retired.
So the boundary became the design. Habivelle owns organisations, clients, templates and who can see which file. Inkless owns signing requests, consent, signing state and evidence. Inkless knows nothing about properties, deals or real estate. Any application can use it the same way Habivelle does.
Why does a signing service need a database and an inbox?
That was my own question, halfway through the build. If the application already knows who its user is, why can't it just tell Inkless "this is Alex, let them sign"?
Inkless uses the application's statement about the user, called an assertion, to open a session. The signer must then enter a six-digit code sent to their own email address. For an already-issued request, the application assertion alone can't satisfy that challenge. Inkless also keeps its own hash-chained record of the ceremony, outside the integrating application's records.
That sets the limit of the claim. Inkless records that a session opened with an application assertion and that someone with access to the signer's inbox completed the challenge. The project calls this an email-verified simple electronic signature. Whether that is enough for a given contract in a given country is a question for a lawyer, not for a Go binary.
Step 0: Install
Use Go 1.27 or newer. With automatic toolchain selection enabled, a compatible Go installation can download the required version.
go install github.com/edgar4/inkless/cmd/inkless@v0.1.0
For this walkthrough, run Inkless directly on your machine so it can deliver webhooks to the local demo app. If you just want to try the signing UI in containers, check out the repository at v0.1.0 and run docker compose up. Inkless listens on port 8080 and Mailpit on port 8025. Signed release images are available at ghcr.io/edgar4/inkless.
Step 1: Start the server
mkdir inkless-demo && cd inkless-demo
inkless serve
That's it. No config file, no environment variables, no database to create.
{"level":"INFO","msg":"listening","addr":"127.0.0.1:8080","public_url":"http://127.0.0.1:8080","mode":"development (synthetic keys; not for real documents)"}
With nothing configured, Inkless runs in development mode: SQLite in inkless.db, documents in ./blobs, synthetic signing keys, a built-in test timestamp authority, and email codes written to the log instead of sent. Use a synthetic document for this walkthrough.
If port 8080 is taken, start the server with INKLESS_ADDR=127.0.0.1:18080 inkless serve and update INKLESS_URL in Step 3.
Step 2: Register your application
Leave the server running. In a second terminal, in the same folder:
inkless apps create -name "Acme Lettings (dev)" \
-origin http://localhost:3000 \
-webhook-url http://localhost:3000/hooks/inkless
{
"application_id": "app_hdg3m2lnylbzpfmuxefjl7yh",
"api_key": "…",
"webhook_secret": "…"
}
The API key and webhook secret are printed once. Store them securely. You can rotate them with inkless apps rotate-key and inkless apps rotate-secret.
The -origin flag limits the return URL to an origin you registered. After signing, Inkless can send the signer back to your app there.
Step 3: Create the app that sends a lease
Our pretend product is Acme Lettings. A landlord and a tenant need to sign a lease, landlord first. From the inkless-demo directory, create the example project:
mkdir acme && cd acme
go mod init example.com/acme
go get github.com/edgar4/inkless@v0.1.0
Use the synthetic PDF from the release for this walkthrough. The tamper test below uses a byte offset within this fixture.
curl -fsSL -o fixture.zip https://github.com/edgar4/inkless/raw/v0.1.0/testdata/fixture/evidence.zip
unzip -p fixture.zip original.pdf > lease.pdf
Save the following program as main.go. It serves a local demo with synthetic signers. Keep it on loopback and use it with test documents.
package main
import (
"context"
"errors"
"fmt"
"io"
"log"
"net/http"
"os"
"sync"
"time"
"github.com/edgar4/inkless/client"
)
const appURL = "http://localhost:3000"
var signers = []client.SignerInput{
{Ref: "landlord", Name: "Alex Example", Email: "alex@example.test", Order: 1},
{Ref: "tenant", Name: "Sam Sample", Email: "sam@example.test", Order: 2},
}
type app struct {
ink *client.Client
secrets []string
mu sync.Mutex
lastSeq map[string]int64
}
func main() {
a := &app{
ink: client.New(os.Getenv("INKLESS_URL"), os.Getenv("INKLESS_API_KEY")),
secrets: []string{os.Getenv("INKLESS_WEBHOOK_SECRET")},
lastSeq: map[string]int64{},
}
id, err := a.sendLease(context.Background(), "lease.pdf")
if err != nil {
log.Fatal(err)
}
log.Printf("issued %s", id)
mux := http.NewServeMux()
mux.HandleFunc("GET /sign/{request}/{signer}", a.sign)
mux.HandleFunc("POST /hooks/inkless", a.webhook)
mux.HandleFunc("GET /done", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Thanks. Outcome: %s\n", r.URL.Query().Get("outcome"))
})
srv := &http.Server{Addr: "localhost:3000", Handler: mux, ReadHeaderTimeout: 10 * time.Second}
log.Fatal(srv.ListenAndServe())
}
func (a *app) sendLease(ctx context.Context, path string) (string, error) {
pdf, err := os.ReadFile(path)
if err != nil {
return "", err
}
doc, err := a.ink.UploadDocument(ctx, pdf, client.IdempotencyKey())
if err != nil {
return "", fmt.Errorf("upload: %w", err)
}
req, err := a.ink.CreateSigningRequest(ctx, client.CreateSigningRequest{
DocumentID: doc.ID,
Routing: client.RoutingSequential,
ExpiresAt: time.Now().Add(7 * 24 * time.Hour),
ExternalRef: "lease-42",
Signers: signers,
}, client.IdempotencyKey())
if err != nil {
return "", fmt.Errorf("create request: %w", err)
}
if _, err := a.ink.Issue(ctx, req.ID, client.IdempotencyKey()); err != nil {
return "", fmt.Errorf("issue: %w", err)
}
return req.ID, nil
}
// sign stands in for a page behind your own login. In a real app the
// assertion comes from the logged-in user, never from the URL.
func (a *app) sign(w http.ResponseWriter, r *http.Request) {
ref := r.PathValue("signer")
var who *client.SignerInput
for i := range signers {
if signers[i].Ref == ref {
who = &signers[i]
}
}
if who == nil {
http.NotFound(w, r)
return
}
sess, err := a.ink.CreateSession(r.Context(), r.PathValue("request"), ref, client.CreateSession{
Assertion: client.Assertion{
Subject: "user-" + ref,
Email: who.Email,
Method: "password",
AuthenticatedAt: time.Now(),
},
ReturnURL: appURL + "/done",
}, client.IdempotencyKey())
var apiErr *client.Error
if errors.As(err, &apiErr) {
http.Error(w, apiErr.Message, apiErr.Status)
return
}
if err != nil {
http.Error(w, "inkless unavailable", http.StatusBadGateway)
return
}
http.Redirect(w, r, sess.URL, http.StatusSeeOther)
}
func (a *app) webhook(w http.ResponseWriter, r *http.Request) {
body, err := io.ReadAll(io.LimitReader(r.Body, 1<<20))
if err != nil {
http.Error(w, "read body", http.StatusBadRequest)
return
}
ev, err := client.VerifyWebhook(a.secrets, r.Header, body, time.Now())
if err != nil {
http.Error(w, "invalid signature", http.StatusBadRequest)
return
}
a.mu.Lock()
seen := ev.Sequence <= a.lastSeq[ev.RequestID]
a.mu.Unlock()
if seen {
w.WriteHeader(http.StatusNoContent)
return
}
log.Printf("#%d %s (%s)", ev.Sequence, ev.Type, ev.Request.State)
if ev.Type == client.EventSignerReady {
for _, s := range ev.Request.Signers {
if s.State == client.SignerReady {
log.Printf("%s can sign at %s/sign/%s/%s", s.Name, appURL, ev.RequestID, s.Ref)
}
}
}
if ev.Type == client.EventRequestCompleted {
for _, name := range []string{"final.pdf", "evidence.zip"} {
data, err := a.ink.Artifact(r.Context(), ev.RequestID, name)
if err != nil {
http.Error(w, "fetch artifact", http.StatusBadGateway)
return
}
if err := os.WriteFile(name, data, 0o600); err != nil {
http.Error(w, "save artifact", http.StatusInternalServerError)
return
}
log.Printf("saved %s (%d bytes)", name, len(data))
}
}
a.mu.Lock()
a.lastSeq[ev.RequestID] = ev.Sequence
a.mu.Unlock()
w.WriteHeader(http.StatusNoContent)
}
Run it with the values from Step 2:
export INKLESS_URL=http://127.0.0.1:8080
export INKLESS_API_KEY=...
export INKLESS_WEBHOOK_SECRET=...
go run .
Example output. The request ID will differ.
issued req_oanbnc2gj326ujvghopqfeyc
#1 request.issued (issued)
#2 signer.ready (issued)
Alex Example can sign at http://localhost:3000/sign/req_oanbnc2gj326ujvghopqfeyc/landlord
Three things in sendLease deserve a closer look.
Every call that creates something takes an idempotency key. Networks fail at the worst moment. If the upload succeeds but the response never arrives, retry with the same key to get the first result back. client.IdempotencyKey() makes a fresh one. In production, store the key alongside the operation so a retry after a crash can reuse it.
Routing: client.RoutingSequential means the tenant can't sign until the landlord has. Use client.RoutingParallel when order doesn't matter.
Issue freezes the document, signers, and expiry. If something is wrong, revoke the request and send a new one. A signer must never sign a document that changed after they were asked.
Step 4: Sign as the landlord
Open the link from the log in a browser. Here is what happens, in order.
Your
/signhandler callsCreateSessionwith an assertion for the demo useruser-landlord, with emailalex@example.testand an authentication method ofpassword. Inkless refuses if that email doesn't match the signer's email. It returns a single-use link that expires in 10 minutes, and you redirect the browser to it.The link opens a page with a Start button. Only pressing it uses up the link. A mail scanner or link preview can open the page without consuming the link before the human sees it. That one was found the hard way.
Inkless offers to email a code. In development mode, the code goes to the server log:
{"level":"INFO","msg":"dev mail (not sent)","to":"a***@example.test","code":"641026"}After entering the code, the signer reviews the document, with its SHA-256 fingerprint shown on the page, ticks "I agree", and presses Sign.
A finished page links back to your
/doneURL with?outcome=signed. Treat that redirect as a hint for the UI. Use the signed webhook or the request API to confirm the outcome.
Meanwhile, your app's log fills in:
#3 signer.viewed (issued)
#4 signer.signed (issued)
#5 signer.ready (partially_signed)
Sam Sample can sign at http://localhost:3000/sign/req_oanbnc2gj326ujvghopqfeyc/tenant
Now open the tenant's link and do the same as Sam. When the last signature lands, Inkless seals the PDF in the background, and only once the sealed files exist does it send the final event:
#6 signer.viewed (partially_signed)
#7 signer.signed (partially_signed)
#8 request.completed (completed)
saved final.pdf (27159 bytes)
saved evidence.zip (8397 bytes)
Step 5: Verify and reconcile webhooks
client.VerifyWebhook checks the signature using the Standard Webhooks scheme and rejects timestamps outside the allowed window. Signature verification authenticates the event. The timestamp limits how long a captured event can be replayed.
Delivery is at least once, in order, per request. So you will sometimes get the same event twice. The handler ignores any event whose sequence is no higher than the last one it processed for that request.
Notice when it records the sequence: at the very end, after the artifacts are saved. If downloading final.pdf fails, the handler returns an error, Inkless retries later (with backoff, for up to 72 hours), and the retry still has work to do. Record the sequence first and a failed download can become a silently lost contract.
Two things this demo skips that a real integration needs:
- Persist the last processed sequence. Use durable storage so a restart preserves what you've processed. Account for concurrent deliveries when recording progress.
- Reconcile. Webhooks can be lost on your side: a deploy, a bad proxy, a full disk. Poll
ListSigningRequestswith anupdated_sincea few minutes before your last checkpoint, and fix up anything you missed. If you see a gap in sequence numbers,GetSigningRequesttells you the current state. See the integration guide.
Step 6: Verify offline
This is the bit I care about most. Go back to the server folder and export the trust data:
cd ..
inkless keys trust -out trust
That writes four files: root.txt (the thumbprint of the root key that signs the key list), keys.json (the key list itself), seal-ca.pem and tsa-ca.pem (the certificate authorities for the seal and the timestamp). In production, distribute those trust anchors through a channel the verifier already trusts, separate from the evidence package. Publish updated key lists as keys rotate.
Now verify the package. No server is involved; you could turn Inkless off first.
inkless verify -root "$(cat trust/root.txt)" -keys trust/keys.json \
-seal-ca trust/seal-ca.pem -tsa-ca trust/tsa-ca.pem acme/evidence.zip
Inkless verification (package)
package passed manifest digests match for 7 files
evidence passed hash chain intact (8 events); JWS valid under kid "dev-evidence-1" at timestamp 2026-11-29T11:17:47Z
document passed original matches D0, final extends it and matches D1
seal passed sealed by "Inkless Dev Seal (synthetic)" (chain trusted); signature timestamp genTime 2026-11-29T11:17:47Z by "Inkless Dev TSA (synthetic)"; seal key is kid "dev-evidence-1" in the key list
attribution passed 2 of 2 signers have a signed event bound to D0 with consent and a passed challenge (recorded evidence, not proof of identity)
- landlord (Alex Example <alex@example.test>): event 4 at 2026-11-29T11:17:06Z; consent v1 accepted; email_code passed after 1 attempt(s); application assertion method "password"
- tenant (Sam Sample <sam@example.test>): event 7 at 2026-11-29T11:17:47Z; consent v1 accepted; email_code passed after 1 attempt(s); application assertion method "password"
timestamp passed token over SHA-256(evidence.jws): genTime 2026-11-29T11:17:47Z by "Inkless Dev TSA (synthetic)"
Result: passed
Six checks, reported separately, because file integrity, signer attribution, and time are different questions.
- Package: every file in the zip is listed in the manifest with a matching hash, and nothing extra was slipped in.
- Evidence: the event log's hash chain is unbroken, and it's signed by a key that the pinned root vouches for.
- Document:
D0is the hash of the exact PDF the signers were shown.D1is the hash of the sealed PDF, which must begin with those same bytes. The seal is added as an incremental update, so nothing the signers saw was rewritten. - Seal: the PAdES signature covers the document's signed bytes, chains to a trusted CA, and was made by a key in the key list.
- Attribution: each signer has a signature event bound to
D0, with consent and a passed email code. The result describes what the service recorded about the ceremony. - Timestamp: the timestamp token binds a time to the evidence digest. The demo uses a synthetic authority. In production, the assurance depends on the authority you trust.
The third answer: "I can't tell"
Run the same command without the trust data:
inkless verify acme/evidence.zip
evidence indeterminate hash chain intact; JWS valid under kid "dev-evidence-1", but no key-list root is pinned
seal indeterminate CMS signature by "Inkless Dev Seal (synthetic)" valid, but no seal trust anchors configured
timestamp indeterminate token over SHA-256(evidence.jws): valid at 2026-11-29T11:17:47Z, but no TSA trust anchors configured
Result: indeterminate
The signatures are mathematically valid, but the verifier doesn't know whether to trust the keys behind them. Indeterminate means "I don't have enough to decide". A verifier that answers "passed" when it means "couldn't tell" is worse than no verifier at all.
Now break it
Change a single bit inside the sealed PDF, put it back in the zip, and verify again:
mkdir tamper && cd tamper && unzip -q ../acme/evidence.zip
python3 -c "p='final.pdf';b=bytearray(open(p,'rb').read());b[416]^=1;open(p,'wb').write(b)"
zip -q -D -r ../tampered.zip . && cd ..
inkless verify -root "$(cat trust/root.txt)" -keys trust/keys.json \
-seal-ca trust/seal-ca.pem -tsa-ca trust/tsa-ca.pem tampered.zip
package failed final.pdf digest does not match manifest
evidence passed hash chain intact (8 events); JWS valid under kid "dev-evidence-1" at timestamp 2026-11-29T11:17:47Z
document failed final.pdf does not start with the original bytes; SHA-256(final.pdf) does not equal D1
seal failed signed bytes were modified
attribution passed 2 of 2 signers have a signed event bound to D0 with consent and a passed challenge (recorded evidence, not proof of identity)
timestamp passed token over SHA-256(evidence.jws): genTime 2026-11-29T11:17:47Z by "Inkless Dev TSA (synthetic)"
Result: failed
One flipped bit, three failures, and the command exits with status 1. The separate checks show that the evidence and its timestamp still pass while the sealed PDF fails. Precise failures make for short investigations.
Keep -D in the zip command. It omits directory entries, which the package verifier rejects before checking the PDF.
Step 7: Verify from Go
The CLI wraps the verify package, which your own code can use without running the signing service.
From the acme directory, create cmd/check and save the following as cmd/check/main.go.
package main
import (
"crypto/x509"
"log"
"os"
"strings"
"github.com/edgar4/inkless/verify"
)
func main() {
root, err := os.ReadFile("trust/root.txt")
if err != nil {
log.Fatal(err)
}
keys, err := os.ReadFile("trust/keys.json")
if err != nil {
log.Fatal(err)
}
pkg, err := os.ReadFile("evidence.zip")
if err != nil {
log.Fatal(err)
}
report := verify.Package(pkg, verify.Options{
KeyListRoot: strings.TrimSpace(string(root)),
KeyLists: [][]byte{keys},
SealRoots: pool("trust/seal-ca.pem"),
TSARoots: pool("trust/tsa-ca.pem"),
})
for _, c := range report.Checks {
log.Printf("%-12s %-13s %s", c.Name, c.Status, c.Reason)
}
if report.Result != verify.Passed {
os.Exit(1)
}
}
func pool(path string) *x509.CertPool {
pem, err := os.ReadFile(path)
if err != nil {
log.Fatal(err)
}
p := x509.NewCertPool()
if !p.AppendCertsFromPEM(pem) {
log.Fatalf("%s: no certificates", path)
}
return p
}
cp -r ../trust .
go mod tidy
go run ./cmd/check
You get the same six checks. With verify.PDF, you can verify the seal on a standalone PDF. Without the evidence package, signer attribution is indeterminate.
Going to production
Development mode uses synthetic keys. Production starts with four variables:
| Variable | What it is |
|---|---|
INKLESS_PUBLIC_URL |
The https:// address signers will see |
INKLESS_KMS_KEY |
An AWS KMS key (ECC NIST P-256) for the seal and the evidence |
INKLESS_SMTP_URL |
A mail relay with TLS, for the codes |
INKLESS_TSA_URL |
An https:// RFC 3161 timestamp authority |
Two optional variables, INKLESS_DATABASE_URL and INKLESS_BLOB_URL, let you use PostgreSQL or MySQL for the database and S3 for documents. There's still no config file.
The signing key never leaves KMS. Create an offline root key to sign the key list. When you rotate a signing key, add the new key to the list and keep the retired key available for verification. If a key is compromised, record the cutoff. Evidence with a trusted timestamp before that cutoff can still pass. Evidence timestamped at or after the cutoff fails. Without a trusted timestamp, the result is indeterminate. The key management guide covers the setup, including the seal certificate.
A few things under the hood
The architecture document covers the full design. A few decisions shaped what you just ran.
A seal checked by someone other than me. The PDF library I used couldn't produce a strict PAdES baseline signature: it hard-coded details the standard forbids. Forking roughly 1,500 lines of it would have meant carrying that fork forever. Instead, Inkless lets the library lay out the PDF, then swaps in a signature it builds itself at the same length so no offsets move. The European Commission's DSS validator, built from its source and run in CI, reports the seal as PAdES-BASELINE-T with TOTAL_PASSED.
Transactions that recheck state. Signing has awkward timing: a revocation arriving mid-signature, two browser tabs, a request expiring while someone types their code. A signing write rechecks state, expiry, signing order, session, code and document hash in one transaction. It writes only if the relevant state still matches. Concurrent requests can retry or return a 409. These races are tested against SQLite, PostgreSQL and MySQL.
An architecture test for package dependencies. A test holds an explicit list of allowed imports for each package. Adding a dependency across packages requires updating the list, so the change is visible in review.
What review caught
Before the release, I asked for independent security and architecture reviews. They found real problems:
- Guessing codes across sessions. The service now caps failed codes across all sessions for each signer on a request and locks the signer when the limit is reached.
- A spoofable IP address. Behind a proxy, the service now records the address supplied by the configured proxy rather than the client-controlled end of
X-Forwarded-For. - MySQL quietly ignoring foreign keys. All 13 of them. A new migration adds them back.
- A flaky test that was a real bug. Running the seal tests 50 times in a row exposed connection exhaustion when talking to the timestamp authority. One release candidate had already shipped with it, so the fix went into the next release.
What Inkless can prove
The evidence records consent to a specific document, an assertion from the integrating application, and a completed inbox challenge. The service calls this an email-verified simple electronic signature. In Habivelle, each market and document type needs legal review before we turn on online signing, and offline paperwork remains an option.
Use development certificates only with synthetic documents. Production deployments choose their own seal certificate and timestamp authority. Inkless is at v0.1.0, and the API and evidence format may change before v1. See the integration guide's contract history.
Where it goes from here
Inkless is live as the signing engine behind Habivelle's offers and contracts. The next lessons will come from real signers: where they hesitate, where codes go missing in spam folders, and which documents need more than an email code.
If you need signatures that stay in your own infrastructure and can be checked for years without asking the signing service, start with the Inkless source, the Go package documentation, or the threat model. The Inkless case study covers how I built it for Habivelle.
Issues and pull requests are welcome, especially from anyone who has had to defend a signature in front of someone who wasn't convinced.
The signature itself was the easy part. The hard part was being exact about what can be proven, and being honest enough to answer "I can't tell".