Licensing
Every gateway is in one of five licence states, and the state decides which modules run. This page is for the people who run a gateway: what each state does, how the trial works, how to get a licence by redeeming a code or importing a file, and what is not available yet. A developer who sells a module reads Writing a module.
States
Open Gateway, then Licensing, or call GET /api/v1/licensing. The state is one of these words:
| State | What it is | Modules that need a licence |
|---|---|---|
trial | No licence, and the trial has time left | Run |
trial-expired | No licence, and the trial is used up | Stopped |
licensed | A paid or internal licence for this installation | Run if the licence names them |
grace | A paid licence that was valid has stopped validating, for example because its issuer's key was withdrawn. It lasts 14 days | Run, under a banner |
evaluation | A time-limited licence from sales | Run until it ends, then the trial's rules apply |
A licensed gateway never stops for licence reasons. A module that the licence does not name is the exception: it shows the module state unlicensed and starts by itself when a licence names it.
Which modules need a licence
A module says what it needs in its module.json. A module that says nothing needs nothing and runs in every state.
| The module declares | The licence has to name | First-party modules |
|---|---|---|
"bundle": "core" | The bundle core, or the module's id | OPC UA, MQTT, Modbus TCP, Historian, Scripts |
"requiresLicense": true | The module's id | MQTT broker, Modbus server, Telegraf, io.scadex.versioning |
A licence that names a bundle entitles every module that declares it, including modules added to it later.
An entitlement's id is one of four things:
| Id | It covers |
|---|---|
core (a bundle) | Every module that declares that bundle |
io.scadex.versioning (a module id) | That module |
io.scadex.driver.* (a prefix ending in .*) | Every module whose id begins io.scadex.driver. |
* | Everything the giver publishes, modules added later included |
Whatever the id, an entitlement only covers modules its giver signed. * from Scadex is every Scadex module and never a vendor's, and a vendor's * is only that vendor's own. A name that merely begins the same way is not under a prefix: io.scadex.driver.* does not cover io.scadex.drivers.
The trial
A gateway with no licence runs on a trial of 2 hours of its running time. The time counts only while the gateway is running in the trial state, and it is kept in the gateway database, so a restart or a clock set back gives nothing back. Licensing__TrialMinutes sets another length, in minutes.
An administrator can reset the trial on the Licensing page, or with POST /api/v1/licensing/trial/reset. A reset gives the whole trial back. It is free, it is always available, and it never touches a licence. The gateway counts the resets and shows the number.
When the trial ends
When the state becomes trial-expired, the gateway holds back what needs a licence, in this order:
- The modules that need a licence stop, and the ones that record, such as the historian, stop first. Each shows the state
unlicensedand the errorTrial expired. Import a licence, or reset the trial. - Every tag except the gateway's own
[system]tags is marked Bad with the detailTrial expired, whichever module supplies it, and a write to one is refused. - The audit log stops recording. It first notes in itself that it stopped: a row with
operationlicence, as described in Audit log.
Nothing is deleted. These keep running: sign-in, the dashboard, the Licensing page, editing tags and screens, the gateway's own tags, and modules that need no licence.
Redeeming a code, importing a licence that covers the modules, or resetting the trial undoes all three at once, with no restart. The modules start again by themselves, the tags get their last values back, and the audit log notes that it is running again.
Getting a licence
A licence comes from the company's licensing service, redeemed with a code, or from the company directly as a file. Nothing here takes payment. A code is the activation code of a licence the company made in a batch before anyone had an installation for it (an unclaimed licence), or an add-on code that adds to one; whoever sold it was paid however they and the customer agreed. Redeeming an activation code claims the licence: it is bound to this installation and is the customer's from then on. There is no storefront in the gateway or in the licensing service.
Redeem a code
On the Licensing page an administrator enters a code and presses Redeem. The gateway sends the code to the licensing service and imports the licence that comes back. The same through the API:
POST /api/v1/licensing/redeem (administrator) with {"code": "<code>", "customer": "<who the licence is for>"}. customer is who a new licence is for. A gateway that already holds a licence uses the customer that licence names, and a code that starts a licence needs a name from one place or the other. The gateway also sends the id of the licence it holds, if any: a code that adds to that licence, an add-on, makes a newer version of it, and any other code makes a licence for this installation. The answer holds accepted, file (what the gateway took) and licensing (the status, as GET /api/v1/licensing gives it).
A code that is wrong and one that is already used get the same answer, a 400 with the service's sentence, and a code is used up when it works. A caller that keeps sending wrong codes is made to wait: 429. When the service has no issuing key or cannot sign, it answers 503, the gateway passes that on as 502, and the code is not used up. A service that cannot be reached also answers 502: take the licence to the gateway as a file instead.
Asking for newer versions
The gateway asks the licensing service from time to time whether there is a newer version of its licence, and for the list of what the roots have withdrawn (see "Withdrawn keys and vendors"). A newer version exists when an add-on was redeemed, when a vendor gave the licence a module (see Giving modules to a licence), or when the licence was moved to this installation. The first question goes out two to five minutes after the gateway starts, then every 6 hours. After a failure it asks again after 2 minutes, then 4, 8 and so on, up to the interval.
This asking is part of call home: it stops with SCADEX_CALL_HOME=off. A person pressing Check for a newer licence on the Licensing page, or calling POST /api/v1/licensing/fetch as an administrator, asks at once, with call home on or off. The call always answers 200: reached is false with an error when nothing answered, and otherwise found says how many newer versions the service had, taken how many the gateway took, and revoked how many keys or vendors the list withdrew that the gateway did not know of.
GET /api/v1/licensing reports where the asking stands in online: url (the service), background (whether the gateway asks by itself), lastAttemptAt, lastSuccessAt, lastError and nextAttemptAt.
What the gateway tells the service
| Call | What the request holds |
|---|---|
| Redeem | The code, the installation id, who the licence is for (customer) and, for an add-on, the id of the licence it adds to |
| Ask for newer versions | The installation id, and the id and version (serial) of every licence the gateway holds |
| Ask for the list of withdrawn keys | Nothing: a plain GET of /revocations on the service |
The installation id is what stands in for a password when a gateway asks for its licence: the service sends back a file that only that installation accepts. A file is taken only if a certified issuer signed it for this installation, as for any imported file.
Without internet
A gateway that cannot reach the internet cannot redeem or ask. For it, a licence can be turned into a file on the company's website, from a code and the installation id (the activation request carries it, see below). A newer version of a licence, such as one that a vendor added a module to, is turned into a file the same way, from the installation id. That page is being built and is not live yet. The vendor never receives the file. The company can also issue a licence file for an installation id directly. Import the file as described under "Importing a licence file".
Moving a licence
A licence can be moved to a new installation, for a new host or a rebuilt gateway, 3 times in 365 days. The service answers a fourth try with 409 and the code rebind_limit; ask the company, which can move it past the limit. A move makes the same licence in a newer version, for the new installation id: the new installation fetches it or imports it. The old installation keeps what it was given, because a file on a gateway that is offline cannot be taken back. Moving is asked for on the company's website, as described under "Without internet".
Importing a licence file
However a licence arrives, it is one file for one installation, not one file per module. It names:
- The installation it is for. A gateway refuses a file for another installation. An
internallicence can name*instead, to run on any installation: it is for the company's own gateways, and a gateway refuses a file that names*and is any other kind. The licensing service never hands such a file to a gateway that asks for its licence; whoever runs the service gives it out. - The customer and the kind:
commercial,evaluationorinternal. A paid licence has no end date. Only an evaluation licence ends, on the date it carries. - What it entitles: bundles such as
core, and module ids. Each entitlement says who gave it (scadex, or a vendor's id), and may carry an end date and features that the module can read. The gateway checks an end date when the module loads, not while it runs, and lets the module run for 14 days past it. - Optionally a support date.
GET /api/v1/licensingshows it assupportUntil, and nothing stops when it passes. Support is what newer builds cost, not what keeps a gateway running: the same answer says, inbuild, which day this build was made (builtOn, stamped into the image when it is built; empty for a build made by hand) and whether that iscoveredby the support,ended(the build is from after the support's last day),unknown(the licence has a support date and the build has no day) ornone(no licence). The Licensing page says so in a line when it has ended, and nothing is held back.
Bring a file in by hand in any of three ways. None needs a restart:
- On the Licensing page, upload the file or paste its text. A block that starts with
-----BEGIN SCADEX LICENSE-----works as well as the file. - Send it to
POST /api/v1/licensing/importas an administrator, with{"license": "<file or armored block>"}. - Copy a file with the extension
.licenseinto the licenses folder,DATA_DIR/licenses(/data/licensesin the container) or whereverModules__LicensePathpoints. The gateway reads the folder again about every 30 seconds.
An import that the gateway understands but does not take, because the file is for another installation or is an older version of a licence it already holds, answers 200 with accepted set to false and the reason. Something that is not a licence file answers 400. GET /api/v1/licensing lists every file the gateway holds under files, with whether it counts and, when it does not, why.
Upgrading a licence
Files that share a licence id are one licence in versions. The one with the highest serial is the current one. Changing a licence at the licensing service (its customer, kind, support date, what it entitles, or the installation it is for) makes a newer version in the same way: nothing about a licence is edited in a file, and every change is a new signed version. An upgrade is a newer file of the same licence: the gateway fetches it when it asks, or you import it as you imported the first. An older file never takes the place of a newer one, and a newer file may drop an entitlement, which stops that module until a licence names it again. Files with different licence ids add up.
Support renewals and entitlements with an end
A licence is perpetual, and support is the part that is bought for a time: a code that renews it only moves the Support until date and changes nothing else. An entitlement can have an end of its own, as with a subscription. What it gives keeps working for 14 days after that date, so a late renewal does not stop a plant, and then the module it covered is stopped and says that the licence for it ended. The gateway judges this while it runs, not only when a module starts. The Entitlements table on the Licensing page shows, under the end, how long it still runs or when it stopped, and in the API each entitlement has expiresAt and stopsAt. A renewal is a newer version of the licence with a later end: redeem the code, fetch it or import it, and the module starts again without a restart.
Withdrawn keys and vendors
A root key can withdraw an issuer key, which signs licences, or a package key, which signs modules, or a vendor as a whole. It does that by signing a revocation list. The gateway's build carries the list that was current when the build was made. A gateway that can reach the licensing service takes newer lists when it asks for its licence, every 6 hours with call home on or when an administrator presses Check for a newer licence. The service publishes the newest list it was given at GET /revocations.
A gateway holds to these rules:
- It takes only a list that a root signed, checked against the roots built into it. The licensing service cannot withdraw anything on its own say.
- Lists only add up. An older list adds what it names and takes nothing back, and a newer list that leaves something out does not give it back.
- It keeps what it took across restarts, in the gateway database with the licences.
- It acts at once, with no restart.
What a withdrawal does on a gateway that has the list:
| What was withdrawn | What happens |
|---|---|
| An issuer key | The licences it signed stop counting, and their entries in files say why. A licensed gateway goes into grace: 14 days with everything running, under a banner, until a licence signed by another key arrives |
| A vendor, or a package key of one | The modules the vendor signed, or that key signed, stop. Each shows the state tampered, and its error says that the vendor or the key has been revoked |
A gateway that cannot reach the licensing service has the list that came with its build, and gets newer ones with its next update.
GET /api/v1/licensing reports what the gateway knows in revocations: issuedAt (when the newest list is from), keys and subjects (how many keys and vendors are withdrawn), or null when it knows of none.
The installation id and the activation request
A licence is issued for an installation id. It is made at the gateway's first start and is the same identifier that the check-in reports as instanceId. The Licensing page and the instanceId field of GET /api/v1/licensing show it.
A gateway with no internet connection cannot ask for a licence itself. Download activation request on the Licensing page, or GET /api/v1/licensing/activation-request as an administrator, gives a small file with the installation's instanceId, its instanceName (the value of SCADEX_INSTANCE_NAME, or none), product and requestedAt. It holds nothing else, so it can travel by any channel. Take it, with the code if there is one, to wherever the licence is turned into a file (see "Without internet"). Carry the file back and import it.
Checking a licence file needs no network: the gateway checks it against public keys built into it. Only redeeming a code and asking for newer versions call the licensing service.
Backup and restore
The installation id, the trial and the imported licence files are kept in the gateway database, in the table LicensingEntry. A backup carries them and a restore brings them back. A file copied into the licenses folder is not in the database and not in a backup: keep it beside the backup.
What is not built yet, and what this does not stop
- Buying a licence is not built. There is no storefront and nothing takes payment, in the gateway or in the licensing service: a code is one the company made.
- The page on the company's website that turns a licence into a file, and moves one, for a gateway that cannot reach the internet, is being built and is not live yet.
- Redeeming a code and asking for newer versions have been tried inside one test process against the licensing module, and not against the company's own collector.
- A licence file cannot be taken back from a gateway that is offline, and a revocation list reaches one only with its next update. A module that a vendor withdraws is gone from a gateway that is online the next time it asks, and a gateway that is offline keeps its file. A licence that was moved stays valid on the installation it was moved from.
- An administrator can reset the trial as often as wanted. The checks run inside the gateway, on the machine that runs it, so patching the gateway removes them.
Settings and API
| Setting | Default | Meaning |
|---|---|---|
Licensing__TrialMinutes | 120 | The trial's length in minutes |
Modules__LicensePath | <DATA_DIR>/licenses | The folder whose *.license files count |
SCADEX_LICENSE_URL | the SCADEX_CALL_HOME_URL gateway | The gateway that runs the licensing service. The gateway adds /api/v1/modules/io.scadex.licensing to it |
SCADEX_LICENSE_INTERVAL_MINUTES | 360 (6 hours) | How often the gateway asks for newer versions, 1 to 1440 |
These are environment variables, read when the gateway starts. The asking by itself also needs SCADEX_CALL_HOME on. See Configuration.
| Route | Role | What |
|---|---|---|
GET /api/v1/licensing | viewer | The state, the installation id, the trial's time left and resets, who it is licensed to, support until, the entitlements (expiresAt, stopsAt), the files, build, revocations and online |
POST /api/v1/licensing/import | admin | Takes a licence file |
POST /api/v1/licensing/redeem | admin | Redeems a code at the licensing service and takes the licence it returns |
POST /api/v1/licensing/fetch | admin | Asks the licensing service now for newer versions and for the list of withdrawn keys, and takes them |
POST /api/v1/licensing/trial/reset | admin | Gives the trial back |
GET /api/v1/licensing/activation-request | admin | The installation id and name |
Only an administrator can import a licence, redeem a code, ask for newer versions or reset the trial: a person, or a script holding an administrator key. A key with any other role cannot. The answer of GET holds state, instanceId, suspended, detail, trial (lengthSeconds, remainingSeconds, resets), customer, kind, supportUntil, evaluationEndsAt, graceEndsAt, build (builtOn, support), entitlements, files, revocations and online. In the TypeScript SDK the calls are client.licensing.get(), import(license), redeem(code, customer?), fetch(), resetTrial() and activationRequest().