License File

License files are a versatile and flexible method for controlling software licenses in disconnected or protected environments where network connectivity to the Babel Licensing Service may not be available. With Babel Licensing, you can generate and utilize license files directly from the Babel User Interface without relying on the Babel Licensing Service for license management. In this introduction, we will explore how to create a license file using the Babel User Interface and how to integrate it into your .NET application for license validation.


To utilize license file functionality in Babel Licensing Service, you need to follow these prerequisites. First, make sure that the Babel Licensing Service is running on your server as per the instructions provided in the Getting Started section. Then, create a test product and a corresponding template license by referring to the instructions below. This step is essential to establish the foundation for generating license files.

Next, you will need to download the license file client source code from GitHub. This client code enables the integration of license file capabilities into your .NET application. Use the following command to clone the repository:

git clone

For this example, the creation of a license file requires the creation of a corresponding license template. To create the license template for your test client, please follow the instructions outlined in the "Creating License Template" section. By following these steps, you will successfully create the license template needed for generating the license file.

Creating a License File

The Babel User Interface provides a user-friendly interface for license management. Through this interface, you can easily create and configure licenses for your applications. When generating a license file, you can specify various details such as the product name, version, expiration date, allowed features, and any custom license fields or features required. The license file is digitally signed to ensure its integrity and authenticity.

To create a license file in the Babel User Interface, follow these steps:

  1. Launch the Babel User Interface and navigate to the Data section.

  2. Click on the "Licenses" link to display the list of existing licenses.

  3. Click on the "New License" button on the grid header to create a new license.

  4. In the License Template combo box, select the appropriate license template (see License Templates).

  5. The License fields will automatically populate with the information from the selected template.

  6. In the "Licensing Mode" field, select "File" as the licensing model for the license. The User Key and Allowed Sites will be automatically disabled as they are typically used to interact with the Babel Licensing Service.

  1. Enter the necessary details for the license, such as the licensee information, license fields, allowed features, and expiration date.

  2. Press the Generate button to generate the license, and then save by clicking the "Save" button.

  3. The newly registered license file will now appear in the licenses grid with a unique license key and other relevant information.

  4. Export the license file by pressing the save button on the grid header. The license file should be named ClientFile.licenses or ClientFile.lic.

You can now distribute the license file to your customers or use it to deploy the license in disconnected or protected environments where the Babel Licensing Service is not accessible.

Configuring a Client

To enable license validation using a license file, you need to integrate the Babel Licensing library into your .NET application. The library provides a set of APIs and methods that facilitate the license validation process. By referencing the Babel Licensing library and incorporating the necessary code, you can ensure that your application validates the license file correctly.

To open the license file console sample project, follow these steps:

  1. Navigate to the location where the license file sample project is stored.

  2. Copy the license file ClientFile.licenses in the project folder.

  3. Double-click on the ClientFile.sln solution file to open it in your preferred Integrated Development Environment (IDE), such as Visual Studio.

  4. Once the project is open, ensure that the Babel Licensing client library is referenced correctly. If the reference is missing, please refer to the Client Components paragraph to configure a local NuGet repository.

  5. After ensuring the correct references, build the solution by selecting the "Build" or "Rebuild" option from the IDE's menu.

  6. Once the solution is successfully built, you can run the application in debug configuration by pressing the "Start Debugging" button or using the keyboard shortcut specific to your IDE (e.g., F5 in Visual Studio).

  7. The license file console sample application will launch, validating the license file and showing the licensee information.

Follow the client application source code:

using System;
using Babel.Licensing;

