cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
ArjaaAine
Level 3

Setting up Trusted Storage for FNE

I have been going through the documentation and I haven't yet been able to find a way to setup trusted storage in FlexNet Embedded.

Could someone please point me in the right direction?
Labels (1)
0 Kudos
(11) Replies
RobertDickau
Flexera Alumni

The combination of the storage, path, and binding callouts handles setting up trusted storage. The default implementations use files as trusted storage. In the FlexNet Embedded User Guide, the "Trusted Storage Overview" section of Chapter 5, "Implementing FlexNet Embedded Callouts", describes what's going on.

The "capability request" example (among others) uses these callouts to create and read from trusted storage, as appropriate.
__________________
Robert Dickau - FlexNet Embedded Engineering - Flexera Software
0 Kudos
ArjaaAine
Level 3

Oh, great thanks for the response. I was able to understand how trusted storage works!

I have a smaller issue in regards with trusted storage now though.



Using the demo toolkit, I setup a local license server and requested a license from my local machine. The license was stored in Trusted storage.

Using the demo examples/builds. I can read the trusted storage no problems.
But when I try to read the TS from my own code, it gives me that the trusted storage is corrupted error.

My own program can read and process .bin files without a hitch.

The only part of the code that I needed to add to make it read from a trusted storage was: "Creating a trusted storage License Source" (Program fails here)
and
"Adding the Trusted Storage License source in the License Source Collection".

And Adding the appropriate libraries.


Any ideas? (Greatly appreciate any help in advance)
0 Kudos
RobertDickau
Flexera Alumni

For a first guess, does a comparison between the example projects' code and your project's code make anything jump out? Have you changed any of the callouts? If you're using the API-based server and not the prebuilt server application, could the server's and client's trusted storage be overwriting each other?

__________________
Robert Dickau - FlexNet Embedded Engineering - Flexera Software
0 Kudos
ArjaaAine
Level 3

No, the comparison doesn't reveal anything which jumps out.
To get a working prototype.. I have followed the same order and same Calls as the example code.


My License Server and Local Client (which created the TS) are both in the same machine, so yes the TS is being used by both. But if the example client project was able to read the TS.. I am at loss why my code (which is supposed to replicate the client example) fails to read it.

For reference, here are my calls:



FlxLicenseSourceRef tsLicenseSource = 0;
if ( !FlxLicenseSourceCreateFromTrustedStorage(
&tsLicenseSource,
identity,
error))
{
CLicenseHelper::DisplayErrorMessage(_T("creating license source from trusted storage"), error);
return FLX_FALSE;
}

/* add trusted storage license source to the license source collection */
if ( !FlxLicenseSourceCollectionAdd(
licenseSources,
tsLicenseSource,
error) )
{
CLicenseHelper::DisplayErrorMessage(_T("adding trusted storage license source to collection"), error);
return FLX_FALSE;
}


Red is where it fails.

I looked in the example code, and Besides these two calls.. I don't see anything that needs to be added to a working Binary License Reader. (Assuming all the other libraries and helper classes are intact).
0 Kudos
RobertDickau
Flexera Alumni

Just to clarify, you'll need to verify that the client and server aren't using the same path callout implementation. The default projects are set up to use anchoring-0 and storage-0 for the client and srvanchoring-0 and srvstorage-0 for the server, with the different names used to avoid collisions.
__________________
Robert Dickau - FlexNet Embedded Engineering - Flexera Software
0 Kudos
ArjaaAine
Level 3

Yes, the path callouts are not the same. I can see all 4 of the files.. and I checked. Both servers and clients are not using the same callout.

nonetheless, if they were indeed usign the same callout.. I wouldn't have been able to read the TS from any program. But the fact that the demo examples can read the TS whereas my App can't baffles me.
0 Kudos
RobertDickau
Flexera Alumni

In that case, it would appear to be some difference in the implementation of the examples and the new project, which is difficult to diagnose without seeing the new project's code.

(I'm sure you've sorted it out, but the code described in those documentation sections you mentioned earlier in this thread are abridged from the toolkit samples. Copying sections of code from the samples rather than copying from the PDF could conceivably have a bearing on it.)

If that doesn't address it, if you're evaluating or a have a support contract, it might be better to go through Support for a closer analysis...
0 Kudos
ArjaaAine
Level 3

I have copied the code from the Samples rather than just the pdf.

I had assumed the problem is what you determine here: Some discrepancy in my code compared to the sample code.


/*Create error object with 512 bytes of space to store external error data */
FlxErrorRef error = 0;
if (!FlxErrorCreate(&error, 512) )
{
CLicenseHelper:: DisplayErrorMessage(_T("Creating error object"), 0);
return false;
}

/*Create an Identity*/
FlxIdentityRef identity = 0;
if (!FlxIdentityCreate(
&identity,
identity_data,
sizeof(identity_data),
error))
{
CLicenseHelper:: DisplayErrorMessage(_T("creating identity object"), error);
return false;
}

