LicenseServer.Client 1.1.7

There is a newer version of this package available.
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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="LicenseServer.Client" Version="1.1.7" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LicenseServer.Client" Version="1.1.7" />
                    
Directory.Packages.props
<PackageReference Include="LicenseServer.Client" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add LicenseServer.Client --version 1.1.7
                    
#r "nuget: LicenseServer.Client, 1.1.7"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package LicenseServer.Client@1.1.7
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=LicenseServer.Client&version=1.1.7
                    
Install as a Cake Addin
#tool nuget:?package=LicenseServer.Client&version=1.1.7
                    
Install as a Cake Tool

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 ILogger for all operations
  • ActivitySource tracing (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.
Package Description
LicenseServer.Abstractions Shared types only (zero dependencies)
LicenseServer.Client.Abstractions Interfaces for mocking/testing
Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.12 180 6/27/2026
1.1.11 161 6/26/2026
1.1.10 206 5/24/2026
1.1.9 138 5/22/2026
1.1.8 123 5/16/2026
1.1.7 115 5/16/2026
1.1.6 114 5/15/2026
1.1.0 111 5/14/2026