Infralution Support Forum Index Infralution Support
Support groups for Infralution products
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Authenticated licensing for DLL

 
Post new topic   Reply to topic    Infralution Support Forum Index -> Licensing Support
View previous topic :: View next topic  
Author Message
santosh



Joined: 10 Jan 2019
Posts: 23

PostPosted: Fri Jan 11, 2019 5:06 am    Post subject: Authenticated licensing for DLL Reply with quote

We make a .NET developer tool that consists of several controls for many of the UI frameworks (WinForms, WPF, Xamarin, ASP.NET), some components and also some libraries (functionality exposed via classes and methods). We have been using ILS for encrypted licenses so far and now were planning to move to authenticated licenses. I understand that ILS provides support for WinForms and WPF dialogs out of the box and we will have to implement the support for Xamarin. I also learned from one of the forum posting that it's possible to have a single license for multiple controls and components by having a common license provider. However I need to figure out how to deal with the licensing for the simple DLL case.

One of the solutions for the DLL case I was thinking about is for us to write a Visual Studio extension that will validate the design-time authenticated license (initiated through a custom menu option provided by the extension) and then provision the run-time license in the application resource so that the DLL can verify it at run-time. This is similar to what happens with the control/component except that instead of doing it in the constructor it will done one-time by the developer using the IDE custom menu option. Essentially the extension with have two menu options. First is to activate an authenticated license and store the activation details on the developer machine. Second is to provision a run-time license to the currently selected project/solution. The second menu item will only be enabled once the design-time license has been provisioned. Do you see any issues achieving this with ILS?
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Sat Jan 12, 2019 4:55 am    Post subject: Reply with quote

That sounds like a reasonable plan. One thing to consider is that it only helps having different runtime and design time licenses if there are functions the developer needs at design time that you can disable in the runtime license. If this is not the case then someone could just extract the runtime license from a distributed application and use it themselves for design time.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
santosh



Joined: 10 Jan 2019
Posts: 23

PostPosted: Thu Jan 17, 2019 3:48 pm    Post subject: Reply with quote

Thank you for the response. Yes, I understand about the possibility of simply copying the DLLs from the distributed app and using them. I was thinking of making this a little more harder to beat by having two encrypted licenses generated using the authenticated license. One is embedded as a resource in the app (so can easily be copied). The second one is to be coded in the developer's app by calling a method into our DLL and passing the license key for validation. Though I haven't tried this yet I presume ILS can generate more than one encrypted license key from an authenticated license. Come to think of it does having the first license (the embedded one) add any additional layer of copy protection in this case?

I have started the implementation of the extension and I will get back if I run into any issues. Meanwhile I had a few questions regarding the API:

  • AuthenticatedLicenseProvider.StartBackgroundReauthentication takes two parameters (reauthenticationInterval and retryInterval). I understand that if I want to reauthenticate immediately I need to pass 0 as the first param. If so then does the thread continue to reauthenticate every 24 hours after the first immediate reauth?
  • Is there anyway to know to get a count of failed reauthentications? By failed I mean the case where the auth server was not reachable.
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Thu Jan 17, 2019 10:24 pm    Post subject: Reply with quote

Quote:
If so then does the thread continue to reauthenticate every 24 hours after the first immediate reauth?


If you select zero for this parameter then reauthentication will only happen once (after the method is first called).

Quote:
Is there anyway to know to get a count of failed reauthentications? By failed I mean the case where the auth server was not reachable.


The software does not track this by default - but you could fairly easily modify the source code (which we provide on purchase) to track this.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
santosh



Joined: 10 Jan 2019
Posts: 23

PostPosted: Tue Jan 22, 2019 8:32 am    Post subject: Reply with quote

This relates to the earlier discussion about having two encrypted license keys generated (at design time) for run time validation. I can see that one encrypted license key gets generated and stored on the developer machine and this is what is returned later via the AuthenticatedLicense.EncryptedLicenseKey property.

