Standard.Licensing.12noon
1.2.1.1
dotnet add package Standard.Licensing.12noon --version 1.2.1.1
NuGet\Install-Package Standard.Licensing.12noon -Version 1.2.1.1
<PackageReference Include="Standard.Licensing.12noon" Version="1.2.1.1" />
paket add Standard.Licensing.12noon --version 1.2.1.1
#r "nuget: Standard.Licensing.12noon, 1.2.1.1"
// Install Standard.Licensing.12noon as a Cake Addin #addin nuget:?package=Standard.Licensing.12noon&version=1.2.1.1 // Install Standard.Licensing.12noon as a Cake Tool #tool nuget:?package=Standard.Licensing.12noon&version=1.2.1.1
<p align="center"><img src="https://raw.githubusercontent.com/junian/Standard.Licensing/master/assets/img/standard-licensing-logo.png" alt="Standard.Licensing Logo"></p>
<h1 align="center">Standard.Licensing</h1>
<p align="center">Easy-to-use licensing library for .NET and .NET Framework products.</p>
<p align="center"> <a href="https://github.com/junian/Standard.Licensing/"><img src="https://img.shields.io/badge/GitHub-%23121011.svg?logo=github&logoColor=white&style=for-the-badge" alt="Standard.Licensing on GitHub" title="Standard.Licensing on GitHub"></a> <a href="https://www.nuget.org/packages/Standard.Licensing/"><img src="https://img.shields.io/nuget/v/Standard.Licensing.svg?style=for-the-badge" alt="Standard.Licensing latest version on NuGet" title="Standard.Licensing latest version on NuGet"></a> <a href="https://www.nuget.org/packages/Standard.Licensing/"><img src="https://img.shields.io/nuget/dt/Standard.Licensing.svg?style=for-the-badge" alt="Standard.Licensing total downloads on NuGet" title="Standard.Licensing total downloads on NuGet"></a> </p>
Standard.Licensing.12noon Fork
This for incorporates Pull Request 47.
- The
Expiration
property was returning anUnspecified
DateTime
type. Added theAdjustToUniversal
style toParse
. - Convert
DateTime
passed toExpirationDate
to UTC before comparing withExpiration
property (which is UTC). - Added a validation to
Expiration.set
to ensure the incoming type is notUnspecified
. - Added a validation to
ExpiresAt
to ensure the incoming type is notUnspecified
.
Whenever the pull request is accepted, this package will be deprecated in favor of the parent project.
Installation
Get Standard.Licensing.12noon from NuGet.
dotnet add package Standard.Licensing.12noon
Usage
Create a private and public key for your product
Standard.Licensing uses the Elliptic Curve Digital Signature Algorithm (ECDSA) to ensure the license cannot be altered after creation.
First you need to create a new public/private key pair for your product:
var keyGenerator = Standard.Licensing.Security.Cryptography.KeyGenerator.Create();
var keyPair = keyGenerator.GenerateKeyPair();
var privateKey = keyPair.ToEncryptedPrivateKeyString(passPhrase);
var publicKey = keyPair.ToPublicKeyString();
Store the private key securely and distribute the public key with your product. Normally you create one key pair for each product, otherwise it is possible to use a license with all products using the same key pair. If you want your customer to buy a new license on each major release you can create a key pair for each release and product.
Create the license generator
Now we need something to generate licenses. This could be easily done with the LicenseFactory
:
var license = License.New()
.WithUniqueIdentifier(Guid.NewGuid())
.As(LicenseType.Trial)
.ExpiresAt(DateTime.Now.AddDays(30))
.WithMaximumUtilization(5)
.WithProductFeatures(new Dictionary<string, string>
{
{"Sales Module", "yes"},
{"Purchase Module", "yes"},
{"Maximum Transactions", "10000"}
})
.LicensedTo("John Doe", "john.doe@example.com")
.CreateAndSignWithPrivateKey(privateKey, passPhrase);
Now you can take the license and save it to a file:
File.WriteAllText("License.lic", license.ToString(), Encoding.UTF8);
or
license.Save(xmlWriter);
Validate the license in your application
The easiest way to assert the license is in the entry point of your application.
First load the license from a file or resource:
var license = License.Load(...);
Then you can assert the license:
using Standard.Licensing.Validation;
var validationFailures = license.Validate()
.ExpirationDate(systemDateTime: DateTime.Now)
.When(lic => lic.Type == LicenseType.Trial)
.And()
.Signature(publicKey)
.AssertValidLicense();
Standard.Licensing will not throw any Exception and just return an enumeration of validation failures.
Now you can iterate over possible validation failures:
foreach (var failure in validationFailures)
Console.WriteLine(failure.GetType().Name + ": " + failure.Message + " - " + failure.HowToResolve);
Or simply check if there is any failure:
if (validationFailures.Any())
// ...
Make sure to call validationFailures.ToList()
or validationFailures.ToArray()
before using the result multiple times.
Third Party Projects
- PatrickRainer/LicenseManager - A WPF license manager for developers to generate and validate licenses.
- skst/LicenseManager - GUI front-end for Standard.Licensing project.
Credits
This is project is derived from Portable.Licensing library. The purpose of this fork is to add support for more .NET platforms, especially .NET Standard and .NET Core.
- dnauck/Portable.Licensing for the original work.
License
This project is licensed under MIT License.
Made with ☕ by Junian.dev.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 is compatible. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.6.1
- BouncyCastle.Cryptography (>= 2.4.0)
-
.NETStandard 2.0
- BouncyCastle.Cryptography (>= 2.4.0)
-
net6.0
- BouncyCastle.Cryptography (>= 2.4.0)
-
net8.0
- BouncyCastle.Cryptography (>= 2.4.0)
-
net9.0
- BouncyCastle.Cryptography (>= 2.4.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Standard.Licensing.12noon:
Package | Downloads |
---|---|
LicenseManager_12noon.Client
The 12noon License Manager Client NuGet package provides an application with a simplified API for validating a license. It is a companion to the 12noon License Manager application. License Manager is a graphical front-end application designed to create and manage licenses for software applications. It leverages the Standard.Licensing project to handle license generation and validation. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.2.1.1 | 203 | 3/7/2025 |
v1.2.1.1
- Fix Expiration parsing and comparison.
v1.2.1
- Add .NET 9.0 Support
v1.2.0
- Update to the latest BouncyCastle
v1.1.9
- Add custom DateTime to check Expiration date