NuSeal 0.2.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package NuSeal --version 0.2.0
                    
NuGet\Install-Package NuSeal -Version 0.2.0
                    
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="NuSeal" Version="0.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NuSeal" Version="0.2.0" />
                    
Directory.Packages.props
<PackageReference Include="NuSeal" />
                    
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 NuSeal --version 0.2.0
                    
#r "nuget: NuSeal, 0.2.0"
                    
#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 NuSeal@0.2.0
                    
#: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=NuSeal&version=0.2.0
                    
Install as a Cake Addin
#tool nuget:?package=NuSeal&version=0.2.0
                    
Install as a Cake Tool

NuSeal provides infrastructure for creating and validating NuGet package licenses. The validation occurs during build time, preventing unauthorized usage of your packages. It's designed to be generic while allowing each product package to set its own public key and license policies.

Overview

NuSeal consists of two main packages:

  1. NuSeal - Core package that validates licenses during build time (netstandar2.0 library)
  2. NuSeal.Generator - Helper package for generating RSA key pairs and licenses (net8.0 library)

Usage Guide

TL;DR

  • Authors create RSA key pairs. They may create them using NuSeal.Generator.
  • Authors create licenses for their users using NuSeal.Generator. License files are named YourProductName.license.
  • Authors embed the public key in their NuGet package using NuSeal. The public key file is named YourProductName.nuseal.pem.
  • End users obtain a license file and place it in their project directory.

For Package Authors

1. Create RSA Key Pairs

Package authors first need to create public/private key pairs. You can use the NuSeal.Generator package for this:

<ItemGroup>
  <PackageReference Include="NuSeal.Generator" Version="0.1.0" />
</ItemGroup>

Then generate the keys:

var keys = NuSeal.RsaKeyGenerator.GeneratePem();
File.WriteAllText("private_key.pem", keys.PrivateKey);
File.WriteAllText("public_key.pem", keys.PublicKey);

Keep the private key secure and confidential, as it will be used to sign licenses.

2. Create Licenses for Users

Once you have the key pair, you can create licenses for your product:

var license = NuSeal.License.Create(
    privateKeyPem: keys.PrivateKey,
    subscriptionId: "00000000-0000-0000-0000-000000000000",
    productName: "YourProductName",
    edition: "Free",
    issuer: "YourCompany",
    startDate: DateTimeOffset.UtcNow,
    expirationDate: DateTimeOffset.UtcNow.AddYears(1));

// Save the license to a file
File.WriteAllText("YourProductName.license", license);

Parameters explained:

  • privateKeyPem: Your private RSA key in PEM format
  • subscriptionId: Unique identifier for the customer subscription
  • productName: Unique identifier of your product associated with this license. It might be the package name if this license is intended only for this package; or it might be a bundle name if the license is associated with group of packages. <strong>Important: this name is used for both the public key filename and license filename. It must be alphanumeric and should not contain dots (.).</strong>
  • edition: Edition of your product (e.g., "Free", "Professional", "Enterprise")
  • issuer: Your company or organization name
  • startDate: When the license becomes valid
  • expirationDate: When the license expires
3. Protect Your NuGet Package

To protect your NuGet package, add the NuSeal package as a dependency:

<ItemGroup>
  <PackageReference Include="NuSeal" Version="0.1.0" />
</ItemGroup>

Then, add your public key as an embedded resource. The file should be named YourProductName.nuseal.pem:

<ItemGroup>
  <EmbeddedResource Include="YourProductName.nuseal.pem" />
</ItemGroup>

The package authors may include more than one pem file. It's a common practice that authors provide licenses for a single package or a bundle of packages. In this case, the author may include multiple pem files. If the public pem is the same (created both licenses with the same private key), you still need to include pem file per product.

<ItemGroup>
  <EmbeddedResource Include="YourProductName.nuseal.pem" />
  <EmbeddedResource Include="YourBundleName.nuseal.pem" />
</ItemGroup>

NuSeal will try to find and validate the license against all embedded public keys. At least one valid license is required to pass the validation.

For End Users

End users of your protected NuGet package need to:

  1. Obtain a license file from you (the package author)
  2. Place the license file in one of these locations:
    • Same directory as the application executable
    • Root of the solution or repository

The license file should be named YourProductName.license where YourProductName matches the productName parameter used when creating the license.

Validation Criteria

  • The license is validated against the following criteria:
    • The license is signed with the private key corresponding to the embedded public key
    • The license has not expired
    • The product claim in the license matches the product name associated with the public key
  • The validation occurs only for the "executable" assemblies (i.e., those that produce an application, not a library). This is determined by checking whether the OutputType is Exe or WinExe, or the SDK is Microsoft.NET.Sdk.Web. This is done to avoid cluttering the build output for large solutions with many library projects, but I'm open to suggestions from the community.

How It Works

  1. NuSeal runs during the build process
  2. For each protected assembly, it extracts the embedded public key
  3. It searches for a matching license file in the project directory tree
  4. The license is validated against the public key
  5. If no valid license is found, the build fails with an error

Give a Star! ⭐

If you like or are using this project please give it a star. Thanks!

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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 was computed.  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 was computed.  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.  net10.0 was computed.  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. 
.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 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.

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
0.3.0 136 9/8/2025
0.2.0 150 9/3/2025

Refer to Releases page for details.
     https://github.com/fiseni/NuSeal/releases