Raspberry Pi devices are commonly used to run software in embedded systems, industrial equipment, kiosks, automation systems, and other dedicated deployments. When software is distributed across multiple Raspberry Pi devices, licensing can be used to control which devices are authorized to run the application and which features are available.
A practical Raspberry Pi licensing implementation needs to handle device identification, license verification, and the possibility that the application may not always have an Internet connection.
A Raspberry Pi licensing system generally needs to perform three tasks.
The application should be able to validate a license before allowing the software to run. This can involve contacting a licensing service when an Internet connection is available and verifying the signed license response.
For many Raspberry Pi applications, it is useful to associate a license with a specific device. This allows you to limit how many Raspberry Pi devices can use the same license.
Every Raspberry Pi board has a unique serial number. A licensing SDK can use this information to generate a machine code that identifies the device without exposing the original serial number to the licensing service. Devolens generates Raspberry Pi machine codes in the form RPI_{SHA256(serial number)}.
Licensing can also determine which functionality is available to a customer. For example, one license could enable a basic set of features while another enables additional functionality or a different number of devices.
The licensing check should therefore happen before the application performs operations that require an entitlement.
Implementing licensing directly into a Raspberry Pi application requires more than generating a license key. The application needs a way to identify the device, communicate with the licensing service, validate responses, and handle cases where connectivity is unavailable.
A licensing SDK can provide these components without requiring you to build the complete licensing infrastructure yourself.
Devolens provides a cross platform licensing library that includes Raspberry Pi specific machine code functionality. The cross platform package can be installed with:
dotnet add package Cryptolens.Licensing.CrossPlatform
The Raspberry Pi specific methods in the library detect whether the application is running on a Raspberry Pi and can use the board's serial number when generating the machine code.
A typical implementation starts when the application receives a license key. The application sends the key together with its machine code to the licensing service.
A simplified C# implementation looks like this:
var auth = "YOUR_ACCESS_TOKEN";
var licenseKey = "YOUR_LICENSE_KEY";
var publicKey = "YOUR_RSA_PUBLIC_KEY";
var result = Key.Activate(
token: auth,
parameters: new ActivateModel()
{
Key = licenseKey,
ProductId = 1234,
Sign = true,
MachineCode = Helpers.GetMachineCodePI(v: 2)
});
if (result == null ||
result.Result == ResultType.Error ||
!result.LicenseKey.HasValidSignature(publicKey).IsValid())
{
Console.WriteLine("The license does not work.");
}
else
{
Console.WriteLine("The license is valid.");
}
The important part for Raspberry Pi deployments is the machine code. Helpers.GetMachineCodePI is designed specifically for Raspberry Pi devices and generates the device identifier used during activation.
For a production application, the verification logic should also handle different failure cases separately. For example, an application may need to distinguish between an invalid license, a device activation limit being reached, and an inability to contact the licensing service.
Once the license has been verified, the application can use the license information to determine which functionality should be available.
For example, a Raspberry Pi application might have different functionality depending on the customer's license:
if (license.HasFeature(1).IsValid())
{
// Enable feature 1
}
if (license.HasFeature(2).IsValid())
{
// Enable feature 2
}
This approach allows the same application build to support multiple editions or licensing models. The license determines what the customer is entitled to use rather than requiring a separate application build for every customer.
Device identification is particularly important when licensing software that runs on Raspberry Pi hardware.
A Raspberry Pi's board serial number provides a device specific value that can be used to generate a machine code. Devolens hashes this value before using it as the machine code, resulting in an identifier such as:
RPI_{SHA256(serial number)}
This makes it possible to associate an activation with a particular Raspberry Pi without sending the original serial number as the machine identifier.
The choice of device identifier should still reflect how the software is deployed. If a Raspberry Pi is replaced, for example, the licensing system needs to account for the fact that the new board will have a different machine code.
Raspberry Pi applications are often deployed in environments where Internet connectivity cannot be assumed. This makes the licensing architecture an important part of the implementation.
If the application always has a reliable connection, it can perform license verification against the licensing service when required. For deployments with intermittent or restricted connectivity, the application can instead use an offline licensing approach.
Devolens supports offline licensing using signed license files, allowing an application to verify licensing information without contacting the licensing service every time it starts. For larger deployments, a dedicated Devolens License Server can also be used where centralized control and floating licensing are required.
Learn more about offline licensing
It is also important to test the licensing flow on the actual Raspberry Pi hardware. Device identification, operating system configuration, network access, and application startup behavior can differ from a development environment.
A licensing implementation that works correctly on a developer's computer should not automatically be assumed to work identically on a Raspberry Pi deployment.
The application should be tested on the Raspberry Pi hardware and operating system configuration used by customers. In particular, test license activation, device identification, application restarts, network failures, and any offline licensing workflow that the product supports.
For applications deployed across many Raspberry Pi devices, it is also useful to consider how devices will be activated and managed operationally. Automating license creation and activation can reduce the amount of manual work required as deployments grow.
Learn more about license automation
For a Raspberry Pi application, the licensing implementation can remain relatively small even when the underlying licensing infrastructure is more sophisticated.
The application needs to:
This keeps licensing logic separate from the rest of the application while still allowing device based licensing and different customer entitlements.
Software licensing on Raspberry Pi requires some considerations that are specific to hardware based deployments, particularly device identification and connectivity.
Using a Raspberry Pi aware licensing SDK can simplify these parts of the implementation. Devolens provides cross platform licensing functionality with Raspberry Pi specific machine code generation, while also supporting feature based licensing and offline deployments.
The result is a licensing layer that can be integrated into the application without requiring you to build and maintain the complete licensing infrastructure yourself.
Deploy licensing with a leading software licensing provider without long implementation cycles or added operational overhead.