LicenseCore.Lib 1.0.0
LicenseCore.Lib
Hardware-bound license validation for .NET applications.
Drop into any ASP.NET Core app with two lines of code. Cross-platform (Windows, Linux, macOS). All cryptographic defaults baked in — works without any appsettings.json configuration.
Quick start
dotnet add package LicenseCore.Lib
In Program.cs:
using LicenseCore;
if (LicenseBootstrap.HandleCliFlags(args)) return 0;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddLicenseValidation(); // startup + 24h re-check
var app = builder.Build();
app.UseLicenseGate(); // returns 503 if invalid
app.MapGet("/", () => "Hello");
app.Run();
return 0;
How it works
Customer machine Vendor server
───────────────── ─────────────
YourApp.exe --machine-info
↓
license_data.json (hardware fingerprint)
↓
send to vendor ────────► LicenseCore.exe generate
↓
license.lic
receive license.lic ◄──────── send back
Drop license.lic next to YourApp.exe
↓
YourApp.exe
↓
LicenseValidator validates on startup + every 24h
↓
UseLicenseGate middleware returns 503 if invalid
CLI flags handled automatically
| Flag | What it does |
|---|---|
YourApp.exe --machine-info |
Generates license_data.json (hardware fingerprint) |
YourApp.exe --license-status |
Prints current license details |
YourApp.exe (no args) |
Normal app startup |
Configuration
All defaults work out of the box. Override only what you need.
Option 1: Programmatic (recommended)
builder.Services.AddLicenseValidation(opts =>
{
opts.LicenseFilePath = "C:/etc/yourapp/license.lic";
opts.RecheckInterval = TimeSpan.FromHours(6);
opts.SupportContact = "help@yourcompany.com";
opts.BypassPaths = new() { "/health", "/admin", "/api/public" };
});
Option 2: appsettings.json
{
"LicenseValidation": {
"LicenseFilePath": "license.lic",
"RecheckInterval": "06:00:00",
"SupportContact": "help@yourcompany.com"
}
}
Option 3: Environment variables
LicenseValidation__LicenseFilePath=/etc/yourapp/license.lic
What validation checks
- Anti-tamper: system clock didn't move backward beyond the tolerance (default 1 day)
- File integrity: license.lic decrypts cleanly
- Signature: HMAC-SHA256 signature verifies against vendor's key
- Hardware binding: machine_id, system UUID, CPU ID, disk ID all match current machine
- Expiry: not past the expiry date
Any failure flips LicenseValidator.IsLicenseValid to false, and UseLicenseGate() starts returning 503.
Built-in static state (for UI / diagnostics)
LicenseValidator.IsLicenseValid // bool
LicenseValidator.LastError // string
LicenseValidator.LastCheckedUtc // DateTime
LicenseValidator.DaysRemaining // int
LicenseValidator.Customer // string?
LicenseValidator.Expiry // string? (YYYY-MM-DD)
Bypass paths
/health and /admin/license are always allowed through the gate by default, so health checks and support diagnostics keep working when the license is invalid.
Default 503 response
{
"error": "Service unavailable",
"reason": "License has expired",
"last_checked": "2026-05-24T14:00:00Z",
"contact": "support@yourcompany.com"
}
Cross-platform hardware identifiers
| OS | Sources |
|---|---|
| Windows | Registry MachineGuid, wmic cpu, wmic diskdrive |
| Linux | /etc/machine-id, /proc/cpuinfo, lsblk |
| macOS | ioreg, sysctl machdep.cpu, diskutil |
License
Proprietary — internal use by YourCompany.
No packages depend on LicenseCore.Lib.
.NET 8.0
- Microsoft.Data.Sqlite (>= 8.0.10)
- Microsoft.Extensions.Configuration (>= 8.0.0)
- Microsoft.Extensions.Configuration.EnvironmentVariables (>= 8.0.0)
- Microsoft.Extensions.Configuration.Json (>= 8.0.0)
| Version | Downloads | Last updated |
|---|---|---|
| 1.0.0 | 258 | 5/24/2026 |