licers
License-key verification for Rust apps, against Licers.
Every answer from the license server is Ed25519-signed with your account key and checked here (ed25519-dalek, strict verification), with a fresh random nonce per call — so a cracked "fake license server", an edited response or a replayed one is refused.
Your public key and product id are on the dashboard’s Integration page. The public key is safe to ship inside your app. Each example below is a complete file.
Check a key
Run this when your app starts. The first check binds the device to the key; past the key’s device limit a new device is refused.
In the dashboard: create a product, then a license key for it.
use LicenseClient;
- A refused key is a normal answer with a message. An unreachable server is an error: never treat it as “unlicensed”.
validate returns Ok with valid == false when the server refuses the key, and Err for a forged answer or an unreachable server. err.is_network() tells them apart. The API is blocking and needs no async runtime; from async code, call it in spawn_blocking.
Entitlements
Switch features on per key: true/false, numbers or text. They come from the signed answer.
In the dashboard: set Entitlements (JSON) on the key or on its plan, for example {"pro": true, "seats": 5}.
use LicenseClient;
- Compare with true exactly. The text "false" is not the same as false.
Offline file
Check a signed .lic file with no internet at all, for air-gapped machines. Signature, product, expiry, device and operating system are all checked on the computer.
- Your app shows its device id, and the customer sends it to you.
- License keys → ⋯ → Offline license file: paste the device id, set how many days it lasts, download the .lic file.
- Send it to the customer. Your app reads it from disk.
use ;
- Revoking a key can’t reach a file you already sent, so give files a short life.
- The expiry uses the computer’s own clock.
- A blank device id makes a file that works on any computer.
Sign in with email
Instead of a key: sign_in() shows a code and waits while the customer signs in
to the customer portal with the email on their license and approves this
computer. The token works wherever a key does, only on this device. Turn on
"Sign in with email" for the product on the Products page first; the client
needs product_id.
let token = client.sign_in?;
// keep the token, then use it instead of the key:
let result = client.validate?;
if result.signed_out
client.sign_out?; // your app's "Sign out"
Calls return Error::SignedOut when the sign-in has ended. Waiting can end with
Error::SignInDenied or Error::SignInExpired. start_sign_in() gives you the
code and URL for your own window; s.wait(None) collects the token.
License server (no internet)
For networks without internet, the customer runs the free Licers License Server
(https://licers.com/docs#license-server). Point the client at it:
LicenseClient::builder(pk).api_url("http://licensing-pc:8090").product_id(id).local_server(true),
then validate("") or a floating session with an empty key. The
SDK checks the server's file with your public key; entitlements, end date and
seat limit come from that file, and no seat lasts beyond the file. License-server
mode must be on: only then are the server's answers trusted, and only for
validating and seats. Usage credits, remote variables and update checks always
come from Licers itself.
Usage credits
Meter what the customer does: “100 exports”, “5,000 AI calls a month”. Spending is all or nothing.
In the dashboard: give the key a credit limit, and a daily or monthly refill if you want one.
use ;
- Check the key on this device first.
- After a network error the credits may already be spent: read the balance before trying again.
Remote variables
Values you change in the dashboard without shipping an update: a link, a message, a switch.
In the dashboard: add them on the Remote Variables page.
use LicenseClient;
- Check the key on this device first.
- Values are text. A product’s value wins over one for all products.
Floating seats
Let only N people run the app at the same time, on any computers.
In the dashboard: set Max concurrent sessions on the key.
use ;
use Arc;
- If the server can’t be reached, the seat is kept until its last signed expiry and then given up.
- A crashed app frees its seat by itself after the session timeout.
Updates
Tell the customer about a new version. Only a valid, active key is given the download link.
In the dashboard: add the version and its download link on the Releases page.
use LicenseClient;
- The answer is signed, including “no update”. The download link is not: check its host and the file’s hash.
Errors
| Error | Meaning |
|---|---|
Error::Network |
Server unreachable: retry, or apply a grace period |
Error::Server |
The server answered 5xx: an outage, not a verdict on the key |
Error::Signature |
Signature or nonce check failed: forged, edited or replayed (or a damaged license file) |
Error::ProductMismatch |
Correctly signed, but for another of your products |
Error::InvalidLicense |
The server (or an offline file) refused the key |
Error::UsageExceeded |
Not enough credits; nothing was spent |
Error::SeatUnavailable |
No free floating seat, or a held seat was lost |
Error::Protocol |
Not a usable reply (a proxy or captive portal; redirects are never followed) |
err.is_network() covers the first two, err.is_refusal() the refusals.
Device id
get_hwid() is SHA-256 of "licers:" + the OS machine id (Windows MachineGuid, Linux /etc/machine-id, macOS IOPlatformUUID) — the same value the Node and .NET SDKs produce on that machine. Where none is readable, a random id is stored once in the user's data folder (LICERS_HWID_DIR overrides). Use .hwid("...") on the builder to supply your own.
License
MIT