Raku reaches the dongle through the SDK’s flat C API with NativeCall, part of Rakudo, which loads the native library at run time, so there is no extension to build and nothing sits in the path of the check that a customer could substitute for something more agreeable. No dependencies. The KeyNub::LicDongle distribution in the zef ecosystem, Raku 6.d, on Windows, Linux and macOS.
zef install KeyNub::LicDongleCode language: CSS (css)
Reading a License
use KeyNub::LicDongle;
my $license = KeyNub::LicDongle::open(-> $d { # first dongle, or open('serial', -> $d { ... })
$d.verify-genuine; # dies unless genuine
$d.session({ $d.read-record('license') }) # closed on every exit path
});Code language: PHP (php)
What You Are Protecting
Raku software that is sold ships as source to the customer’s machine: a command-line tool, a text-processing service, an automation script. A check that returns a Bool is one conditional in that source, and removing one of those is a beginner exercise.
So the strong pattern is the one to reach for: the data the program needs only exists when the dongle is present.
# Weak: one removed line.
exit 1 unless $d.genuine;
# Strong: the parameters only exist with the dongle present.
my $parameters = $d.session({
decode-parameters($d.app-decrypt($sealed-blob-shipped-with-your-program))
});Code language: PHP (php)
Every failed call throws X::KeyNub::LicDongle with the status (NoDevice, NotGenuine, AuthRequired, …), the operation and the library’s detail; genuine fails closed. The block forms of open and session release the dongle and the session on every exit path. The distribution calls the SDK’s flat companion API, the one designed for foreign function interfaces: integer handles and buffers, no hand-written structure layouts.
Shipping the Native Library with a Raku Application
The KeyNub::LicDongle distribution calls the SDK’s flat API through NativeCall, part of Rakudo, so there is nothing to build and no dependency. zef install KeyNub::LicDongle installs it; a program takes keynub_licdongle_flat for its platform in natives/<platform>/ beside it or above the working directory, on the system’s library path, or names it with KeyNub::LicDongle::library-path or KEYNUB_LICDONGLE_FLAT_LIBRARY.
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 Raku Developers Ask
Which Raku Versions Does the Distribution Support?
Raku 6.d on Rakudo, on Windows, Linux and macOS. NativeCall comes with Rakudo, so the distribution has no dependencies.
Does the Raku Distribution Need a C Compiler?
No. It is Raku over NativeCall, and the native library ships prebuilt for every platform; zef install runs the distribution’s tests without a compiler or a dongle.
Does a Raku 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 Raku 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 Raku 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.
Code
Runnable sample: raku/verify-and-read.raku. Binding source: bindings/raku. 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