Issuing a License with the YubiKey¶
This is the operator runbook for signing a customer platform.lic on the vendor
laptop using the YubiKey (PIV slot 9c, Ed25519) over PKCS#11. It is the
step-by-step procedure; the conceptual model (file layout, validation pipeline,
feature mask, key custody, rotation) lives in
Business Domains → Licensing, and one-time
tool/dependency setup lives in Installation. Neither is
repeated here.
When to use the software backend instead
Production licenses are signed by the YubiKey. The on-disk PEM backend
(--privkey / MBSS_LICENSE_KEY) exists only for development and tests. If
you are issuing a real customer license, use --yubikey as below.
Quick path — sbin/mint_license.sh¶
For the common cases, the mint_license.sh wrapper drives bin/licensing
--issue --yubikey for you: it picks the hardware-id rules for the target
platform, always signs with the YubiKey, and runs --verify on the result as a
self-check. The manual bin/licensing steps below remain the reference for
anything the wrapper does not cover (renewals inspected off an existing file,
non-default key/token selection, etc.).
Pick the target with one of --auto (default) / --macos / --linux. The
host OS (where the YubiKey is plugged in) is independent of the target — you can
sign a Linux license on a macOS laptop:
# 1) A license for THIS machine (default --auto → host OS, binds via --localhost):
sbin/mint_license.sh --customer acme-7F3A --expires 2027-12-31
# 2) On this macOS laptop, mint for a Linux GCP VM. The VM's id is its
# /etc/machine-id (grab it there: `cat /etc/machine-id`, or run
# `bin/licensing --info` in the deployed tree):
sbin/mint_license.sh --linux \
--customer acme-7F3A --expires 2027-12-31 \
--hwid 4f1c2e9ab0d34f5e8c7a1b2c3d4e5f60 \
--out /tmp/acme-platform.lic
Defaults: --features 0x7f (all seven modules) and --out platform.lic in the
current directory. Key rules the wrapper enforces:
--localhostbinds to the machine you run it on, and is only valid when the target OS equals the host OS. It is the implicit default under--auto.--hwid IDis required whenever the target differs from the host (you cannot read a remote machine's id locally — case 2 above). The id is format-checked against the target (--linux→ 32-hex/etc/machine-id;--macos→ dashedIOPlatformUUID); a mismatch aborts, so you never ship a license the customer's platform would reject.--forceoverrides the check.--dry-runprints the exactbin/licensingcommand without signing;--no-verifyskips the post-issue verification. PIN handling is unchanged (MBSS_YK_PINor the no-echo prompt — never on the command line).
Run sbin/mint_license.sh --help for the full flag list. The remaining sections
document the underlying bin/licensing flow the wrapper builds on.
Prerequisites¶
Before issuing, confirm all of the following on the signing laptop:
- The YubiKey is plugged in and provisioned — slot 9c holds the Ed25519
signing key (
sbin/yubikey_license_provision.sh status). On macOS PC/SC is built in; nopcscdneeded. - The binaries embed the matching public key.
bin/licensingandbin/servermust have been built from a source tree whoseEMBEDDED_PUB_KEY(in bothusr/src/licensing.cppandusr/src/security/license_validator.cpp) corresponds to this token's slot-9c key. If you have just rotated or rebuilt, reinstall the binaries (cd tmp/build && cmake --install .) so./bin/carries the fresh key — an issue against a stalebin/licensingprintsEmbedded: MISMATCH(see Troubleshooting). - The user PIN is available to the shell via
MBSS_YK_PIN, or you are ready to type it at the no-echo prompt. The PIN is never passed on the command line and never committed. On this laptop it is kept out of the shell history by reading it from a protected file at call time (see step 3).
Sanity-check the token and slot before you start:
cd "$BSS_HOME"
ykman piv info # slot 9C → Private key type: ED25519
./bin/licensing --pkcs11-list # token label + object CKA_ID 02 = PIV 9c
Step 1 — Gather the license parameters¶
Decide the four payload fields. For a renewal on the same machine, read them off the existing license so the reissue is like-for-like:
| Field | Flag | Notes |
|---|---|---|
| Customer id | --customer UUID |
max 35 chars; logged at startup for traceability |
| Expiry | --expires YYYY-MM-DD |
inclusive to the start of that UTC day |
| Features | --features HEX |
OR of the feature bits; 0x7f = all seven modules |
| Hardware id | --hwid ID or --localhost |
binds to one machine; --localhost signs for this laptop's machine id |
Confirm this laptop's hardware id (what --localhost will stamp):
Step 2 — Back up the current license (renewals)¶
Issuing overwrites the target .lic and its sibling .lkgt. Keep the
previous pair so you can roll back if verification fails:
cp -v var/lib/license/platform.lic /tmp/platform.lic.bak-$(date +%Y%m%d-%H%M%S)
cp -v var/lib/license/.lkgt /tmp/lkgt.bak-$(date +%Y%m%d-%H%M%S)
Step 3 — Issue and sign on the YubiKey¶
Run --issue --yubikey. The tool composes the payload, signs it on the
token (a physical touch is required — the key blinks), self-verifies the
fresh signature against the signing key, and writes the Base64 .lic plus a
freshly-initialised .lkgt.
Supply the PIN via MBSS_YK_PIN for the duration of the one command — reading it
from a protected file keeps it out of the shell history, argv, and this
document:
cd "$BSS_HOME"
MBSS_YK_PIN="$(cat ~/.onsite/keys/pin)" ./bin/licensing --issue \
--customer test-e2e-8DF7CA76 \
--expires 2027-12-31 \
--features 0x7f \
--localhost \
--yubikey \
--out var/lib/license/platform.lic
Touch the key
Slot 9c has a touch-always policy: signing blocks until you physically touch the YubiKey (it times out after ~15 s). Touch it when it blinks.
If you would rather be prompted for the PIN instead of using the env var, drop
the MBSS_YK_PIN=… prefix — the tool asks on the terminal with echo disabled.
A successful issue ends with, and you should confirm, these two lines:
Signer : PKCS#11 libykcs11.dylib, token 'YubiKey PIV #…', key id 02 confirms
the signature came from the token, not a file.
Step 4 — Verify the issued license¶
Cryptographically verify the signature and expiry against the binary's embedded public key:
Expect Signature: ✓ VALID and
✓ License is cryptographically valid and has not expired.
Step 5 — Confirm the server accepts it¶
The definitive test is that bin/server validates the license at startup
(signature and hardware binding and LKGT). Run any role briefly against
its TOML and watch for the License valid line, then stop it:
unset BACKEND_PREFIX FRONTEND_PREFIX # CLAUDE.md rule 3: run from source tree
export BSS_HOME="$PWD"
./bin/server -i etc/prepaid.toml & # start
sleep 2
pkill -9 -f bin/server # stop
A licensed boot logs:
License located.
License valid — customer=<…> days_left=NNN features=[PREPAID, CDR_LOADER, STATS, BILLING, BILL_FMT, CRM, DIAMETER]
Prepaid server setup complete [SSL].
Once you see License valid, the platform.lic is good for that machine.
Troubleshooting¶
| Symptom | Cause | Fix |
|---|---|---|
Embedded: MISMATCH on issue |
bin/licensing was built with a different EMBEDDED_PUB_KEY than this token's slot-9c key (usually a stale binary — rebuilt but not reinstalled) |
cd tmp/build && cmake --install ., then reissue. If genuinely mid-rotation, this is expected — see Key Rotation. |
| Sign hangs then aborts (~15 s) | touch not registered | Reissue and touch the key when it blinks |
DigestSign failed / login error |
wrong PIN, or PIN blocked (3 tries) | Check ~/.onsite/keys/pin / ykman piv info PIN-tries; a blocked PIN needs the PUK |
--verify → ✗ INVALID |
license signed by a key that does not match the binary's embedded key | Confirm you signed with slot 9c on the right token; rebuild/reissue as needed |
| Server logs hardware mismatch | .lic hardware_id ≠ this machine's id |
Reissue with the target machine's --hwid, or --localhost on that machine |
| Server logs LKGT rollback | system clock moved backward since last boot | Correct the clock; a fresh issue re-initialises .lkgt to now |
Security reminders¶
- The signing key never leaves the YubiKey; there is no PEM to copy in the production path.
- The PIN is only ever supplied via
MBSS_YK_PINor the no-echo prompt — never on argv, never in a committed file. - Every signature needs a physical touch, so malware holding the PIN still cannot sign silently.