class Program
    /// <summary>
    /// Public key used to validate the license signature.
    /// </summary>
    static string PublicKey => "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDE1VRiIdr6fiVZKve7NVgjIvGdRiRx0Mjjm+Yzf6tLbzFnxLs0fat5EoRcubxx0QQQDfydsJBE/fc7cwRWSrE2xK6X4Eb4W8O47pCMjqvTQZfDqQywEZJrLlxpp9hlKz6FDYX4SagrjmP1gdw8olo+n+IBz8ubkNxRhvycikxuDQIDAQAB";
    static Program()
        // Register the file license provider for the Program class
        // that will be used by the BabelLicenseManager to locate the license file.
        // The license file should be named as the assembly name with .licenses extension.        
        BabelFileLicenseProvider provider = new BabelFileLicenseProvider();

        // Sets the public key used to validate the license signature
        provider.SignatureProvider = RSASignature.FromKeys(PublicKey);

        // Uncomment the following line to customize the license file path
        // provider.LicenseFilePath = "license.xml";

        // Register the provider for the Program class
        BabelLicenseManager.RegisterLicenseProvider(typeof(Program), provider);

    static void Main(string[] args)
        var program = new Program();

            var license = program.ValidateLicense();

            Console.WriteLine($"License {license.Id} registered to {license.Licensee?.Company}");
        catch (Exception ex)

        Console.WriteLine("Press any key to exit...");

    public ILicense ValidateLicense()
        // Uses the registered file license provider for Program class
        return BabelLicenseManager.Validate(typeof(Program), this);

Inside the static constructor of the Program class, the file license provider is registered using the BabelFileLicenseProvider. This provider is responsible for locating and validating the license file for the Program class. By default, the license file should have the same name as the assembly with the extension .licenses or .lic.

Extracting and Securing the Public Key

In the provided code, the PublicKey property is used to hold the public key required for validating the license signature. It is set to a specific value extracted from the Keys.snk file.

var rsa = RSASignature.CreateFromKeyFile("Keys.snk");
string publicKey = rsa.ExportKeys(true);

To extract the public key from the Keys.snk file, the code uses the RSASignature.CreateFromKeyFile method, passing the file name as the parameter. This method creates an RSASignature object that represents the key pair stored in the Keys.snk file. Then, the ExportKeys method is called on the RSASignature object with the parameter true to export the public key. This method returns a string representation of the public key.

The Keys.snk file contains the private key and should not be deployed with the application. The private key must be kept secure and not exposed to unauthorized access.

The use of license files offers flexibility and convenience in scenarios where a network connection to the Babel Licensing Service is not feasible. It allows you to distribute licenses in offline or protected environments while still maintaining control over the licensing terms and compliance. License files can be easily deployed and transferred between systems, making them ideal for use in disconnected or restricted settings.

In conclusion, license files provide an alternative method for managing software licenses in disconnected or protected environments where network connectivity to the Babel Licensing Service is limited. By generating license files through the Babel User Interface and integrating them into your .NET application, you can ensure license compliance, protect your software's integrity, and facilitate licensing in offline or restricted scenarios.

License Validation With License Manager

In addition to the BabelFileLicenseProvider, Babel Licensing provides alternative methods for license validation using specific license manager classes. These classes, such as XmlLicenseManager and StringLicenseManager, offer flexibility in handling the loading and validation of license keys without relying on the BabelFileLicenseProvider for finding the license file.

The XmlLicenseManager class is designed to work with XML-based license files. It allows users to set the public key used for validating the license signature and provides methods to read the license key from an XML file, validate it, and retrieve the validated license object.

Here's an expanded explanation of the code snippet provided:

public ILicense ValidateLicenseWithXmlLicenseManager()
    // Uses the Xml license manager
    XmlLicenseManager manager = new XmlLicenseManager();

    // Sets the public key used to validate the license signature
    manager.SignatureProvider = RSASignature.FromKeys(PublicKey);

    // Reads the license from the license file
    string licenseKey = File.ReadAllText("ClientFile.lic");

    // Validates the license
    return manager.Validate(licenseKey, typeof(Program), this);

The StringLicenseManager class is another option that allows users to validate license keys directly from an encoded string. This can be useful when the license information is obtained from a different source, such as a database or an API response.

Both the XmlLicenseManager and StringLicenseManager classes provide alternative ways to handle license validation and offer flexibility in controlling the loading and validation process. They allow users to define their own logic for accessing the license key and provide a means to verify the license's authenticity and integrity using the specified public key.

Last updated