Hardware keys (YubiKey)
A license that requires a YubiKey activates only with a key generated inside a genuine YubiKey 5, and then works only on a computer where that YubiKey is plugged in. The customer can move the license from one computer to another by moving the key, online or offline, and the license file itself needs no protection.
What a YubiKey protects
Section titled “What a YubiKey protects”- It decides where a license works, not who gets one. Who may activate is still decided by the activation code, the sign-in and the seat count, as without a YubiKey.
- It stops one activation from running on many computers. The license is bound to a key that cannot leave the chip, not to a fingerprint calculated by software, which a virtual machine can fake or clone. A copied license file does nothing without the key.
- Anyone can create a key on a YubiKey, but a key without an activation holds no license.
- Anyone can delete the key, with the SDK’s
Clear()or with Yubico’sykman. That gains nobody a license: the seat stays taken until you release it. A deleted key cannot be restored; setting the key up again and re-issuing the license recovers. - It behaves like a dongle. One key holds one seat and moves between computers with the key, offline included. It is not a floating license: no server counts concurrent use, the physical key does.
How a YubiKey-bound license works
Section titled “How a YubiKey-bound license works”Your application uses the SDK’s hardware-key add-on. On the customer’s YubiKey it creates one key of its own in a free retired slot, and never touches the customer’s other keys. That key’s thumbprint is the device fingerprint the license is bound to.
At activation the application sends the YubiKey’s attestation with the request. The attestation is a certificate chain that Yubico’s own certificates sign; it proves the key was generated inside a genuine YubiKey and cannot be copied out of it. Oclavex checks it before the license is issued:
- the chain leads to Yubico’s published attestation certificates, with a Yubico CA directly above the YubiKey’s own attestation certificate;
- the key is a P-256 key on firmware 5.7 or later;
- the key’s thumbprint is the fingerprint the device activates with;
- the key asks for a touch before every signature, when the license requires one.
An attestation is public: anyone who has seen it could send it again. So every online activation also proves the YubiKey is present right then: the application asks Oclavex for a fresh nonce, and the YubiKey’s key signs it (RFC 9449 DPoP). Oclavex accepts only a signature by the attested key, for that request, over a nonce it issued in the last two minutes.
A license that requires a YubiKey refuses any online activation without this proof. An offline request must carry the attestation; its signature by the key is checked when the request carries one, and required only if you ask Oclavex to require it. Devices activated before the requirement was turned on keep their licenses until their sessions are released or revoked.
When the application starts, the YubiKey signs a fresh challenge before the license is used (without a license store, the activation proof takes its place). A copied license file, or the same fingerprint on a computer without the YubiKey, fails that check. Your application can repeat the check at any time, for example to notice that the key was unplugged.
Set up the license in the portal
Section titled “Set up the license in the portal”Everything is on the entitlement’s or the offer’s Rules tab. An offer hands its settings to every entitlement made from it.
- Turn on Require a YubiKey to activate. Turn on Require a touch on the YubiKey too if a person must be at the computer whenever the key signs.
- Choose who may activate, on the Activation policy card. An application that activates without signing anyone in, like the example below, needs Activation security level set to Anonymous. Identify (log in) needs a signed-in user. If your application signs its user in, choose Identify (log in) and use interactive-user activation.
- On the Access tab, under Activation codes, create the code your customer enters. For an application that
activates without signing in, choose Anyone with the code under Who can redeem the code; the dialog
offers it only when the entitlement’s Activation security level is Anonymous. A code that needs a signed-in user refuses such
an application with
license.authentication_requiredandrequires: sign_in. To change a code you created earlier, open it and set Who can redeem the code to Anyone with the code.
Your application also needs your Oclavex address, such as https://acme.oclavex.com, and your license-signing
public key: in Settings → License signing keys, choose Copy public key on the key’s row. See
the provider key is mandatory.
What your customer needs
Section titled “What your customer needs”- A YubiKey 5 series key with firmware 5.7 or later. Older firmware leaks elliptic-curve keys to someone with physical access and specialized equipment (YSA-2024-03), so it is not used.
- Windows or macOS need no driver. Linux needs the
pcscdsmart-card service. - No PIN and no setup on the YubiKey: the application creates its key on the first start. A YubiKey whose PIV management key was changed, as company-issued keys often are, needs that management key once, for that first start.
Use the hardware-key add-on in your application
Section titled “Use the hardware-key add-on in your application”Add the add-on beside the SDK. Like the SDK packages, the add-on is not on NuGet.org until the first
public release, the beta 0.1.0-beta, so the command carries --prerelease:
dotnet add package Revenusion.Oclavex.Client.HardwareKeys --prereleaseThen make the YubiKey the device fingerprint. The name you pass labels the key on the YubiKey. Use your company name for all your products, and give a product its own name only in the cases under several licenses on one YubiKey. This example asks for the YubiKey when none is plugged in:
using Revenusion.Oclavex.Client.LicenseConsumer;using Revenusion.Oclavex.HttpConnector;
var yubiKey = new YubiKeyNodeId("Acme");
var found = yubiKey.Enroll();while (found.Exception is YubiKeyException { Failure: YubiKeyFailure.NoKey }){ Console.WriteLine("Insert your YubiKey, then press Enter."); Console.ReadLine(); found = yubiKey.Enroll();}
if (!found.IsSuccess){ Console.WriteLine(found.Exception?.Message); return;}
await using var session = new LicenseClientBuilder() .UsePublicKey(publicKey) .UseActivationCode(StaticActivationCodeProvider.Create(activationCode)) .UseNodeId(yubiKey) .UseOclavexHttpClient(OclavexClientFactory.Create(tenantUrl, new AnonymousAuthentication())) .BuildSession();
var access = await session.AccessLicenseAsync();Enroll() finds the key, or creates it on a YubiKey that has none, without having it sign anything. From then on
the application finds the key by its label. Every activation goes to Oclavex with the key’s attestation and a proof
of possession the key signs, which also proves the key is plugged in.
Call yubiKey.Check() whenever you want to know the key is still plugged in, for example before a licensed
feature runs. It has the key sign a fresh challenge, and succeeds only for that same key; another YubiKey fails it.
Without a prompt of your own, .UseYubiKey("Acme") on the builder replaces the YubiKeyNodeId and
Enroll(). BuildSession then throws a YubiKeyException when no YubiKey is plugged in.
Require a touch
Section titled “Require a touch”When the license requires a touch, create the key with a touch policy:
new YubiKeyNodeId("Acme", new YubiKeyOptions { TouchPolicy = YubiKeyTouchPolicy.Always }). The key then
signs only after a touch, and a check that gets no touch within 15 seconds fails with an
OperationCanceledException. Every online activation signs its proof of possession, so it needs a touch
(a lease refresh renews the session with its token and needs none): one, in a session without a license store. A session with a license store has the
key sign a challenge first, a second touch, because a stored license is served without an activation. A check is
one touch. The touch policy is fixed when the key is created. A key created without one
is refused by a license that requires a touch; remove it with Clear(), and the next start creates a new one.
Where the add-on sends
Section titled “Where the add-on sends”The add-on posts to routes that name the kind of key: api/v1/hardware-keys/yubikey/activations/license and .../nonce; the service also serves .../jwt. The offline route is api/v1/hardware-keys/operational/yubikey/activations/offline/issue. The SDK sets them for you; the old paths without yubikey are gone. A call to those paths from your own code fails with 404.
What the add-on does on the YubiKey
Section titled “What the add-on does on the YubiKey”- It creates a P-256 key in the highest free retired PIV slot, 95 down to 82, and labels it
CN=License key, O=<your name>. The slots 9A, 9C, 9D and 9E, and every slot it did not label, are never touched. - Checks need neither the PIN nor the management key. Creating and removing the key need the PIV management
key: the factory default is tried once. Pass a changed management key in
YubiKeyOptions.ManagementKey. yubiKey.Clear()removes your key and its label, and every license bound to that key stops working. SeeClear()and the other licenses before you offer it.
Several licenses on one YubiKey
Section titled “Several licenses on one YubiKey”One YubiKey can back any number of licenses. The licenses are files on the computer; the YubiKey holds one
key per name your application passes to YubiKeyNodeId. Every product and entitlement that uses the same
name is bound to the same key.
- Releasing a license releases only that license. The other licenses bound to the same key keep their seats.
Clear()breaks every license bound to the key: every product and entitlement that uses that name on that YubiKey, and none of their seats is released. So never callClear()when the customer uninstalls: the customer carries the key to other computers, and deleting it ends the license on all of them. Offer it as a deliberate “remove the license from this YubiKey” action, and release your own license first.- Keys under other names keep working, whether they belong to other vendors or to you under another name.
Use one name, your company name, for all your products, for example new YubiKeyNodeId("Acme"). One key per
vendor:
- uses one of the 20 retired slots (82 to 95), which every other vendor and any other smart-card software on that YubiKey share;
- needs the PIV management key only once, which matters for company-issued YubiKeys with their own management key;
- takes one seat per YubiKey on an entitlement that covers several products, such as a suite.
A separate name helps in three cases:
- A product needs a different touch setting. Touch is fixed when the key is created. A shared key set up
without touch is refused by a product that requires it, and recreating the key with
Clear()breaks the other products. - Each product offers its own “remove from this YubiKey” action. With a shared key, that action breaks every license bound to the key.
- The customer’s IT department assigns a slot per application (
YubiKeyOptions.PreferredSlot).
Each extra name costs a slot and one more setup with the management key. When none is free, enrollment fails
with NoFreeSlot. Products under different names count as different devices, so on one shared entitlement each
takes a seat.
When activation is refused
Section titled “When activation is refused”A refused activation comes back as a failed result. Branch on its ErrorCodeName:
ErrorCodeName |
Code | What happened |
|---|---|---|
hardware_key.attestation_refused |
11001 | The attestation did not hold: not a genuine YubiKey 5, firmware older than 5.7, or a different key. |
hardware_key.proof_refused |
11002 | The proof that the YubiKey is present did not hold: not signed by the attested key, made for another request, or its nonce expired. |
license.hardware_keys_not_licensed |
2023 | Your Oclavex plan doesn’t include hardware keys. |
license.forbidden_by_policy |
2011 | The license’s policy refused it, for example a license that requires a touch while the key was set up without one. |
license.authentication_required |
2028 | The activation code needs a signed-in user or a confirmed email, and the application activated without one (HTTP 401). See set up the license. |
When the refusal was for something missing, the result’s Requires says what, so your application can
act on it: ActivationRequirements.SignIn, HardwareKey or HardwareKeyTouch, for example. The
error codes page lists every value.
An application built without the add-on cannot activate a license that requires a YubiKey: it is refused
with license.forbidden_by_policy.
When the YubiKey can’t be used, nothing is sent, and the result’s Exception is a YubiKeyException. Its
Failure says why:
Failure |
What happened |
|---|---|
NoKey |
No YubiKey is plugged in. |
FirmwareNotSupported |
The YubiKey’s firmware is older than 5.7. |
NotEnrolled |
The YubiKey holds no key for your name, or not the key the application is bound to. |
WrongKey |
The YubiKey holds a key for your name, but not the one the license is bound to. |
SeveralKeys |
More than one plugged-in YubiKey qualifies. Leave only one plugged in. |
ManagementKeyRefused |
The YubiKey refused the management key. Pass the customer’s in YubiKeyOptions.ManagementKey. |
NoFreeSlot |
All retired slots, 82 to 95, hold other keys. |
ChallengeFailed |
The key’s signature did not verify with its own public key. |
DeviceError |
The YubiKey stopped answering, for example because it was unplugged. |
Offline activation
Section titled “Offline activation”An air-gapped device’s request file carries the attestation too. Upload it on the Provision portal’s Offline activation page as usual: the portal sees the attestation and has it checked before the response is signed. The signed response imports only on a computer where the same YubiKey is plugged in.
Issue the YubiKey yourself
Section titled “Issue the YubiKey yourself”You can set a YubiKey up at your office and send it to the customer with an activation code, so that only that key activates. The steps:
- Plug the YubiKey in and call
Enroll(). Read the key’s fingerprint from the result (found.Value.Fingerprint). This creates the key without activating, so no seat is used. - On the entitlement’s Access tab, under Devices, pre-register that fingerprint. On its Activation policy card, turn on Activation codes require a pre-registered device, and on the Hardware key card turn on Require a YubiKey to activate.
- Create the activation code after step 2. A code copies the setting when it is created, so codes made earlier do not check the device list.
- Optionally, set your own PIV management key on the YubiKey with Yubico’s
ykman, after step 1.Clear()then fails without it, and checks never need it. It is not airtight: blocking the PIN and PUK and resetting PIV still wipes the key. - Send the YubiKey and the activation code.
The code then admits the pre-registered YubiKey and refuses any other YubiKey, genuine or not. Offline requests made with the code are checked against the device list too.
Limits of this setup:
- Codes made before step 2 do not check the device list. An activation with the license key or by sign-in does check it, so only the pre-registered YubiKey activates those ways too.
- A deleted key gets a new fingerprint when it is set up again. Pre-register the new fingerprint and release the old seat.
Limits
Section titled “Limits”- The check runs in your application. A patched application can skip it; Oclavex does not wrap or encrypt executables. Online activation still needs the YubiKey, because Oclavex checks the proof of possession itself.
- Offline requests have no fresh challenge. Your operator uploads them, often much later, so there is no nonce from Oclavex to sign. A current SDK has the key sign the request file instead, and that signature stays valid for up to 30 days. The attestation shows the key was made in a genuine YubiKey.
- Relayed challenges. One YubiKey could answer challenges relayed from several computers over a network. They all carry the key’s fingerprint, so they count as one device.
- Virtual machines. A cloned virtual machine has no key. Several instances on one host can share one plugged-in key; they count as one device unless each names its own application instance.
- YubiKey 5 series with firmware 5.7 or later. Older firmware, the Security Key series and other brands are not accepted.