Skip to content

Software License Dongle for Perl

Perl still runs a great deal of quiet, valuable, long-lived commercial software — bioinformatics pipelines, publishing and prepress systems, network and telecoms tooling, in-house ERP that outlived three CIOs. Much of it is installed on the customer’s own server, which is exactly where a dongle earns its place: they hold your source, and a licence file is a file, which copies.

CPAN version badge

cpanm KeyNub::LicDongleCode language: Bash (bash)

Reading a License

use KeyNub::LicDongle qw($SCOPE_DEVELOPER);

my $dongle = KeyNub::LicDongle->open;      # first dongle, or ->open($serial)
$dongle->verify_genuine;                   # dies unless genuine

$dongle->session_open;
my $license = $dongle->record_read('license');
$dongle->session_close;
$dongle->close;Code language: Perl (perl)

The binding is dongle-centric rather than session-object-centric: the session, record and app-crypto calls all hang off the dongle. That keeps the object count down. Failures die, so one eval covers a whole sequence, and $@ carries the SDK’s own diagnostic text.

Setup

Perl 5.20+ and FFI::Platypus, which is the only dependency. Point it at the library with KEYNUB_LICDONGLE_FLAT_LIBRARY — note the flat: this binding goes through the flat companion API, so it wants keynub_licdongle_flat rather than the core library. Pointing it at the wrong one reports a missing licdf_ symbol, which is not an obvious way of saying “wrong library”.

The rule that holds in every language: do not branch on a boolean. Encrypt data your program needs with appEncrypt when you build the product, decrypt it through the dongle at run time, and removing the check leaves the program with nothing to compute rather than a working unlicensed copy.

Shipping the Native Library with a Perl Application

The KeyNub::LicDongle distribution on CPAN uses FFI::Platypus over the SDK’s flat API, so there is no XS to compile against your Perl. It loads keynub_licdongle_flat at run time from KEYNUB_LICDONGLE_FLAT_LIBRARY, the natives/ folder of an SDK clone, or the system search path.

A pp-packed executable or a plain script deployment needs the platform’s flat library beside it or on the search path. The prebuilt libraries for every platform are in the SDK repository’s natives/<platform>/ folder, with a SHA-256 manifest: Windows x64, x86 and ARM64, Linux x86_64 and aarch64, and universal macOS binaries for Intel and Apple silicon. On Linux, install the udev rule from NATIVES.md once, so that ordinary users may open the device.

Questions Perl Developers Ask

Which Perl Versions Does the Binding Support?

Perl 5.16 and later with FFI::Platypus, on Windows, Linux and macOS.

Does a Perl Application Need Administrator Rights to Talk to the Dongle?

No, and no driver either: the dongle is a USB HID device that the operating systems handle with their built-in class drivers. On Linux, install the shipped udev rule once so that ordinary users may open it; without the rule the SDK reports access denied and names the cause in its error detail.

Does a Perl License Check Need an Internet Connection?

No. Verification is a local exchange between your program and the dongle over USB: the SDK checks the dongle’s certificate chain to KeyNub’s root and runs a live challenge-response. There is no activation server and no account, so the check works on air-gapped machines.

Who Can Read the License Records on a Dongle?

Anyone holding the dongle: a program opens a session and reads records, and can decrypt data sealed for that dongle. Writing records, erasing them and incrementing counters need your write key. What the dongle guarantees is that none of it is available without the dongle present.

Can a License Written from Perl Be Read by a Program in Another Language?

Yes. Every binding drives the same core library and the same dongle, and records and sealed data are language-neutral bytes. Your issuing tool can be written in one language and your product in another.

How Do I Test the Perl Integration?

Against a dongle. The samples in the repository run against real hardware; with no dongle attached they print what to do and exit cleanly, which makes them a quick check that the library is found and the device is accessible.

Code

Runnable sample: perl/verify_and_read.pl. Binding source: bindings/perl. Both are Apache-2.0, in the public SDK repository; the prebuilt native libraries are in the repository’s natives/ folder, one per platform.

All supported languages · All industries · Buy a KeyNub · Ask us something