Skip to content
Oclavex is in private preview, open to existing MonetizeIt users. New users who would like to evaluate Oclavex before the public launch can request access at info@revenusion.com.

.NET SDK — offline, freshness and grace

The SDK does not call the server on every check. After activation it holds a signed, cached license and validates it locally against the embedded provider key. This is what lets you gate features on the hot path without a network round trip — and what lets a short connectivity blip pass unnoticed.

On the fluent-builder path, UseLicenseStoreBuilder() keeps the cached license in a file, a LicenseFileStore. A hosted app keeps it in memory.

The file goes in a License folder inside your application’s own folder in the user’s application data: %AppData%\<app>\License on Windows and ~/.config/<app>/License on Linux and macOS, where <app> is the name of your application’s entry assembly. To put it somewhere else:

.UseLicenseStoreBuilder(store => store
.UseLicenseFolderLocation(LicenseFileStore.LicenseFolderLocation.UserDefined, path))

LicenseFileStore is in the Revenusion.Oclavex.Client.LicenseConsumer.Services.Store namespace, which the other samples don’t import.

On startup the SDK checks the cached license’s signature against the embedded provider key and checks that the license names this device, then serves it, so the application starts licensed without waiting on the network.

Every license names the device it was issued for, and the SDK does not serve a stored or imported license that names another device. A cache copied to another machine is refused there. A license that names no device is refused too, unless you issue such licenses on purpose and set LicenseConfiguration.AllowUnboundLicenses.

The SDK encrypts the cache file by default. The signature proves a license wasn’t forged but doesn’t hide its contents: without encryption, a backup, a synced folder or malware that scans known paths can read the license.

The SDK derives the encryption key from three inputs: your application’s key material, a random salt for each file, and the activation code and application of the license. The key material is a built-in default unless you set your own with UseProtectionKey:

.UseLicenseStoreBuilder(store => store
.UseProtectionKey(myAppEmbeddedKeyBytes)) // optional — a built-in default is used otherwise

The device fingerprint is not one of the inputs, so a later SDK version that computes the fingerprint differently still finds and opens the cache. The license, not the key, ties the cache to the device.

When the cache file doesn’t decrypt, because the key material changed or the file was altered, the SDK treats it as a cache miss and revalidates online. It never denies the license for that reason, so a legitimate user isn’t locked out. A plaintext cache file, written while UseUnprotectedCache() was set, is read once and rewritten encrypted.

To keep the cache file readable, for debugging or because you protect the file yourself, call UseUnprotectedCache() on the store builder. The signature check and the device check still apply.

Each cached license carries a lease describing how recently it was authoritatively validated. LeaseStatus captures where it stands:

Status Meaning
Fresh Validated within the normal freshness window. Used directly.
Stale Past freshness but still inside the allowed offline window — should revalidate soon.
StaleLockout Past the absolute offline limit — must revalidate before further protected use.
Unverifiable Freshness can’t be determined; refused like StaleLockout — the license must be revalidated before use.
Lease freshness — how recently the license was revalidated time → Fresh used directly Stale revalidate soon StaleLockout must revalidate freshness TTL absolute offline limit License validity — grace keeps features on after expiry time → Active IsOperational = true GracePeriod still true — renew now Expired IsOperational = false license expires grace window ends

On the fluent-builder path, the background refresh renews the lease as soon as it goes Stale (at 80% of the lease), and checks at least every LicenseRefreshInterval, so in normal operation the lease never reaches lockout and a floating seat is never free between two renewals. When a renewal fails, the SDK tries again before the lease ends. A hosted app runs no background refresh: there the interval caps how long the license stays cached, and the next access fetches it again. A backend outage shorter than the allowed offline window has no user-visible effect: the lease may go Stale, but the license keeps working until the absolute offline limit. A prolonged outage eventually moves the lease to lockout, at which point the license must be revalidated before protected features resume — the SDK will not extend an unverified license indefinitely.

Grace is separate from freshness: it’s the window after a license’s validity ends during which the product keeps working, giving a customer time to renew. While in grace, LicenseStatus is GracePeriod and IsOperational stays true, so your existing feature checks keep passing without special casing. Read LicenseStatus == LicenseStatus.GracePeriod if you want to show a “renew now” banner. Grace doesn’t extend to a build the license doesn’t cover, which reports VersionNotSupported or ReleasedAfterMaintenance instead; see builds the license covers.

Offline enforcement can’t trust the system clock alone — moving it backwards would revive an expired license. The SDK keeps a monotonic high-water record of observed time, so winding the clock back doesn’t restore expired access. This is automatic; you don’t configure it.

A clock that jumps forward raises that record too, and offline it stays raised until real time catches up. Online the server’s time decides: a license the server issues on an activation, renewal or borrow carries the time it was issued, and the SDK resets the record to that time once it has verified the license’s signature. So once the system clock has been corrected, the next license the application gets from Oclavex makes its licenses valid again. Licenses accepted without a signature check (AllowUnsignedLicenses) never reset the record.

For air-gapped or intermittently connected installs, add the Revenusion.Oclavex.Client.OfflineStore package. It lets you carry activation across an air gap: the device produces an activation request (signed by its hardware key when it has one), an operator activates it against the platform, and the device imports the signed response, verified against the same provider key, so an offline device is no less protected than an online one.