cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
RangaPro
Level 4

Validate license file without installing it

Hi,

We are using File Based Licensing, and currently I'm looking for any API which allows me to check if the license file is valid without actually installing it via the Flexera API.

 

Context:

We have a need to know the individual license file details (expiry, count etc) in the cases where uses has access to multiple licenses for the same feature but since since flexera doesn't expose this information, we planned to read it manually from the license file.

https://community.flexera.com/t5/FlexNet-Publisher-Forum/Multiple-overlapping-licenses-for-the-same-feature-with/td-p/125436

 

Thanks!

0 Kudos
(8) Replies
raffie
Level 6

If you just want to read the count, expiry, etc, then you can use lc_get_config/lc_next_conf to read the lines and get that data out of the CONIFG structure.    These are just text parsers so they don't ensure that everything is valid.  You can use lc_test_conf, which I think validates the data since it requires a test checkout first (but I've never used this).

 

0 Kudos
aparashar1
Flexera Alumni

@RangaPro , i am afraid that as of nw, there isn't any way through which we can query the details of a license file - unless and until it is being served (/installed).

However, as of now our engineering team is working on a "license validator utility", which does exactly what you are looking for. The work is in progress and it may not be ready till end of the quarter.

Kindly do let me know your Account details(as i can only see a gmail ID with your user account), so that i can ensure that once the utility is GA ready, it gets communicated to you.

(If my response assists with your questions , then please click "ACCEPT AS SOLUTION" or 'Kudos' so that it help others.)
0 Kudos
RangaPro
Level 4

@raffie Thank you Raffie. I will try it out!

 

@aparashar1 I unfortunately don't have the account details as I am just using the company wide floating license. I will check out later for sure for that tool.

0 Kudos

@aparashar1 @raffie 

 

I tried with the lc_check_key example from Flexera sample, and i am able to fetch the license information. Only problem seems to be that the api is not giving correct response for valid/invalid license files (e.g with tampered dates or signatures). For e,g in case of valid files too , I am getting a bad param (-42) error.

I am using the below code :

 

static void get_lic_details(lm_job) LM_HANDLE *lm_job;
{
  char **featlist;
  CONFIG *conf;
  char *err;
  
	lc_log(lm_job, "get_lic_details(lm_job)\n");

	for (featlist = lc_feat_list(lm_job, 0, 0); featlist && *featlist;	featlist++)
	{
	   CONFIG *pos;

		for (pos = 0, conf = lc_next_conf(lm_job, *featlist, &pos);
				conf;
				conf = lc_next_conf(lm_job, *featlist, &pos))
		{
			char respCodeStr[10], licCount[10], licString[1024];
			int respCode = 1;

			strcpy(licString,"");
			strcat(licString,"Feature - ");
			strcat(licString,conf->feature);
			strcat(licString," - Expiry Date - ");
			strcat(licString,conf->date);
			strcat(licString," - Lic Count - ");
			itoa(conf->users,licCount,10);
			strcat(licString,licCount);
						
			strcat(licString," - IsValidLicense - ");
			
			respCode = lc_check_key(lm_job, conf, &code);
			if (respCode != 0)
			{
				strcat(licString," No - ");
				strcat(licString, lc_errstring(lm_job));
			}
			else
			{
				strcat(licString," Yes - ");				
			}		
			
			strcat(licString,itoa(respCode,respCodeStr,10));
			
			strcat(licString,"\n");
			lc_log(lm_job, licString);			
		}
	}
	
	lc_log(lm_job, "\n End check_file(lm_job)\n");
}

 

Any help would be great 🙂

 

Thanks!

0 Kudos

I've never used lc_check_key, but maybe it doesn't work in an application.  The doc has this line:

"This function is optional and only for use during license installation; it is not used in an application that also calls lc_checkout."

Since you are using lc_log, I assume you are in your application and connected to the license server.  If so, then you can just do a test checkout (also mentioned in the doc for lc_check_key).

0 Kudos

I come across this thread and wonder if this could be used in our license creating tool. Several colleagues are using copy+paste in case of customers with multiple products and are sometimes creating invalid license files by mistake.

One missing gap in the code above is how to retrieve the feature list of a license code which is not stored in a file, but just as a string in a variable. I guess lc_set_attr for  LM_A_LICENSE_FILE_PTR does not provide a syntax for having a memory based license file. Is there another attribute which could be used for this purpose?

Achim Schön

 

0 Kudos

If you create an lm_job and pass that buffer to LM_A_LICENSE_DEFAULT (the buffer needs to be properly formatted, search the doc for "License in a buffer") then you can use the normal APIs like lc_feat_list to get the feature list.

@raffie

Thanks, that was exactly for which I was searching.
0 Kudos