LicenseServer.Client
1.1.7
See the version list below for details.
dotnet add package LicenseServer.Client --version 1.1.7
NuGet\Install-Package LicenseServer.Client -Version 1.1.7
<PackageReference Include="LicenseServer.Client" Version="1.1.7" />
<PackageVersion Include="LicenseServer.Client" Version="1.1.7" />
<PackageReference Include="LicenseServer.Client" />
paket add LicenseServer.Client --version 1.1.7
#r "nuget: LicenseServer.Client, 1.1.7"
#:package LicenseServer.Client@1.1.7
#addin nuget:?package=LicenseServer.Client&version=1.1.7
#tool nuget:?package=LicenseServer.Client&version=1.1.7
LicenseServer.Client
Full .NET license client SDK for integrating with LicenseServer. Provides license activation, background sync, ASP.NET Core middleware, hardware fingerprinting, and lifecycle events.
Installation
dotnet add package LicenseServer.Client
This transitively brings in LicenseServer.Client.Abstractions and LicenseServer.Abstractions.
Quick Start
1. Basic Setup (Console App)
var builder = Host.CreateApplicationBuilder(args);
builder.Services.AddLicenseClient(opts =>
{
opts.BaseUrl = "https://license.example.com";
opts.ApiKey = builder.Configuration["LicenseServer:ApiKey"]!;
});
var host = builder.Build();
var client = host.Services.GetRequiredService<ILicenseClient>();
2. Activate a License
var fingerprint = await host.Services
.GetRequiredService<IFingerprintCollector>()
.CollectAsync();
var hash = await host.Services
.GetRequiredService<IFingerprintCollector>()
.HashAsync(fingerprint);
var result = await client.ActivateAsync(new ActivateRequest(
Serial: "XXXX-XXXX-XXXX-XXXX",
ActivationCode: "123456",
Fingerprint: fingerprint.ToDictionary(k => k.Key, v => v.Value),
Hash: hash,
InstanceKey: Environment.MachineName,
Label: null));
var license = client.ParseLicense(result.License);
Console.WriteLine($"Licensed to: {license!.Customer.Name}");
Console.WriteLine($"Expires: {license.ExpiresAt}");
3. Background Sync
builder.Services.AddFileLicenseStore("license.dat", encrypt: true);
builder.Services.AddLicenseSyncManager(opts =>
{
opts.Serial = "XXXX-XXXX-XXXX-XXXX";
opts.Hash = hash;
opts.Interval = TimeSpan.FromHours(24);
});
4. ASP.NET Core Integration
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddLicenseClient(opts =>
{
opts.BaseUrl = builder.Configuration["LicenseServer:BaseUrl"]!;
opts.ApiKey = builder.Configuration["LicenseServer:ApiKey"]!;
});
builder.Services.AddFileLicenseStore("license.dat", encrypt: true);
builder.Services.AddLicenseMiddleware();
var app = builder.Build();
app.UseLicenseValidation();
// Public endpoint
app.MapGet("/health", () => Results.Ok("healthy"));
// Feature-gated endpoint
app.MapGet("/analytics", () => Results.Ok("premium data"))
.RequireLicenseFeature("advanced_analytics");
app.Run();
5. Lifecycle Events
builder.Services.AddLicenseEventHandler<MyHandler>();
public class MyHandler(ILogger<MyHandler> logger) : LicenseEventHandlerBase
{
public override Task OnExpiredAsync(ParsedLicense license, CancellationToken ct)
{
logger.LogWarning("License expired at {ExpiresAt}", license.ExpiresAt);
return Task.CompletedTask;
}
}
6. Error Handling
All API errors are mapped to typed exceptions for ergonomic try/catch:
try
{
await client.ActivateAsync(request);
}
catch (InvalidActivationCodeException)
{
Console.WriteLine("Wrong activation code");
}
catch (DeviceLimitException)
{
Console.WriteLine("Too many devices");
}
catch (LicenseClientException ex)
{
Console.WriteLine($"License error: {ex.Message} ({ex.ResponseCode})");
}
Features
Storage Options
| Method | Description |
|---|---|
| Default (in-memory) | No persistence, lost on restart |
AddFileLicenseStore(path, encrypt) |
JSON file with optional AES-GCM encryption |
AddProtectedLicenseStore(path) |
Windows DPAPI user-scoped encryption |
Middleware Pipeline
| Extension | Purpose |
|---|---|
UseLicenseValidation() |
Blocks requests with 403 when license is invalid + checks feature gates |
UseLicenseSeatEnforcement() |
Manages concurrent session lifecycle automatically |
.RequireLicenseFeature("feature") |
Per-endpoint feature gating |
Authorization Policies
Use LicenseFeatureRequirement with ASP.NET Core authorization for attribute-based gating:
builder.Services.AddAuthorization(opts =>
{
opts.AddPolicy("PremiumFeature", policy =>
policy.AddRequirements(new LicenseFeatureRequirement("premium")));
});
Hardware Fingerprint
The SDK automatically detects the platform and collects hardware identifiers:
- Windows: CPU ProcessorId, BaseBoard Serial, Machine GUID, MAC address (via WMI)
- Linux:
/proc/cpuinfo,/sys/class/dmi/id/board_serial,/etc/machine-id, MAC address - Other: Hostname + MAC address (fallback)
Fingerprint matching uses weighted scoring (CPU 30%, Board 30%, GUID 25%, MAC 15%) with a configurable threshold (default 70%) to tolerate minor hardware changes.
Security
- ECDSA response verification (opt-in): Verifies server response signatures to prevent tampering
- Clock guard: Detects system clock manipulation by comparing local time with server time
- Anti-rollback: Prevents clock rollback attacks by tracking monotonic server timestamps
- Configurable retry: Linear or exponential backoff for transient failures
Observability
- Structured logging via
ILoggerfor all operations ActivitySourcetracing (LicenseServer.Client) for OpenTelemetry integration- Health check (
license-server) for monitoring server connectivity
Configuration Validation
Missing or invalid configuration fails fast at startup with descriptive error messages:
LicenseClient: BaseUrl is required. Set the license server URL (e.g., "https://license.example.com").
LicenseClient: ApiKey is required. Set your license server API key.
LicenseClient: VerifyResponseSignatures is enabled but TrustedResponseKey is not set.
SyncManager: Interval must be at least 30 seconds to avoid rate limiting.
Related Packages
| Package | Description |
|---|---|
| LicenseServer.Abstractions | Shared types only (zero dependencies) |
| LicenseServer.Client.Abstractions | Interfaces for mocking/testing |
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- LicenseServer.Client.Abstractions (>= 1.1.7)
- Microsoft.Extensions.Caching.Hybrid (>= 10.6.0)
- Microsoft.IdentityModel.JsonWebTokens (>= 8.18.0)
- Standard.Licensing (>= 1.2.2)
- System.Security.Cryptography.ProtectedData (>= 10.0.8)
- ZiggyCreatures.FusionCache (>= 2.5.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.