This message was discovered on microsoft.public.dotnet.languages.vb.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
| Nak |
Hi there,
I just made my own license provider (at last!) that uses signed XML license files. When the license provider gets the license it does the following,
*At runtime
1) Gets the signed XML license file from the calling assemblys resources 2) Gets the public RSA key from the calling assemblys resources 3) Attempts the validate the signature
*At design time
1) Gets the signed XML license file from same path the binary is executing from (i.e. Obj\Debug or Obj\Release) 2) Gets the public RSA key from same path the binary is executing from (i.e. Obj\Debug or Obj\Release) 3) Attempts the validate the signature
This works fine, and it seems to be quite a reliable method of control licensing with 1 exception. It's damn slow!
Check this out, I timed the creation and disposal of 2 types of control, 1 licensed via my method and 1 not licensed at all. I timed how many could be created in 1 minute in both circumstances and these were my results,
* I created 3,456,717 un-licensed controls in 1 minute
* I created 438 licensed controls in 1 minute
On closer inspection it turns out that the GetLicense method starts at about 578ms then jumps around 94ms and 250ms each time. So obviously this greatly reduces the speed of creating large numbers of controls. I would ideally like to speed this up and I believe that there is a way to cache the license file and possibly the public key too.
So that leaves me asking if anyone has any idea how I can create my own LicenseContext class and get it passed to my license provider so that I can use the SetSavedLicenseKey and the GetSavedLicenseKey methods (unless of course there is another way around this). I have found an example from the Windows Forms web site that creates a licensed component class, but I'm not quite sure if this is what I need or not as this would intil creating lots of derived classes from the licensed one.
Anyways, thanks for your time and I look forward to any suggestions!
Nick.
|
|
| |
| |
| Peter Huang (VIP) |
Hi Nick,
Here is the link about create customlicensecontext, you may take a look. http://www.windowsforms.net/Samples/download.aspx?PageId=1&ItemId=123&tabind ex=4
Best regards,
Peter Huang Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security This posting is provided "AS IS" with no warranties, and confers no rights.
|
|
| |
| |
| Nak |
Hi Peter,
<quote>... "I have found an example from the Windows Forms web site that creates a licensed component class, but I'm not quite sure if this is what I need or not as this would intil creating lots of derived classes from the licensed one."
I know it was a bit of a long question so never mind. I think I have just found out something quite interesting. *ALL* Licensed objects via a license provider are "slowass" at being created in comparrison to unlicensed controls, which would explain any bottle necks in my application. My PC is making around 749,862 standard LicFileLicenseProvider licensed controls in 1 minute too.
I have thought of 1 idea to help speed up the process but it doesnt seem to make any difference, I have created a custom attribute that allows you to specify the public key to verify the XML file with, it seems that retrieving data from an assemblys resources actually takes very little time. So at the moment I am looking for another bottle neck and all I can think it is; is that the license key for that type is *not* being cached, if it were it would take very little to no time at all to create the 2nd object.
I *think* this is all the licene context does, *but* the example on Windows Forms does *not* use a license provider and I must as I am wanting to license any class via my own license provider so that I can in-turn sell this product as a licensing solution. Surely other XML based licensing systems arent this slow so it must be something I'm missing! :-(
Nick.
""Peter Huang"" <Click here to reveal e-mail address> wrote in message news:Click here to reveal e-mail address... [Original message clipped]
|
|
| |
| |
| Nak |
Hi again,
Even more scary results, I have managed to implement a custom LicenseContext by altering the license managers context when my application loads, now it caches the resource file in the form of a string in a hashtable and the public key is passed via a custom attribute but it is *still* as slow as a sloath swimming in molasses! So this leads me to believe that it is the XML signature verification that is slow, this is my routine,
-----------------------------------
Private Function verifyViaString(ByVal iType As Type, ByVal iLicense() As Byte, ByVal iPublicKey As String) As Boolean Try
'Firstly we load the XML license from a byte array into a memory stream
Dim pMSmInput As New MemoryStream(iLicense)
'Then we load it into the XML document object
Dim pXDtXMLDoc As New XmlDocument() Call pXDtXMLDoc.Load(pMSmInput)
'Then we create a new signature object
Dim pSXlSigned As New SignedXml(pXDtXMLDoc) Dim pXNeSig As XmlNode = pXDtXMLDoc.GetElementsByTagName("Signature", SignedXml.XmlDsigNamespaceUrl)(0) Call pSXlSigned.LoadXml(CType(pXNeSig, XmlElement))
'Then we set the public key to verify with
Dim pStrKey As String = iPublicKey
'The following check is used as an internal precauting within my application
If (Not (pStrKey Is Nothing)) Then
'Then we create the CSP object to verify the signature with
Dim pRSACrypto As RSACryptoServiceProvider = New RSACryptoServiceProvider() Call pRSACrypto.FromXmlString(pStrKey)
'Lastly we verify the signature
If (pSXlSigned.CheckSignature(pRSACrypto)) Then Return (True) End If End If Finally End Try End Function
-----------------------------------
My understanding is that this is as fast as this method could possibly be, but surely slowing it down as much as it is is not a viable solution. Has anyone any ideas on how I can speed this little method up maybe? Or an alternative method?
Nick.
"Nak" <Click here to reveal e-mail address> wrote in message news:Click here to reveal e-mail address... [Original message clipped]
|
|
| |
| |
| Nak |
AAaaah, and dumb I surely am!
I was caching the license keys in the context but still verifying them, and in theory if a license key has already been verified in order to be cached there is no point in verifying it again, so I just create a new license with that key and return it straight away! Bobs your aunty or whatever and now over 1 million licensed controls per minute! ;-)
Nick.
"Nak" <Click here to reveal e-mail address> wrote in message news:Click here to reveal e-mail address... [Original message clipped]
|
|
| |
| |
| Peter Huang (VIP) |
Hi Nick,
It is cool that you have resolved the problem. Cheers!
Best regards,
Peter Huang Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security This posting is provided "AS IS" with no warranties, and confers no rights.
|
|
| |
|
|
|
|
|
|
|
|
|