/*Get The License File Contents*/
FlxUInt8 * buffer = 0;
FlxSize bufferSize = 0;

/* create trusted storage license source */
FlxLicenseSourceRef tsLicenseSource = 0;
if ( !FlxLicenseSourceCreateFromTrustedStorage(
&tsLicenseSource,
identity,
error))
{
CLicenseHelper:: DisplayErrorMessage(_T("creating license source from trusted storage"), error);
return FLX_FALSE;
}

/* create license source collection */
FlxLicenseSourceCollectionRef licenseSources = 0;
if ( !FlxLicenseSourceCollectionCreate(&licenseSources, error) )
{
CLicenseHelper:: DisplayErrorMessage(_T("creating license source collection"), error);
return FLX_FALSE;
}

/* add trusted storage license source to the license source collection */
if ( !FlxLicenseSourceCollectionAdd(
licenseSources,
tsLicenseSource,
error) )
{
CLicenseHelper:: DisplayErrorMessage(_T("adding trusted storage license source to collection"), error);
return FLX_FALSE;
}

/* Create publisher */
FlxPublisherRef publisher = 0;
if ( !FlxPublisherCreate(
&publisher,
error) )
{
CLicenseHelper:: DisplayErrorMessage(_T("creating publisher object"), error);
return FLX_FALSE;
}

/*Acquire License Information*/
TCHAR msg[512] = {0};
if ( CLicenseHelper::sAcquireLicense(
publisher,
licenseSources,
featureName,
featureVersion,
1,
error) )
{
_stprintf(msg, _T("acquired %s license"), featureName);
CLicenseHelper:: DisplayMessage(msg,_T("INFO"));
return true;
}

/* cleanup */
if ( !CLicenseHelper::sCleanup(
identity,
publisher,
tsLicenseSource,
licenseSources,
buffer,
&error) )
{
return false;
}
CLicenseHelper:: DisplayMessage(msg,_T("deleted client objects"));

return false;



Above is the code where I took out the needful API elements from the sample.
CLicenseHelper is my own class which has again snippets of the code from the samples.


If there is something which glares out as a possible problem. Otherwise I will try a brand new project.
0 Kudos
RobertDickau
Flexera Alumni

Without seeing the implementation of the helper classes, it's difficult to say for sure, but the overall flow looks correct. It still sounds like some difference between the SDK example code and the new sample code.

(Another thing to check is that the identity data used in the server was generated at the same as the identity data used in the client, but that would typically result in a different error from the one you describe. Just to be precise, what is the error code/message you're seeing when you create the trusted storage license source?)
0 Kudos
ArjaaAine
Level 3

static FlxBool ReadFileData(
const TCHAR * fileName,
FlxUInt8 ** buffer,
FlxSize * bufferSize,
FlxErrorRef error)

Used to read the Binary License File, Not used in TS read.

static void DisplayMessage(
LPCTSTR msg,
LPCTSTR caption)

Just the Display Message method

static void DisplayErrorMessage(
LPCTSTR msg,
FlxErrorRef error)
Defines All the errors.

static FlxBool sAcquireLicense(
FlxPublisherRef publisher,
FlxLicenseSourceCollectionRef licenseSources,
const FlxChar * const featureName,
const FlxChar * const featureVersion,
FlxInt32 count,
FlxErrorRef error)
{
FlxLicenseRef license = 0;
TCHAR msg[512] = {0};

/*----------------------------------------------------------------------*/
if ( !publisher || !licenseSources || !featureName || !featureVersion || !count || !error )
{
DisplayErrorMessage(_T("acquiring license"), 0);
return false;
}

/* acquire license */
if ( !FlxPublisherAcquireLicenses(
publisher,
&license,
licenseSources,
featureName,
featureVersion,
count,
0,
0,
error) )
{
_stprintf(msg, _T("acquiring %s license"),featureName);
DisplayErrorMessage(msg, error);
return false;
}

//GetLicenseDetails not really needed for this part//

/* return license */
if ( !FlxPublisherReturnLicenses(publisher, &license, error) )
{
_stprintf(msg, _T("returning %s license"), featureName);
DisplayErrorMessage(msg, error);
return false;
}

/*----------------------------------------------------------------------*/
return true;
}


The thing about the helper class is that the program gives the error while it tries to create a truste storage License source.
At the methord: FlxLicenseSourceCreateFromTrustedStorage

The error is:

case FLXERR_TS_CORRUPTED:
return _T("Trusted storage is corrupted.");


I haven't had time to rebuild the project yet. But I am going to start from scratch and try it again, but if you can see anything else that I am not able to see It will save a lot of time haha.

But thanks for your help so far.
0 Kudos
ArjaaAine
Level 3

lol.

It worked... and I didn't have to do anything. Just delete Trusted Storage files and make new ones.


Weird that the demo application read those old files and not my app.
0 Kudos