This is the native library used for server side licensing in Advanced licensing solutions.
The zip file here contains binaries for
- Windows x86
- Windows x64
- Linux x86
- Linux x64
- Linux arm
- Linux arm64
- MUSL x64 (Alpine Linux)
- MUSL arm64 (Alpine Linux)
- MacOS arm64 (Apple)
- MacOS x64 (Intel)
Server side licensing uses a client key and a server key. The first time a chart is created on the client, a validation challenge is generated using the client key and this is sent to the server (by default to /api/license?orderid={orderId}&challenge={challenge}). The server needs to pass the challenge to the SciChart native library which has had the server key set, and return the response to the client. The result is that the application can be deployed to any domain, including localhost. Note that the communication is only between the client and its originating server. It does not require outside internet access. The validation result is stored in a cookie on the client, so this validation only needs to occur once per week per client.
- Read SciChart Advanced Licensing and ensure you have complied with the contractual requirements. At minimum this means having a BUNDLE license and commititing to maintain at least 1 active license for the lifetime of your project.
- Contact sales@scichart.com to sign the necessary agreement. Once the necessary license type and agreement is in place, Advanced Licensing will be enabled for your license. This adds new functionality to the Licenses section of the My Account Page page which will enable you to generate the key pairs needed.
- On the My Account page, add your application name as an OEM or Embedded License App Name, then click to Show Runtime Keys and copy the client and server keys
The required code flow is as follows
On server start
- Call SetAssemblyName, passing the name of your application which needs to match the name you set on the MyAccount page.
- Call SetRuntimeLicenseKey passing the server key.
- If the call to SetRuntimeLicenseKey returns 0 (ie false), there is something wrong with the server key. Call GetLicenseErrors to find out what.
On a request to /api/license
- Extract the value of the querystring parameter 'challenge'.
- Pass this to ValidateChallenge which returns a response string.
- Check that the response string does not start with "Error". If it does, the response will give some explanation for the error.
- Return the response to the client as text, not json.
The api is exposed from the native library in a few different ways.
For interop scenarios where you will be loading and calling the library dynamically, we suggest you use the methods prefixed by SciChartLicenseServer_. These are marked extern 'C' and their signatures are as follows
void SciChartLicenseServer_SetAssemblyName(char* name)
int SciChartLicenseServer_SetRuntimeLicenseKey(char* key)
char* SciChartLicenseServer_ValidateChallenge(char* challenge)
char* SciChartLicenseServer_GetLicenseErrors()
void SciChartLicenseServer_SetTimeTolerance(int timeTolerance)For the functions that return char* you should free the buffer that is returned.
If you are using C / C++ and can link against the library statically, you can call the underlying LicenseServer class. Its header is as follows.
namespace SciChart {
enum class SCRTLicenseType
{
/// Invalid but informs the user a trial is being requested.
LICENSE_TYPE_NO_LICENSE = 0,
/// Trial - Valid but with trial notices
LICENSE_TYPE_TRIAL = 0x02,
/// Community - Watermark but no expiry
LICENSE_TYPE_COMMUNITY = 0x03,
/// Full - Valid
LICENSE_TYPE_FULL = 0x20,
/// Full expired - For Non-perpetual (web)
LICENSE_TYPE_FULL_EXPIRED = 0x04,
/// Trial expired - Invalid
LICENSE_TYPE_TRIAL_EXPIRED = 0x40,
/// Subscription expired - build is after expiry date
LICENSE_TYPE_SUBSCRIPTION_EXPIRED = 0x80,
/// Invalid developer license - Invalid machine specific license
LICENSE_TYPE_INVALID_DEVELOPER_LICENSE = 0x0F,
/// License that requires server validation
LICENSE_TYPE_REQUIRES_VALIDATION = 0x2F,
/// Invalid license - Invalid runtime license
LICENSE_TYPE_INVALID_LICENSE = 0xFF
};
namespace LicenseServer {
void ResetRuntimeLicense();
bool SetAssemblyName(const std::string& _assemblyName);
/// Sets the Runtime License ( narrow string version ).
/// Returns true passed license key is valid; otherwise false.
bool SetRuntimeLicenseKey(const std::string& _strKey);
/// The tolerance in seconds between the time when the challenge was generated and when it was processed. Default 300.
/// If your server does not have reliable time synchronisation you can increase this value or set it to 0 to disable time based validation completely.
void SetTimeTolerance(int timeTolerance)
/// Gets a type of the Runtime License.
SCRTLicenseType GetLicenseType();
/// Determines whether the Runtime License is valid.
bool CheckLicenseValid();
/// Gets the OrderId of the current license
std::string GetOrderId();
/// Gets the reason for the license failure
std::string GetLicenseErrors();
/// Decode and check challenge. Generate response with encrypted expiry
std::string ValidateChallenge(const std::string& _challenge);
/// Dumps the information of the Runtime License to returned string.
std::string Dump();
}
}For our .net integration there is a swig generated wrapper which exposes the methods prefixed with CSharp_, eg CSharp_SetAssemblyName. These use a different method for passing string which involves registering a callback. In C# this is done as follows
protected class SWIGStringHelper {
public delegate string SWIGStringDelegate(string message);
static SWIGStringDelegate stringDelegate = new SWIGStringDelegate(CreateString);
[global::System.Runtime.InteropServices.DllImport("SciChartLicenseServer", EntryPoint="SWIGRegisterStringCallback_SciChartLicenseServer")]
public static extern void SWIGRegisterStringCallback_SciChartLicenseServer(SWIGStringDelegate stringDelegate);
static string CreateString(string cString) {
return cString;
}
static SWIGStringHelper() {
SWIGRegisterStringCallback_SciChartLicenseServer(stringDelegate);
}
}Then you can call CSharp_ValidateChallenge. You can also register a callback to enable exception handling, but there are no meaningful exception thrown.