Is it possible to create two different encrypted license keys both derived from the same authenticated license key? I tried calling the API AuthenticatedLicenseProvider.GetEncryptedLicenseProvider().GenerateRuntimeKey() by passing the design time license key. However this method is returning an empty string.

Also I was curious how the (run time) encrypted license key is distributed to the end user machine. I know the XML file containing the run time key is stored on the developer machine. The Microsoft documentation https://docs.microsoft.com/en-us/dotnet/api/system.componentmodel.licensecontext?view=netframework-4.7.2 states that the LicenseContext class must be extended for supporting design time licenses but I didn't find any ILS code for this.
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Tue Jan 22, 2019 9:45 pm    Post subject: Reply with quote

Quote:
Is it possible to create two different encrypted license keys both derived from the same authenticated license key? I tried calling the API AuthenticatedLicenseProvider.GetEncryptedLicenseProvider().GenerateRuntimeKey() by passing the design time license key. However this method is returning an empty string.


Yes. The AuthenticatedLicense.EncryptedLicenseKey returns a license which is valid when the LicenseContext usageMode is set to DesignTime. The GenerateRuntimeKey method allows you to generate a different EncryptedLicenseKey which is only valid when the usage mode is Runtime. You need to pass the GeneratedRuntimeKey method a valid EncryptedLicense Key (not an AuthenticatedLicenseKey). To get this you should call it like below:
Code:

string runtimeKey = licenseProvider.GetEncryptedLicenseProvider().GenerateRuntimeKey(license.EncryptedLicenseKey);


Quote:
Also I was curious how the (run time) encrypted license key is distributed to the end user machine. I know the XML file containing the run time key is stored on the developer machine. The Microsoft documentation https://docs.microsoft.com/en-us/dotnet/api/system.componentmodel.licensecontext?view=netframework-4.7.2 states that the LicenseContext class must be extended for supporting design time licenses but I didn't find any ILS code for this.


The EncryptedLicenseProvider and AuthenticatedLicenseProvider classes inherit from the system base class LicenseProvider and override the GetLicense method. Licensed controls use the "LicenseProviderAttribute" to designate an associated LicenseProvider class. The forms designer then autmatically creates an instance of the license provider and calls GetLicense when compiling the code that uses the control and passes a LicenseContext. The license provider uses this context to save (and retrieve) runtime license keys into the compiled license.resources which are linked into the call application.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
santosh



Joined: 10 Jan 2019
Posts: 23

PostPosted: Wed Jan 23, 2019 5:36 am    Post subject: Reply with quote

Thanks, I was able to generate an additional runtime license key using the code you provided. So one of the runtime key I can use is AuthenticatedLicense.EncryptedLicenseKey and the other is the one I get from the code you provided. Both of these should validate successfully at runtime.

Regarding the second question about embedding the encrypted license key for runtime validation do you know how exactly this is being done by the control licensing framework? I couldn't find any additional resource entries or resource files being created apart from the "licenses.licx" file which just contains an entry of the licensed control and not the license key itself. As I mentioned in my first post I need to do this via the VS extension so that the case where the developer uses our control (or simply DLL) without a designer is covered. Basically I need to provide an option in the VS extension to "install" the runtime license into the app by embedding the first encrypted license key into the current project.
Back to top
View user's profile Send private message
santosh



Joined: 10 Jan 2019
Posts: 23

PostPosted: Wed Jan 23, 2019 6:14 am    Post subject: Reply with quote

santosh wrote:
Regarding the second question about embedding the encrypted license key for runtime validation do you know how exactly this is being done by the control licensing framework?


I think I figured this out. A decade and half old article here explains the process very well Laughing
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Wed Jan 23, 2019 9:59 pm    Post subject: Reply with quote

Yes that is a nice article on the topic.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Infralution Support Forum Index -> Licensing Support All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group