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
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