Labs64 / NetLicensingClient-cpp

C++ wrapper for Labs64 NetLicensing RESTful API
https://netlicensing.io
Apache License 2.0
10 stars 4 forks source link

API for node locked licensing module. #8

Open Ponsanthini0708 opened 1 month ago

Ponsanthini0708 commented 1 month ago

I have tried to set the productModuleValidation parameters and also the nodeSecret as mention in the documentation. I am trying to validate the licensee key which has two models combined i.e, Subscription + nodelocked licensing model. These are things I have tried out. `Context ctx; ctx.set_base_url("https://go.netlicensing.io/core/v2/rest/"); ctx.set_api_key("efa71f48-8968-4fc7-a9ed-bb343caba28e"); ctx.set_security_mode(Context::APIKEY_IDENTIFICATION); ValidationParameters vParams = ValidationParameters(); vParams.setProductModuleValidationParameters(productModuleNumber, "paramKey", "paramValue"); vParams.setLicenseeSecret(licenseeSecret); ValidationResult vRes = LicenseeService::validate(ctx, licenseeNumber, vParams); std::string temp = vRes.toString(); const char* validationResult = temp.c_str(); printf("%s\n",validationResult);

Output which I got when printing validationResult : ValidationResult [ProductModule<MGWYST7N9>{expires=2025-05-08T13:22:28.057Z, licensingModel=Subscription, productModuleName=Ultraziq Evaluation Module, productModuleNumber=MGWYST7N9, valid=true, warningLevel=GREEN}]

But when I tried printing the validationResult, the nodleocked module didn't get reconized itself, I can see only the Subscription module details. Am I missing out something ? `

r-brown commented 1 month ago

Hello @Ponsanthini0708 ,

As advised in this NetLicensing Community topic https://github.com/orgs/Labs64/discussions/140 please make sure you specify nodeSecret parameter in the validation request. So, your request may look like this:

    ValidationParameters vParams = ValidationParameters();
    vParams.setProductModuleValidationParameters(productModuleNumber, "nodeSecret", "device-fingerprint");
    vParams.setLicenseeName(licenseeName);
    vParams.setProductNumber(productNumber);
    ValidationResult vres = LicenseeService::validate(ctx, licenseeNumber, vParams);
    std::cout << "Validation result for created licensee:\n" << vres.toString() << std::endl;

Please also make sure, that:

Ponsanthini0708 commented 1 month ago

Hello R.Brown, Thanks for your response. I have tried the same and evaluated the validation results of both the modules. But it seems the licensee key is working in all the machines, and it is not locked to specific machine after one time of usage. I have tried out this :

        Context ctx;
        ctx.set_base_url("https://go.netlicensing.io/core/v2/rest/");
        ctx.set_api_key("efa71f48-8968-4fc7-a9ed-bb343caba28e");
        ctx.set_security_mode(Context::APIKEY_IDENTIFICATION);
        ValidationParameters vParams = ValidationParameters();

vParams.setProductModuleValidationParameters(productModuleNumber, "nodeSecret", "2d715e98-dd0c-47e2-916b-8869337866a2"); vParams.setLicenseeName(licenseeName); vParams.setProductNumber(productNumber); ValidationResult vRes = LicenseeService::validate(ctx, licenseeNumber, vParams); std::string temp = vRes.toString(); const char validationResult = temp.c_str(); const char firstOccurrence = strstr(validationResult, "valid=true"); const char secondOccurrence = firstOccurrence ? strstr(firstOccurrence + 1, "valid=true") : nullptr; bool isValidModule1 = firstOccurrence != nullptr; bool isValidModule2 = secondOccurrence != nullptr; printf("%d %d\n",isValidModule1,isValidModule2); printf("%s\n",validationResult); if (isValidModule1 && isValidModule2) { const char expiryDate = strstr(validationResult, "expires="); uhdkit_log(NULL, UHDKIT_LOG_INFO, "UHDkit License: %s is valid; Expires on %.10s %.8s\n", licenseeNumber, expiryDate + 8, expiryDate + 19); } I got both the modules output validation to be true.

On Fri, 10 May 2024 at 10:46, R.Brown @.***> wrote:

Hello @Ponsanthini0708 https://github.com/Ponsanthini0708 ,

As advised in this NetLicensing Community topic https://github.com/orgs/Labs64/discussions/140 please make sure you specify nodeSecret parameter in the validation request. So, your request may look like this:

ValidationParameters vParams = ValidationParameters();
vParams.setProductModuleValidationParameters(productModuleNumber, "nodeSecret", "device-fingerprint");
vParams.setLicenseeName(licenseeName);
vParams.setProductNumber(productNumber);
ValidationResult vres = LicenseeService::validate(ctx, licenseeNumber, vParams);
std::cout << "Validation result for created licensee:\n" << vres.toString() << std::endl;

Please also make sure, that:

— Reply to this email directly, view it on GitHub https://github.com/Labs64/NetLicensingClient-cpp/issues/8#issuecomment-2103881305, or unsubscribe https://github.com/notifications/unsubscribe-auth/A3AAZQOEQKXHBRHSXN5C4WDZBRJ2ZAVCNFSM6AAAAABHPQP5KCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMBTHA4DCMZQGU . You are receiving this because you were mentioned.Message ID: @.***>

r-brown commented 1 month ago

@Ponsanthini0708 in the case you submit always the same request and the same machine fingerprint (e.g. "2d715e98-dd0c-47e2-916b-8869337866a2") as shown on you code snippet above - you will always get the same result.

vParams.setProductModuleValidationParameters(productModuleNumber,
"nodeSecret", "2d715e98-dd0c-47e2-916b-8869337866a2");

Please make sure, that your machine fingerprint routine returns an unique fingeprint.

Ponsanthini0708 commented 1 month ago

I have create a client node locked module and also created the secret which I have auto generated there. I am passing that auto generated key to the productModuleValidation().If i give this nodeSecret in some other machine,I hope it should not work and pop out a message,No new nodes present. Each time if i send a new secret key,how it would compare it with the secret which i have created under the client node locked module?

On Fri, 10 May 2024 at 12:33 PM, R.Brown @.***> wrote:

@Ponsanthini0708 https://github.com/Ponsanthini0708 in the case you submit always the same request and the same machine fingerprint (e.g. "2d715e98-dd0c-47e2-916b-8869337866a2") as shown on you code snippet above

  • you will always get the same result.

vParams.setProductModuleValidationParameters(productModuleNumber, "nodeSecret", "2d715e98-dd0c-47e2-916b-8869337866a2");

Please make sure, that your machine fingerprint routine returns an unique fingeprint.

— Reply to this email directly, view it on GitHub https://github.com/Labs64/NetLicensingClient-cpp/issues/8#issuecomment-2104019266, or unsubscribe https://github.com/notifications/unsubscribe-auth/A3AAZQILRUP7WEUQQ4N75UDZBRWKXAVCNFSM6AAAAABHPQP5KCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMBUGAYTSMRWGY . You are receiving this because you were mentioned.Message ID: @.***>

r-brown commented 1 month ago

Obtaining of the machine fingerprint is the responsibility of the vendor. Generated machine ID or fingerprint need to be generated on-the-fly and passed as value for nodeSecret. The verification of the pairing nodeSecret to licenseeNumber is performed by the NetLicensing during the validation call.