SDKs
...
Tutorials
Best Practices

Virtual Machine Detection

12min
node locking's essence lies in associating a distinct, often hardware based, identifier with each device this unique marker, frequently derived from hardware ids, serves to correlate licenses to devices however, complexities arise in virtualized and containerized setups in these scenarios, the apparent hardware isn't the physical device's, but that of the generating virtual machine fortunately, licensespring tackles this challenge adeptly through methods tailored for containers and virtualization these methods effectively discern various virtual contexts, ensuring precise environment identification and steadfast license to device locking this tutorial will introduce you to licensespring's sophisticated techniques for distinguishing virtual machine instances and how they can reinforce your software security prerequisites completed the getting started docid\ lsfy9tq3vfq4roow9shkd tutorial, specifically initialized licensemanager (or licensehandler ) with your configuration using the appropriate settings created a licenseid using either licenseid fromkey or licenseid fromuser function, depending on the activation method you prefer implemented basic license management, including license activations, deactivations, and both online and local license checks working with virtual machines the licensespring sdks offer a distinctive feature the capability to detect virtual machine environments supported vms vm name java c++sdk net sdk parallels desktop qemu virtualbox windows virtual pc vmware wine xen project docker microsoft hyper v microsoft azure bhyve freebsd jail kvm lxc lguest linux vserver openvz project acrn virtual iron qnx hypervisor enabling virtual machine detection this functionality, designed to enhance software security, can be activated manually within your program through the sdk as shown below extendedoptions options; options >enablevmdetection( true ); std shared ptr\<configuration> configuration = configuration create( encryptstr( "xxxxxxxx xxxx xxxx xxxx xxxxxxxxxxxx" ), encryptstr( "xxxxxxxxx xxxxx xxxxxxxxxxxxx xxxxxx xxxxxx" ), encryptstr( "xxxxxx" ), appname, appversion, options );var options = new licensespring extendedoptions(); options enablevmdetection = true; var configuration = new licensespring configuration( apikey "xxxxxxxx xxxx xxxx xxxx xxxxxxxxxxxx", sharedkey "xxxxxxxxx xxxxx xxxxxxxxxxxxx xxxxxx xxxxxx", productcode "xxxxxx", appname "name", appversion "version", extendedoptions options ); note virtual machine detection is disabled by default this feature must be enabled to make use of any features mentioned throughout this tutorial we provide a separate dll for vm detection in the c++ sdk package make sure you put this library with the licensespring dll if it is not found, a vmdnotavailableexception will occur detecting whether virtual machine detection is enabled after the configuration has been initialized, developers are able to detect whether virtual machine detection is currently activated with if ( configuration >isvmdetectionenabled ) { //vm detection is enabled }if ( configuration isvmdetectionenabled ) { //vm detection is enabled } within the c++ sdk, this can also be checked through the extendedoptions object, as shown below if ( options >isvmdetectionenabled ) { //vm detection is enabled } detecting whether a user is on a virtual machine the sdks can also check for whether a specific user currently using the application is on a virtual machine by using if ( configuration >isvm() ) { //the user is currently running on a vm }if ( configuration isvm ) { //the user is currently running on a vm } retrieving detected virtual machine name developers can get the name of the user's hypervisor with the following vmname = configuration >getdetectedvmname()vmname = configuration getdetectedvmname() vmdnotavailableexception (windows only) thrown in the c++ and net sdk in the case that vm detection dll is not found, tempered or detection failed preventing virtual machine access you can also prevent users from activating their licenses on virtual machines by adjusting the license settings simply access the license and select the "prevent virtual machine" option this straightforward step ensures that your product remains exclusively operational on the intended devices, aligning with your software's specifications prevent virtual machine when this feature is checked off, any actions involving our license, will result in an error/exception, making the license unusable on a vm within the sdk, developers can check for whether a license is allowed to work under virtual machine or not with if ( license >isvmallowed ) { //vm detection is enabled } vmisnotallowedexception thrown on virtual machine when vm detection is enabled but product policy prohibits running on vm