We have now finalized the last bits that were left to make the C++ client API more reliable and easier to integrate. This is great news if you develop applications in C++ (for instance, drivers, connected products as a service, IoT products, and more).
Right now, it offers the activation method, which is the method that should always be called to either verify or activate a license. If there are other methods that you would find useful, please get in touch with us.
The project has been lead by Martin Svedin, Lead Developer.
On the technical side
Our client API in C++ is quite different from its .NET counterpart. The main difference is in error handling, the protocol under the hood and the ability to perform API requests outside of our API (which uses curl by default). Extensions functions (ability to chain together several constraints together) in the C++ client are similar to the .NET client.
How to perform activation
In the .NET client, the only object you need is LicenseKey. In the C++ client, there is a similar class called LicenseKey (which contains license key parameters such as features). However, in order to retrieve a LicenseKey object, you cannot just call the activation method. Instead, you need to use an intermediate class called RawLicenseKey. That is, when you call the activation function, it will return a RawLicenseKey, which can be used to create a LicenseKey object.
The only difference between RawLicenseKey and LicenseKey is that the former one contains signature whereas the latter one does not. If you want to support offline activation, you should save RawLicenseKey object (the license and the signature, as described here). However, when you verify the license parameters, LicenseKey should be used instead.
Adding a chain of constraints on LicenseKey object is very similar to the way it is done in .NET. For example, in .NET, to check that feature 1 is enabled and the key has not expired, you would type:
licenseKey.HasNotExpired().HasFeature(1).IsValid() // returns true if the constraints are satisfied
In the C++ client, it’s quite similar:
license_key->check()->has_not_expired(123456789)->has_feature(1) // returns true if the constraints are satisfied
A minor difference is that has_not_expired requires the current time as a Unix time stamp in seconds.
Public Key extraction
Another point worth mentioning is how you insert your public key (not the access token) into the C++ client. You can find your RSA public key here that has a structure similar to the one below:
When you specify the modulus and exponent, you can just copy them directly from your public key as shown below:
skm_handle.signature_verifier.set_modulus_base64(e, "sGbvxwdlDbqFXOMlVUnAFgteQ=="); skm_handle.signature_verifier.set_exponent_base64(e, "AQAB");
This has to be done before any activation request is sent, as shown here.
This was a short summary of the C++ client, with focus on users that are familiar with our .NET client. For further information, please see the GitHub repository and API documentation Please get in touch with us should you have any questions! One more thing, please review the third party licenses when you are ready to release your application.