squagel
Posts: 4
Joined: Fri Aug 03, 2012 1:00 am

License Server issue

Hello. I have implemented the ASP.NET (C#) example of a license server for my application.

I have also confirmed that the communication channel from the AI registration dialog in my application and my license server is working.

However, the AI Registration dialog always returns "the registration key is invalid".

Code: Select all

     
                String data = "";
                if (compID != null)
                    data += "COMP_ID=" + compID;
                data += "ID=" + ID;
                if (MP != null)
                    data += "MP=" + MP;
....
                // compute signature
                byte[] dataToSign = Encoding.Unicode.GetBytes(data);
                byte[] signature = rsaProvider.SignData(dataToSign, new SHA1CryptoServiceProvider());

                // Step 4 - Respond with the license elements
                // if your license has a Maintainance Plan element (or any other elements) add them in alphabetical order
                string responseData = $"ID={ID};MP={MP};SIGN={Convert.ToBase64String(signature)}";

                SendResponse(200, responseData);
I added some logging to the server to log the incoming values and the exact response I'm sending back:

New Request: ID=squagel@gmail.com; COMP_ID=5260331983682616;
Request Response: ID=squagel@gmail.com;MP=03/05/2022;SIGN=IDJBReIlv1X2+F1Y9A/G7Ia0eGcVRPejw3p/6tNe9L9Rhya84/oLZ9aDCIIUsjOQ

If I manually enter the same ID, COMP_ID and MP date into the "Generate Registration Keys" dialog in AI, I get the exact same signature value so I'm confident that I'm computing it correctly.

Is there any way to debug what might be causing the error in the licensing dialog? I think I have followed the instructions to the letter but Is my response string not properly formatted perhaps?

Any help would be much appreciated.
AI Registration settings
AI Registration settings
registration settings.png (58.16 KiB) Viewed 21090 times
The error message
The error message
reg key invalid.png (33.08 KiB) Viewed 21090 times
Generate License dialog
Generate License dialog
generate license.png (24.07 KiB) Viewed 21090 times
Daniel
Posts: 8238
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: License Server issue

Hi,

I really cannot say why this happens. Maybe it has to do with the encoding you use when computing the digital signature or with an invisible character included in the license elements string/signature. Can you please make sure the license elements are merged into an UTF-16LE encoded string before being computed their digital signature?

Also, could you share with us your .AIP (setup project) file and a download link of your built setup package so we can fully test the scenario on our side? If so, just send us your .AIP file alongside a setup download link by email at support at advancedinstaller dot com. And also any test case we should follow to replicate the behavior.

If you cannot share with us your setup project file, then you can try to isolate the behavior in a buildable sample (.aip + its referenced files) which we can build and test on our side.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”