CarchaLabs.Seal.NetFramework
0.2.0
dotnet add package CarchaLabs.Seal.NetFramework --version 0.2.0
NuGet\Install-Package CarchaLabs.Seal.NetFramework -Version 0.2.0
<PackageReference Include="CarchaLabs.Seal.NetFramework" Version="0.2.0" />
<PackageVersion Include="CarchaLabs.Seal.NetFramework" Version="0.2.0" />
<PackageReference Include="CarchaLabs.Seal.NetFramework" />
paket add CarchaLabs.Seal.NetFramework --version 0.2.0
#r "nuget: CarchaLabs.Seal.NetFramework, 0.2.0"
#:package CarchaLabs.Seal.NetFramework@0.2.0
#addin nuget:?package=CarchaLabs.Seal.NetFramework&version=0.2.0
#tool nuget:?package=CarchaLabs.Seal.NetFramework&version=0.2.0
Carcha Seal for .NET
Licensing for .NET desktop apps that keeps working offline: activation, check-ins, offline grace, clock checks, offline license files, feature decryption and seats of floating licenses, with the same behaviour as the Electron SDK. CarchaLabs.Seal is a thin layer over the native library's C interface (the same library the C++ SDK ships), where the client logic, lease verification and decryption run. Requests go through .NET's HttpClient, so your app's proxy and certificate settings apply.
Targets: net10.0 (source-generated LibraryImport, trimming and Native AOT), netstandard2.0 and net462 (DllImport, for .NET Framework WinForms and WPF apps).
using CarchaLabs.Seal;
using var seal = new SealClient(new SealOptions
{
Product = "studio",
ServerUrl = "https://seal.carchalabs.com/<your slug>", // https://, or http:// on this computer only
PublicKeys = PublicKeys, // the PEM from the console, in your code, not read from a file
StorageDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Studio"),
AppVersion = "2.4.0",
});
try
{
await seal.ActivateAsync(keyTheUserTyped);
}
catch (LicenseException e)
{
Show(e.Message); // e.Code: "activation_limit", "invalid_key", "network", ...
}
LicenseState state = await seal.CheckAsync(); // at every start: online when the server answers, else offline grace
if (state.HasFeature("pro")) { /* ... */ }
byte[] model = seal.Decrypt("pro", encryptedModel); // data you encrypted for the feature
| Member | What it does |
|---|---|
ActivateAsync(key, machineName) |
Activates this device; no machine name is sent unless you pass one |
CheckAsync() |
The license state; offline from the saved lease, with its grace period and clock checks |
DeactivateAsync() |
Releases this device's seat |
OfflineRequest(key), ActivateOffline(file), DeactivateOffline() |
Offline activation by file |
Decrypt(feature, data) |
Decrypts data encrypted for a feature; the content key stays in the native library |
CheckoutAsync(key, options) |
Takes a seat of a floating license (below) |
SealOptions.HttpClient takes your own HttpClient; turn off automatic redirects on its handler (AllowAutoRedirect = false), as the library's own does: a redirect is never followed. One operation runs at a time on a SealClient; concurrent calls wait for each other (a seat's renewals among them).
Floating licenses: seats
A floating license is used by taking a seat while the app runs; the server frees it when the app gives it back or stops renewing (see the server's docs/floating.md).
SealSeat seat;
try
{
seat = await seal.CheckoutAsync(keyTheUserTyped, new CheckoutOptions { MachineName = "Lab PC 7" }); // later: CheckoutAsync() uses the saved key
}
catch (LicenseException e) when (e.Code == "seats_exhausted")
{
Show(e.Message); // e.GetDetail("inUse"), e.GetDetail("total"), e.GetDetail("retryAfter") in seconds
return;
}
seat.Lost += (_, e) => StopLicensedWork(e.Loss.Message); // on a thread-pool thread: "expired", "license_revoked", ...
if (seat.HasFeature("pro")) { /* ... */ }
// ... the seat renews itself on a timer ...
await seat.ReleaseAsync(); // when the app is done (on quit), then seat.Dispose()
| SealSeat | What it does |
|---|---|
GetInfo() |
Status (Held, Lost, Released), session id, features, seats in use and the pool's size (null: unlimited), license id and expiry, when the seat ends without a renewal, and why it was lost |
Status, HasFeature(name) |
From GetInfo(); HasFeature is false once the seat is not held |
RenewAsync() |
Renews now; the seat does it itself unless checked out with RenewAutomatically = false (then call it at NextRenewal) |
ReleaseAsync() |
Gives the seat back: true when the server confirmed it, false when it could not be reached (the seat frees itself when its token expires) |
Lost, Renewed |
Raised on the thread that renewed (a thread-pool thread for the timer's renewals) |
Dispose() |
Stops renewing and frees the seat here; it does not release it |
The seat token lives in the native library's memory only, and a seat has no offline grace: a renewal with no answer is tried again 15 s, 30 s, then every 60 s later (or when the server says), and the seat is lost as expired when its token's lifetime has passed on a monotonic clock (Stopwatch), so changing the computer's clock changes nothing. A session that ended or was taken over is checked out again on the same seat; any other refusal loses the seat with the server's reason. A transport that throws during a renewal or release counts as no answer, and so does a cancelled one (which then throws). An exception from a Lost or Renewed handler on the timer's thread is ignored. Keep a reference to the SealSeat while the app uses it.
Packages
dotnet add package CarchaLabs.Seal
CarchaLabs.Seal on nuget.org, published from a GitHub release tagged CarchaLabs.Seal@<version> (CHANGELOG). pack/ builds three packages, the layout Microsoft recommends for a native library used from both .NET and .NET Framework ("Native files in .NET packages"):
| Package | For | Holds |
|---|---|---|
CarchaLabs.Seal |
What apps install | No files: it depends on one of the two below, chosen by the app's target framework |
CarchaLabs.Seal.Runtime |
.NET 5+ (and other .NET Standard 2.0 hosts) | The library under ref/ and runtimes/any/lib/ (net10.0, netstandard2.0), the native library under runtimes/<rid>/native/ |
CarchaLabs.Seal.NetFramework |
.NET Framework 4.6.2+: AnyCPU, x86, x64, ARM64; PackageReference or packages.config | The library (net462), the native library for each Windows CPU, and build targets that copy them to carcha-seal\<cpu>\ next to the app; the library loads the one that matches the process |
Put the native libraries (cargo build --release --manifest-path ../native/Cargo.toml, no features) in artifacts/native/<rid>/: seal_native.dll for win-x86, win-x64, win-arm64; libseal_native.dylib for osx-x64, osx-arm64; libseal_native.so for linux-x64, linux-arm64. Then:
dotnet pack pack/CarchaLabs.Seal.Runtime
dotnet pack pack/CarchaLabs.Seal.NetFramework
dotnet pack pack/CarchaLabs.Seal
The packages are written to artifacts/packages/. A platform with no file in artifacts/native/ is left out of them.
CI (.github/workflows/dotnet-packages.yml) builds the native library for all seven platforms: on Windows with the C runtime linked in (-C target-feature=+crt-static), so the DLL needs no Visual C++ redistributable; on macOS for macOS 11 and later; on Linux on Ubuntu 22.04, so it needs no newer glibc than 22.04's. It packs them, checks every file in the packages, and runs tests/Consumer, an app that installs the packages: .NET 10 on Windows (x64, ARM64), macOS (Apple Silicon, Intel) and Linux (x64, ARM64; Ubuntu 22.04 and 24.04), and .NET Framework built for x86, x64, AnyCPU and ARM64 through PackageReference and packages.config, each checking that it loaded the copy for its CPU.
Tests
Needs the .NET 10 SDK and a Rust toolchain (the tests build ../native with cargo).
dotnet test --project tests/CarchaLabs.Seal.Tests -c Release # against the net10.0 build
dotnet test --project tests/CarchaLabs.Seal.Tests.NetStandard -c Release # against the netstandard2.0 build
Both run every client scenario recorded from the Electron SDK (../client/tests/vectors.json), every seat scenario (../client/tests/seat-scenarios.json: requests, results and events, on a scripted monotonic clock), the seat's renewal timer on the real clock, and the HTTP client against a local server.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET Framework | net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
-
.NETFramework 4.6.2
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on CarchaLabs.Seal.NetFramework:
| Package | Downloads |
|---|---|
|
CarchaLabs.Seal
Carcha Seal for .NET: licensing for desktop apps that keeps working offline. Activation, check-ins, offline grace, clock checks, offline license files and feature decryption. .NET 10, .NET Standard 2.0 and .NET Framework 4.6.2+ on Windows (x86, x64, ARM64), macOS and Linux. |
GitHub repositories
This package is not used by any popular GitHub repositories.