Verify a certificate offline

In this guide

A Keyseal certificate binds one licence to a product and a machine. The application can check both at launch without making a network request. It also needs the publisher’s public signing keys and a stable local fingerprint.

To use the SDK, follow the client SDK integration guide.

Pin the keys when you build

Fetch GET /v1/keys/{organization}/{product}?environment=test over HTTPS from Keyseal when preparing a test build. Replace both slugs with your own. The response’s keys object maps each kid to 32 raw Ed25519 public-key bytes, encoded in standard padded base64. Bundle the complete JSON response, including the keys object and its base64 strings, as the build resource pinned-keys.json. At startup, read this trusted resource and decode each value once to construct the public keys used by the verifier. Production builds use their own map from the same path with environment=live (the default).

Ship the active key and the retiring keys that should still verify older certificates. Distribute a trusted app update with new pins for a rotation and remove retired keys from subsequent builds. An unknown kid is a refusal. Keep the organisation, product, environment and key map together in the trusted build. Selecting a key from the certificate itself, a customer-supplied file or an automatic network lookup would let that input choose its own signer.

Activate a machine

Send a UTF-8 JSON object with Content-Type: application/json to POST /v1/activate. The buyer supplies key (1–64 characters). The build supplies product (1–64), app_version (1–40) and optionally build_date (a calendar date such as 2026-11-17, or null). The installation supplies fingerprint (1–256), machine_name (1–120) and platform (1–40). Required strings must be nonempty and free of control characters. Keep the fingerprint stable across launches and updates. The buyer’s key determines the organisation and environment.

A configured client also sends organization (the publisher slug) and environment (test or live). The server checks this pair before allocating a seat. Older clients can omit both. A signed certificate can contain update_major. When present, check it against the running binary’s major on each launch, including offline, together with the update period. Licences without this field retain their previous rights.

A 200 returns activation_id and certificate. Verify the certificate and match its signed act to the returned ID before storing the pair in private application storage. Reactivating the same active fingerprint reuses its seat. On seats_exhausted, show the names and last-seen times from error.machines so the buyer can release a seat in the customer area. On invalid_key or wrong_product, ask them to check the key and product. Keep keys, certificates and fingerprints out of logs, error messages and crash reports.

Verify a certificate in order

  1. Require the literal prefix keyseal:v1: followed by exactly two nonempty segments separated by one dot. Each must use only A–Z a–z 0–9 - _ and decode as unpadded base64url. Re-encode both and require byte-for-byte equality with the input. Reject a signature other than 64 bytes, or a payload other than a UTF-8 JSON object with a string kid. Return malformed for any failure here.
  2. Look up kid in the public keys pinned for this build. Return unknown_kid when absent.
  3. Verify pure Ed25519 with the 32-byte key, the decoded signature, and the original ASCII bytes of the payload segment. Return bad_signature on failure. Signing uses the encoded segment directly, with no prehash or context.
  4. Validate every signed field below. Return malformed on a missing field, wrong type or invalid format. Ignore unknown fields.
  5. Compare prod to the product slug embedded in the application. Return wrong_product on mismatch.
  6. Compute the lowercase hexadecimal SHA-256 of the original fingerprint’s UTF-8 bytes and compare it to fp. Return wrong_machine on mismatch.

Each field must be present, including both nullable dates. Check these groups before using the result.

  • Identity. kid, prod, lic, act and plan are strings identifying the key, product, licence, activation and plan. fp is a string of exactly 64 lowercase hexadecimal characters.
  • Entitlements. features is an array of strings. seats is a JSON integer. updates_until is a valid YYYY-MM-DD calendar date or null.
  • Time. valid_until is a UTC timestamp or null. lease_until is a required UTC timestamp. Both timestamp values use exactly YYYY-MM-DDTHH:MM:SSZ, with valid calendar dates and times. Dates and timestamps use ASCII digits. iat is a JSON integer in Unix seconds. Reject booleans and floating-point values for both integers, even 3.0.
  • Policy. offline is exactly open or closed. status is a string. Keyseal currently signs usable licences with active. A revocation reaches an installed app through refresh.

Decide what runs offline

Verify the stored certificate at every launch. Its lease is active while now < lease_until, using UTC. At equality the lease has expired. On loss of contact, open allows the last verified entitlements to continue. With closed, an expired lease blocks use until a successful refresh. Apply an explicit server refusal immediately, even during an active lease.

Evaluate build coverage separately. For the date constraint, a build dated d is covered if updates_until is null or d <= updates_until. The last day counts in full. valid_until carries the subscription end and the app chooses its local subscription policy. When online, Keyseal refuses refresh for an expired licence.

Refresh and release

Once a day when online, send activation_id, the original fingerprint and the current app_version to POST /v1/refresh. Verify a 200 before replacing stored state. Branch on error.code.

  • On revoked, suspended or expired, immediately persist a blocked state, including across restarts. Keep the activation ID and continue refreshing. Only a verified success restores access.
  • On released, unknown_activation or wrong_machine, clear the ID and certificate and ask for a new activation.
  • A timeout, network failure, 429, 5xx or unrecognised response leaves the last verified state in force under its offline policy. An invalid_request, not_found, method_not_allowed or http_error on refresh also gives no licence decision. Correct the request or retry later. An invalid certificate cannot replace a trusted one.
  • When the buyer chooses to release this machine, send only activation_id and fingerprint to POST /v1/deactivate. A 204 has an empty body. Clear local state on 204, unknown_activation or wrong_machine. A transport failure leaves the release unconfirmed.

The device uses only the public licence API. Keep management credentials and privileged actions such as changing a plan, revoking a licence or releasing another machine on the publisher’s server. Management API reference.

Run the conformance cases

Download the synthetic vectors and the standalone verifier into the same directory. With Python 3.11 or later and cryptography available, run:

python verify_vectors.py vectors.json

The 19 cases compare refusal reasons, signed fields, the exact lease boundary and build coverage. For example, rotated_key_b succeeds, retired_key yields unknown_kid, tampered_payload yields bad_signature and noncanonical_signature_bits yields malformed. offline_closed has a valid signature and an expired lease. Its app must block offline. Use the supplied public keys only for this test.

All guides