Home All Groups Group Topic Archive Search About

checksignature always returning false

Author
10 Apr 2006 3:53 PM
Chris
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

Author
11 Apr 2006 6:44 AM
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."
Author
11 Apr 2006 7:10 AM
Chris
Thanks but that didn't help.

Also I tried converting my signing code to dot net 2 but also the resulting
signedxml's would not "CheckSignature" under dot net 2 but under .net 1.1

find attached a textfile containing a signedxml

and a file with the public key.

I have also provided a class with the signing and verification code (but
have left out the privatepublic key)

Chris


Show quote
"Kevin Yu [MSFT]" <v-k***@online.microsoft.com> wrote in message
news:dQay4NTXGHA.2428@TK2MSFTNGXA01.phx.gbl...
> 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."
>

[attached file: TestSigning.vb]
[attached file: PublicKey.xml]
[attached file: testsignedxml.xml]
Author
11 Apr 2006 3:56 PM
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)"



Show quote
"Chris" <ceckl@nosam.nospam> wrote in message
news:u0snIcTXGHA.3760@TK2MSFTNGP02.phx.gbl...
> Thanks but that didn't help.
>
> Also I tried converting my signing code to dot net 2 but also the
> resulting signedxml's would not "CheckSignature" under dot net 2 but under
> .net 1.1
>
> find attached a textfile containing a signedxml
>
> and a file with the public key.
>
> I have also provided a class with the signing and verification code (but
> have left out the privatepublic key)
>
> Chris
>
>
> "Kevin Yu [MSFT]" <v-k***@online.microsoft.com> wrote in message
> news:dQay4NTXGHA.2428@TK2MSFTNGXA01.phx.gbl...
>> 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."
>>
>
>
>
Author
12 Apr 2006 12:08 PM
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."

AddThis Social Bookmark Button