Extending a trial without reissuing the key
A prospect asks for seven more days on their evaluation. Reissuing the whole license key is disruptive — new key to distribute, device bindings to redo, caches to invalidate. This post builds grant-extension tokens in Keyright: a small signed object that layers on top of the base key and pushes its expiry forward, chained by a from/to expiry so each token applies exactly once and in order, bounded by a service-side extension ceiling so a trial cannot be extended forever, and verified entirely offline against the same pinned key.
A prospect is three days from the end of a 14-day evaluation and emails: “We’re close to a decision but need the long weekend to finish our proof-of-concept. Can we get a few more days?” It is the easiest yes in sales. The engineering question underneath it is not: how do you move one trial’s expiry forward without disturbing anything else about that license?
The reflex answer — reissue the key with a later date — works, and for a permanent change it is the right model. But a trial extension is a small, reversible nudge, and reissuing drags the whole key-distribution path behind it. A new key has to reach the prospect and be pasted in. The old key has to be revoked, or it keeps working alongside the new one. Any device binding tied to the old key’s payload has to be re-established. Every config file, environment variable, and cached copy of the old string has to be swapped. That is a lot of moving parts to buy someone a long weekend.
The real question
What you actually want to change is one field: the effective expiry. Everything else about the license — its id, its entitlements, its device bindings, the pinned key that verifies it — should stay exactly as it is. So the design question is: can an extension be a small object that layers on top of an unchanged base key, rather than a replacement for it?
It can. The mechanism is a grant-extension token: a short, signed statement that says “the license with this id, currently expiring at time A, now expires at time B.” The base key never changes. The client holds the base key plus zero or more extension tokens, and the effective expiry is whatever the last applied token says.
The base license stays frozen
A Keyright trial license has a fixed expiry baked into its signed payload. Nothing the extension does ever rewrites this object:
public sealed record LicensePayload(
Guid LicenseId,
string Edition, // "Trial"
DateTimeOffset NotBefore,
DateTimeOffset NotAfter, // the ORIGINAL trial expiry — immutable
IReadOnlyList<string> Entitlements)
{
public byte[] Signature { get; init; } = Array.Empty<byte>();
}
The extension token is a separate, independently signed object. The field that makes it safe is that it names both ends of the move it performs:
public sealed record GrantExtension(
Guid LicenseId, // which license this applies to
Guid GrantId, // unique per token, for audit
DateTimeOffset FromExpiry, // the expiry this token expects to find
DateTimeOffset ToExpiry, // the expiry it advances to
DateTimeOffset IssuedAt)
{
public byte[] Signature { get; init; } = Array.Empty<byte>();
}
FromExpiry is the whole trick. A token does not say “add seven days”; it says “if you are currently expiring at exactly A, you are now expiring at B.” That turns an otherwise-replayable grant into a single-use, strictly-ordered one.
Applying a token is a guarded state advance
The client keeps the base key and an ordered list of applied extensions. The effective expiry is the base NotAfter, advanced by each token whose FromExpiry matched when it was applied:
public DateTimeOffset EffectiveExpiry(LicensePayload baseLicense,
IReadOnlyList<GrantExtension> applied)
=> applied.Count == 0 ? baseLicense.NotAfter : applied[^1].ToExpiry;
Applying a new token is the only place the effective expiry moves, and it is guarded:
public ApplyResult Apply(GrantExtension token,
LicensePayload baseLicense,
List<GrantExtension> applied)
{
// 1. The token must be for THIS license, signed by the pinned key.
if (token.LicenseId != baseLicense.LicenseId)
return ApplyResult.WrongLicense;
if (!_verifier.Verify(token.Signature, CanonicalBytes(token)))
return ApplyResult.BadSignature; // fail closed
// 2. The chain gate: the token's FROM must equal our CURRENT effective expiry.
var current = EffectiveExpiry(baseLicense, applied);
if (token.FromExpiry != current)
return ApplyResult.NotApplicable; // out of order, or already applied
// 3. A token may only ever move expiry FORWARD.
if (token.ToExpiry <= current)
return ApplyResult.NotForward;
applied.Add(token); // effective expiry is now token.ToExpiry
return ApplyResult.Applied;
}
Walk the three guards. The signature check reuses the same pinned verification key the client already trusts for the base license — no new trust root, and the whole thing works offline. The FromExpiry != current gate is what makes a token single-use: once applied, the current expiry becomes ToExpiry, so re-applying the same token finds a From that no longer matches and does nothing. The forward-only check means a malicious or mistaken token can never shorten a trial by claiming a later From.
The same gate enforces order for free. A token that advances 20 Jan → 27 Jan is inert until something has moved the expiry to exactly 20 Jan. Tokens form a chain, each link fitting only onto the end of the previous one.
The ceiling lives on the service
Chaining stops a token being reused. It does nothing to stop support from minting a tenth token and extending a “trial” into a free perpetual license. That bound belongs on the issuing service, which is the only party that knows the running total it has already granted:
// Service-side mint. The ceiling is policy, enforced in one place.
public async Task<GrantExtension> MintExtensionAsync(
Guid licenseId, TimeSpan extendBy, CancellationToken ct)
{
var lic = await _store.GetLicenseAsync(licenseId, ct);
var granted = await _store.TotalExtensionGrantedAsync(licenseId, ct);
if (granted + extendBy > lic.MaxTrialExtension) // e.g. 14 days total
throw new ExtensionCeilingReachedException(granted, lic.MaxTrialExtension);
var from = lic.OriginalExpiry + granted; // the current chain tip
var to = from + extendBy;
var token = new GrantExtension(
licenseId, GrantId: Guid.NewGuid(),
FromExpiry: from, ToExpiry: to, IssuedAt: _clock.UtcNow)
{
Signature = _signer.Sign(CanonicalBytes(/* from, to, ids */))
};
await _store.RecordExtensionAsync(licenseId, token, ct); // running total advances
return token;
}
The client never sees or enforces the ceiling — it only ever handles individual tokens. A token simply does not exist for an extension that would breach policy, so “can we just keep extending” is answered no by the thing that mints, not by hopeful client-side arithmetic.
How you wire it
- Reuse the pinned key. The extension is verified with the same key as the base license (see pinning the verification key). No new trust root, and application is fully offline.
- Persist applied tokens beside the license cache. The effective expiry is a pure function of the base
NotAfterand the ordered applied list, so it recomputes deterministically on every start. - Canonicalize before signing. The signature must cover the ids and both expiries over a stable byte layout, the same discipline as canonical license serialization — a field-order wobble is a forged token.
- Surface the chain in the UI. “Trial, extended twice, now expiring 27 Jan” is what a support agent and a buyer both need to see.
When this breaks, honestly
The From gate assumes the client’s clock is roughly honest for display, not for the equality check. The FromExpiry comparison is an exact timestamp match against stored state, not against the wall clock, so clock skew does not misapply tokens — but the decision that a trial is expired still reads the clock, with the usual leeway and anti-rollback protections you already apply (anti-rollback epoch). An extension moves the boundary; it does not change how you trust the time you compare against it.
A lost token cannot be “skipped.” Because grants chain on exact expiries, if a prospect loses grant #1 and pastes grant #2, grant #2 finds a From that does not match and refuses. That is correct — the chain has a hole — but it means you reissue the missing link, not the one after it. Mint extensions one at a time and keep the GrantId list so you can see exactly which link is missing.
This is for moving a boundary, not for entitlements. A grant-extension token extends time. If an evaluation also needs more seats or a new feature unlocked, that is an entitlement change, and layering it onto an expiry token conflates two concerns. Keep extension tokens about the one field they name.
Takeaway
Reissuing a key to buy a prospect three more days is a sledgehammer for a thumbtack. A grant-extension token changes the one field that actually needs to move — the effective expiry — and leaves the base key, its bindings, and everything that references it frozen. Name both ends of the move inside the signed token, apply it only when its FromExpiry matches the current expiry, and the token becomes single-use and ordered with no counter to tamper with. Put the total-extension ceiling on the service where the running total lives, and a trial cannot quietly become perpetual. The prospect pastes one short string into the dialog they already know, gets their long weekend, and your key-distribution path never moves. See the trial and evaluation options in the Keyright docs and the licensing model on the Keyright product page.
Try Nebula.NET
Harden your .NET code in minutes — start with the free edition.