{"id":22271161,"url":"https://github.com/cryptolens/license-server","last_synced_at":"2025-10-06T21:53:12.940Z","repository":{"id":40854892,"uuid":"164626604","full_name":"Cryptolens/license-server","owner":"Cryptolens","description":"License server that can be installed by your clients on-premise, especially if they have machines that need to be offline.","archived":false,"fork":false,"pushed_at":"2024-04-25T12:32:47.000Z","size":198,"stargazers_count":29,"open_issues_count":2,"forks_count":8,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-26T10:25:22.967Z","etag":null,"topics":["cryptolens","license-server","linux","mac","offline","windows"],"latest_commit_sha":null,"homepage":"https://cryptolens.io/products/license-server/","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Cryptolens.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2019-01-08T10:41:40.000Z","updated_at":"2024-04-25T12:15:35.000Z","dependencies_parsed_at":"2024-04-25T10:25:20.935Z","dependency_job_id":"b918a3a1-f96c-4cbd-9d5d-a8861792f74d","html_url":"https://github.com/Cryptolens/license-server","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cryptolens%2Flicense-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cryptolens%2Flicense-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cryptolens%2Flicense-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cryptolens%2Flicense-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Cryptolens","download_url":"https://codeload.github.com/Cryptolens/license-server/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227914220,"owners_count":17839245,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cryptolens","license-server","linux","mac","offline","windows"],"created_at":"2024-12-03T12:10:52.591Z","updated_at":"2025-10-06T21:53:07.911Z","avatar_url":"https://github.com/Cryptolens.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# License Server\n\n\u003e **Note**: a seprate subscription is required to use the license server: https://cryptolens.io/products/license-server/\n\n## Idea\n**Problem**: Large companies tend to have strict policies that restrict certain machines to have direct internet access. This is a problem if we want license files on them to be up-to-date.\n\n**Solution**: We allow one computer, the *license server*, to have internet access. All the machines in the network will contact the license server and it will in turn contact Cryptolens. Alternatively, the *license server* can store a copy of the license files and work offline.\n\n![](example.png)\n\n## Getting started\nSince v2.12-rc, there are two ways you can configure the server. Either, you can use the [pre-built version](https://github.com/Cryptolens/license-server/releases) of the server or you can use the configuration string from [this page](https://app.cryptolens.io/extensions/LicenseServer?OfflineMode=False\u0026LocalFloatingServer=False) and build the server yourself.\n\n### Using the pre-built license server\nYou can use our [pre-built binaries](https://github.com/Cryptolens/license-server/releases) for all use cases (including the **local floating license server** feature).\n\nWhen you use the binaries, you can either store the configuration in the config file (as we describe later), configure the server using environment variables (read more [here](#alternative-ways-to-configure-the-server)) or pass on the configuration as a command line variable (read more [here](#providing-the-configuration-string-as-command-line-argument)).\n\nPlease keep in mind that the license server will **only read the environment variables** or the **-config command line parameter** if you run it as a service (read more [here](#providing-the-configuration-string-as-command-line-argument)), unless you set `cryptolens_configurationstring` environment variable with the configuration string from [this page](https://app.cryptolens.io/extensions/LicenseServer).\n\nTo sum up, you can start the server in two ways:\n1. If you choose to use environment variable, you would need to set `cryptolens_configurationstring` to the configuration string.\n2. If you instead want to supply the configuration string as a command line argument, you can start the server using as follows:\n```\nLicenseSerer.exe -config \u003cthe configuration string\u003e\n```\n3. By using a `config.json` file (not recommended).\n\n### Building the server yourself\nIf you need the local floating license server and cannot use environment variables or pass the configuration string as a command line argument as described [here](#alternative-ways-to-configure-the-server), the license server needs to be compiled on your end to create the binaries. All configuration is stored inside the `ConfigurationFromCryptolens` variable in `Program.cs`, which can be created on [this page](https://app.cryptolens.io/extensions/LicenseServer?OfflineMode=False\u0026LocalFloatingServer=False). In other words, there is no need to provide any arguments when calling the license server or use an external configuration file.\n\nThe license server can be compiled on most operating systems and the process is as follows:\n\n#### Install .NET\nTo install .NET, visit https://dotnet.microsoft.com/en-us/download/dotnet/6.0 and download the SDK (i.e. not the runtime).\n\n#### Configuring the server\nThere are three steps involved:\n\n1. Visit [the configuration page](https://app.cryptolens.io/extensions/LicenseServer?OfflineMode=False\u0026LocalFloatingServer=False) to create a configuration that will make the server work in standard mode.\n2. Copy the configuration string and paste it in the `ConfigurationFromCryptolens` variable in `Program.cs`.\n3. Environment variables can also be used to change configuration data for a specific user. Please read more [here](#alternative-ways-to-configure-the-server).\n\nLater in this tutorial, there are examples of calling the license server using command line arguments. We recommend to use the configuration string as described in (1) if possible. If you have any questions, please reach out to us at support@cryptolens.io.\n\n#### Building the server\nTo build the server, you can run the following command in the folder that contains the `LicenseServerCore.sln` file:\n\n```\ndotnet build LicenseServerCore.sln --configuration Release\n```\n\nFrom now on, you can use the instructions further down on this page to launch the executable.\n\n## Starting the server\n\nIn order to launch the server, you need to run `LicenseServer.exe` as an administrator (you can download it [here](https://github.com/Cryptolens/license-server/releases)). The default port is 8080 but this can be changed.\nOne way of doing it is to run CMD as an administrator and then type the command below:\n\n```\nC:\\\u003e LicenseServer.exe 5000\n```\n\nFor newer versions of the license server, you can [this configuration](https://app.cryptolens.io/extensions/LicenseServer?OfflineMode=False\u0026LocalFloatingServer=False\u0026Port=5000) to set the port to 5000.\n\n\u003e Please make sure to check that this port is open so that other computers in the network can access it (shown below).\n\n### Running as a Windows service\nIf you would like to run the license server as a service on Windows, you can accomplish that as described [here](#running-the-license-server-as-a-service).\n\n### Running on Linux and Mac\nTo run the license server on either Linux or Mac, you need to make sure that .NET 5 runtime or later is installed (read more [here](https://dotnet.microsoft.com/download/dotnet/5.0)). Once it is installed, the license server can be started as follows:\n\n```\ndotnet LicenseServer.dll\n```\n\nIn the rest of the article, you just need to add `dotnet` before launching the server. Everything else is the same. Based on our tests, no sudo access is needed to run the license server on Linux.\n\n## Allowing ports (Windows only)\n\nIn order to allow other computers in the network to access the license server, you need to open up the desired port in the firewall. \nIf you use the default firewall, it can be opened as follows:\n\n1. Run `wf.msc`\n2. Right click on **Inbound Rules** and then click on **Add Rule**\n3. Ryle type should be **Port**\n4. **Specific local ports** should be checked, and the textbox at the right of it should be set to 5000 (or any other port of your choosing).\n5. Click next through the entire wizzard and that should be it.\n\n## Connect to the server\n\nDepending on which of our client SDKs you use, there will be a different way to provide the URL of the license server. For example, if you use the [.NET SDK](https://github.com/Cryptolens/cryptolens-dotnet), every API method (such as Key.Activate) will have an extra parameter `LicenseServerUrl`, which can be used to provide the URL of the license server.\n\n## Additional features\n\nThere are two versions of the license server, `v1.*` and `v2.*`. If you only need the request forwarding feature, `v.1.*` version will suffice. If you want to use the extra features listed below, you can use `v2.*` version instead.\n\n### Enable caching of licenses\nSince v2.0 there is a way to cache responses to `Key.Activate`, which helps to reduce the number of requests sent to Cryptolens. This is useful especially if your clients would have temporary internet connectivity issues. To enable license caching, you need to specify how long the license server should store each license. Note: if your application uses the `signatureExpirationInterval` parameter in `HasValidSignature`, the lifetime of the cache on the license server needs to be either equal to `signatureExpirationInterval` or less. Otherwise, your client application will throw an error.\n\nAs an example, to launch the server that caches licenses for 10 days, it can be started as follows:\n\n```\nC:\\\u003e LicenseServer.exe 8080 10\n```\n\nFor newer versions of the license server, you can use [this configuration](https://app.cryptolens.io/extensions/LicenseServer?OfflineMode=False\u0026LocalFloatingServer=False\u0026CacheLength=10\u0026Port=8080) instead.\n\n#### Customers who are permanently offline\nThe default behaviour of the server is to *always* attempt to get the latest copy of the license. However, if you know that the license server will not have access to the internet, it is better to enable the *offline mode* so that the license server always reads from cache.\n\nTo enable offline mode, you can launch the server as follows (or use [this configuration string](https://app.cryptolens.io/extensions/LicenseServer?OfflineMode=True\u0026LocalFloatingServer=False\u0026CacheLength=10\u0026Port=8080)):\n\n```\nC:\\\u003e LicenseServer.exe 8080 10 work-offline\n```\n\nIn this case, it is a good idea to provide the license files (aka. activation files) that you want to load into the server. You only need to do it once or when the cache needs to be updated. If the license file (with a `.skm` extension) is in the *Downloads* folder, it can be loaded as follows (or use [this configuration string](https://app.cryptolens.io/extensions/LicenseServer?OfflineMode=True\u0026LocalFloatingServer=False\u0026CacheLength=10\u0026Port=8080\u0026ActivationFileFolder=C:\\Users\\User%20Name\\Downloads)):\n\n```\nC:\\\u003e LicenseServer.exe 8080 10 work-offline \"C:\\Users\\User Name\\Downloads\"\n```\n\nIf you want to load a specific list of files and folders, they can be separated by a semi-colon ';'.\n```\nC:\\\u003e LicenseServer.exe 8080 10 work-offline \"C:\\Users\\User Name\\Downloads\";\"C:\\temp\\file.skm\"\n```\n\n##### Floating licenses offline\nIf you want to use [floating licensing](https://help.cryptolens.io/licensing-models/floating) in offline mode (for example, to restrict the maximum number of containers a user can start), it can be done as follows:\n\n1. Visit [https://app.cryptolens.io/extensions/licenseserver](https://app.cryptolens.io/extensions/licenseserver) and copy the \"License server configuration\" and \"RSA Public Key\".\n2. When verifying the signature inside your application, please use the RSA Public Key on this page instead of the one you would normally use when your application can access our API. This key will only work with the license server that uses the configuration above.\n3. In the license server project, paste the value of \"license server configuration\" to `ConfigurationFromCryptolens` variable in `Program.cs`. In newer versions, you can choose to place the configuration string in an environment variable (`cryptolens_configurationstring`) or by supplying it as a command line argument (**-config**).\n4. Compile the license server in release mode.\n5. In the release folder, create a new folder called \"licensefiles\".\n6. Visit the [product page](https://app.cryptolens.io/Product) and click on the yellow button next to the license key that belongs to your client (to manage all activations). Now, click on \"Download activation file\" and put this file into the \"licensefiles\" folder created earlier.\n7. You can now send the license server (in the release folder, including all the files and folders) to your client.\n\n\u003e **Note (for .NET users)** For the time being, `Key.Activate` needs to be called the same way as the in the Unity example: https://help.cryptolens.io/getting-started/unity\n\n```cs\n// call to activate\nvar result = Key.Activate(token: auth, productId: 3349, key: \"GEBNC-WZZJD-VJIHG-GCMVD\", machineCode: \"foo\", floatingTimeInterval: 150, LicenseServerUrl: \"http://192.168.0.2:8080\");\n\n// obtaining the license key (and verifying the signature automatically).\nvar license = LicenseKey.FromResponse(\"RSAPubKey\", result);\n```\n\u003e **Note** If the local license server is enabled, floating license status will not be synchronized with Cryptolens, even if online mode is enabled. Moreover, GetKey request will return the information stored on the local license server and sign it using the local license server's private key. This means that if you have enabled floating licensing offline, you need to use public key that was shown on the [configuration page](https://app.cryptolens.io/extensions/LicenseServer) for both `Activate` and `GetKey` requests.\n\nIf you need to deactivate machine earlier, you can use the Deactivate method with `Floating=true`, similar to the way it would have been done when calling Cryptolens' Web API:\n\n```cs\nvar result = Key.Deactivate(\"\", new DeactivateModel { ProductId = 3349, Key = \"key\", MachineCode = \"machine\", LicenseServerUrl = \"http://192.168.0.2:8080\", Floating = true });\n```\n\nTo obtain the list of all activated floating machines, you can use the GetKey call:\n\n```cs\nvar result = Key.GetKey(token: \"\", productId: 3349, key: \"\", LicenseServerUrl: \"http://192.168.0.2:8080\");\n\n// obtaining the license key (and verifying the signature automatically).\nvar license = LicenseKey.FromResponse(\"RSAPubKey\", result);\n```\n\n##### Usage-based licensing offline\nIf the license server is set to work offline, it is still possible to collect information about usage (that is stored in data objects) and bill your clients for it.\nAt the time of writing, only data objects associated with a license key can be used.\n\nTo get started, please follow the same steps as described in the [floating license offline](#floating-licenses-offline) section. When creating the configuration file, please make sure that _offline mode_ is enabled.\n\nWhen this is done, all usage information will be stored in the \"usage\" folder. The structure of the logs is described here: [https://eprint.iacr.org/2021/937](https://eprint.iacr.org/2021/937)\n\n\u003e **Note:** The license file in the `licensefiles` folder needs to have the data objects that will be incremented or decremented. Otherwise, the license server will throw an error.\n\n\n### Loading settings from a config file\n\n\u003e **Note** In newer versions of the license server, we recommend to create a [configuration string](https://app.cryptolens.io/extensions/LicenseServer?OfflineMode=False\u0026LocalFloatingServer=False) as described in the beginning of this page.\n\nTo make it easier to deploy the license server on customer site, you can add all settings into `config.json` in the same folder as the server. The structure of the configuration file is shown below:\n\n```\n{\n    \"Port\" : 8080,\n    \"CacheLength\": 365,\n    \"OfflineMode\" : True,\n    \"ActivationFiles\" : [\"C:\\Users\\User Name\\Downloads\"]\n}\n```\n\nThe `ActivationFiles` can either reference a specific file or a folder. If it references a folder, all files with the `.skm` extension will be loaded.\n\n\n### Running the license server as a service\nThe license server can run as a Windows service in the background. This can be accomplished as follows (using [sc](https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/sc-create)). Note, these commands need to be ran as an Administrator:\n\n```\nsc create license-server binpath=\"D:\\path\\to\\licenseserver\\LicenseServer.exe\" start=auto\nnet start license-server\n```\n\nNote: the path to the license server needs to be absolute. It's important that you provide a configuration string that can be obtained at can be obtained on [https://app.cryptolens.io/extensions/licenseserver](https://app.cryptolens.io/extensions/licenseserver). When creating a new configuration, please set **Activation file folder** to an absolute path. For example, **C:\\license-files**. \n\nOnce you have the configuration string, you have three ways that you can start the server:\n\n#### If you have compiled the server yourself\n1. Copy the configuration string that you obtained above into `ConfigurationFromCryptolens` variable and build the License Server yourself.\n\n#### If you are using the pre-built binaries\n1. Create an environment variable `cryptolens_configurationstring` with the configuration string from above.\n2. Supply the configuration string (from above) as a command line argument when registering LicenseServer.exe as a service, as follows:\n```\nsc create license-server binpath=\"D:\\path\\to\\licenseserver\\LicenseServer.exe -config \u003cthe configuration string\u003e\" start=auto\n```\n\nWe have tested the license server version that targets .NET Framework 4.6.1.\n\nBelow are other useful commands:\n```\nsc stop license-server\nsc queryex license-server\nsc delete  license-server\n```\n\n\u003e To obtain information about server status, e.g. the IP it is listening or if any errors have occurred, you can use the Windows Event log.\n\nIf you need any help, please let us know at support@cryptolens.io.\n\n### Alternative ways to configure the server\n\n#### Using environment variables\n\nIt is also possible to configure the license server using environment variables. For now, the license server will only read the environment variables in two cases:\n\n1. If the `ConfigurationFromCryptolens` in Program.cs is not null or empty.\n2. If license server runs as a service (Windows).\n\nFor example, if you prefer to use the environment variables, you can set `ConfigurationFromCryptolens` to any string value and then rely on the environment variables. Alternatively, you can create a configuration string at https://app.cryptolens.io/extensions/licenseserver and then set \"path to config file\" to `USE_ENVIRONMENT_VARIABLES`.\n\nCryptolens uses the following environment variables:\n\n| Name   | Description      |\n|----------|-------------|\n| `cryptolens_offlinemode` | Specifies if the license server should contact the central server (if set to false) or rely on the cached version if such exists (if set to true). When set to true, the license server will at first try the cache before attempting to contact the license server. |\n| `cryptolens_port` | The port to use. |\n| `cryptolens_activationfilefolder` | The path to the folder with activation files. Please set it to an absolute path when running the license server as a service. |\n| `cryptolens_cachelength` | The amount of days until a new license file should be obtained. |\n| `cryptolens_pathtoconfigfile` | The path to the configuration file. This can be useful if you anticipate that your clients might need to change certain properties more often, and then it may be easier to change the file rather than restarting the machine (which is often required for the environment variables to take effect). For now, you can set the port and the folder to the activation files. If you plan to run the server as a service, please set this to absolute path.|\n| `cryptolens_cachefolder` | Path to the cache folder. If you plan to run the server as a service, please set this to absolute path. |\n| `cryptolens_configurationstring` | An optional parameter that you can use to provide the configuration string that would normally need to be added in the code. The license server will always check for this environment variable at start and it will have priority over command line arguments.|\n\n\u003e **Note**: when running the license server as a service, all paths to files and folders need to be **absolute**.\n\n#### Providing the configuration string as command line argument\n\nSince version v2.13, you can pass on the configuration string as a command line argument, meaning that you can start the server as follows:\n\n```\ndotnet LicenseServer.exe -config \u003cpaste configuration string here\u003e\n```\n\nThe configuration string can be obtained at [https://app.cryptolens.io/extensions/licenseserver](https://app.cryptolens.io/extensions/licenseserver).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcryptolens%2Flicense-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcryptolens%2Flicense-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcryptolens%2Flicense-server/lists"}