checksignature always returning false

G

Guest

I have the following code that in the 1.1 framework worked (signatures are
generated with a 1.1 application)
Since we converted our application to 2.0 the checksignature method always
returns a false.

What has changed?

I can supply the testlicence and the constPublicXMLKey strings if necessary.

Thanks

Chris


Imports System.Security.Cryptography
Imports System.Security.Cryptography.xml
Imports System.Xml



Public Class Form1


Dim testlicence As String = "xxx"



Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

MsgBox(CheckLicense(testlicence))
End Sub

Public Shared Function CheckLicense(ByVal inputXML As String) As String

Try
Dim constPublicXMLKey As String = "xxx"


Dim cspParams As New CspParameters
cspParams.Flags = CspProviderFlags.UseMachineKeyStore
Dim rsaKey As RSACryptoServiceProvider = New
RSACryptoServiceProvider(cspParams)

' Create a SignedXml.

Dim MYsignedXml As New SignedXml

Dim objRSAkeyPair As RSA = RSA.Create()


objRSAkeyPair.FromXmlString(constPublicXMLKey)

Dim keyInfo As New keyInfo

keyInfo.AddClause(New RSAKeyValue(objRSAkeyPair))

MYsignedXml.KeyInfo = keyInfo ' Load the SignedXML Document


Dim xmlDocument As New XmlDocument

xmlDocument.PreserveWhitespace = True

xmlDocument.LoadXml(inputXML) 'Verify the Signature



Dim nodeList As XmlNodeList =
xmlDocument.GetElementsByTagName("Signature")

MYsignedXml.LoadXml(CType(nodeList(0), XmlElement))

If MYsignedXml.CheckSignature() Then
Return "True"
Else
Return "False"
End If

Catch ex As Exception
Throw ex

End Try

End Function





End Class
 
K

Kevin Yu [MSFT]

Hi Chris,

Here is a similar problem to your scenario.

http://lab.msdn.microsoft.com/ProductFeedback/viewFeedback.aspx?feedbackid=4
8766f6b-12eb-41dc-97c5-46cbcf60f272

Please try the resolution to see if it works for you.

If that doesn't work, please provide us with the testlicence and
constPublicXMLKey string which can return a true in .NET 1.1, and return
false in .NET 2.0, so that we can make a repro.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
C

Chris

This is resolved with the following solution curtesy of MS support:
I've modified the way your code uses the public key and now it works in .NET
1.1 and .NET 2.0. I've attached the modified code to this email.


I've just removed these three lines:

"

Dim keyInfo As New KeyInfo

keyInfo.AddClause(New RSAKeyValue(objRSAkeyPair))

MYsignedXml.KeyInfo = keyInfo ' Load the SignedXML Document

"

And changed "Return MYsignedXml.CheckSignature()" to "Return
MYsignedXml.CheckSignature(objRSAkeyPair)"
 
K

Kevin Yu [MSFT]

It was nice to hear that you have had the problem resolved. Thanks for
sharing your experience with all the people here. If you have any
questions, please feel free to post them in the community.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top