Home All Groups Group Topic Archive Search About

SignedXml fails under .NET 2.0 Beta

Author
5 Mar 2005 9:34 PM
Gabriel
Hi,

I'm using the following code to check signed xml files:

SignedXml signedXml = new SignedXml();
//  http://support.microsoft.com/default.aspx?scid=KB;EN-US;322371
CspParameters cspParams = new CspParameters();
cspParams.Flags = CspProviderFlags.UseMachineKeyStore;
RSACryptoServiceProvider rsaPublicKey = new
RSACryptoServiceProvider(cspParams);
rsaPublicKey.FromXmlString(xmlPublicKey);
KeyInfo keyInfo = new KeyInfo();
keyInfo.AddClause(new RSAKeyValue(rsaPublicKey));
signedXml.KeyInfo = keyInfo;

XmlNodeList nodeList = licenseData.GetElementsByTagName("Signature");
signedXml.LoadXml((XmlElement)nodeList[0]);

return signedXml.CheckSignature();

This code works great under .NET 1.x and it FAILS under .NET 2.0 Beta.
Do you know why?
Thanks in advance.

PS: xmlPublicKey contains the public key of course.

Author
7 Mar 2005 11:24 AM
Gabriel
In reality the code does not fail, CheckSignature method always
returns FALSE under .NET 2.0 Beta 1.

Please advice. Thanks in advance again.

Show quoteHide quote
gfoga***@gmail.com (Gabriel) wrote in message news:<352db686.0503051334.436733fa@posting.google.com>...
> Hi,
>
> I'm using the following code to check signed xml files:
>
> SignedXml signedXml = new SignedXml();
> //  http://support.microsoft.com/default.aspx?scid=KB;EN-US;322371
> CspParameters cspParams = new CspParameters();
> cspParams.Flags = CspProviderFlags.UseMachineKeyStore;
> RSACryptoServiceProvider rsaPublicKey = new
> RSACryptoServiceProvider(cspParams);
> rsaPublicKey.FromXmlString(xmlPublicKey);
> KeyInfo keyInfo = new KeyInfo();
> keyInfo.AddClause(new RSAKeyValue(rsaPublicKey));
> signedXml.KeyInfo = keyInfo;
>
> XmlNodeList nodeList = licenseData.GetElementsByTagName("Signature");
> signedXml.LoadXml((XmlElement)nodeList[0]);
>
> return signedXml.CheckSignature();
>
> This code works great under .NET 1.x and it FAILS under .NET 2.0 Beta.
> Do you know why?
> Thanks in advance.
>
> PS: xmlPublicKey contains the public key of course.
Author
9 Mar 2005 1:30 AM
Shawn Farkas [MS]
Its hard to tell what's going on from this snippet.  At the very least
we'll need a sample signed XML file and a key to verify with.

-Shawn
http://blogs.msdn.com/shawnfa 
-- 
This posting is provided "AS IS" with no warranties, and confers no rights.


Note: 
For the benefit of the community-at-large, all responses to this message
are best directed to the newsgroup/thread from which they originated.
--------------------
> From: gfoga***@gmail.com (Gabriel)
> Newsgroups: microsoft.public.dotnet.security
> Subject: Re: SignedXml fails under .NET 2.0 Beta
> Date: 7 Mar 2005 03:24:15 -0800
> Organization: http://groups.google.com
> Lines: 31
> Message-ID: <352db686.0503070324.7c364***@posting.google.com>
> References: <352db686.0503051334.43673***@posting.google.com>
> NNTP-Posting-Host: 200.69.233.6
> Content-Type: text/plain; charset=ISO-8859-1
> Content-Transfer-Encoding: 8bit
> X-Trace: posting.google.com 1110194655 18776 127.0.0.1 (7 Mar 2005
11:24:15 GMT)
> X-Complaints-To: groups-ab***@google.com
> NNTP-Posting-Date: Mon, 7 Mar 2005 11:24:15 +0000 (UTC)
> Path:
TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.
sul.t-online.de!t-online.de!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!
postnews.google.com!not-for-mail
Show quoteHide quote
> Xref: TK2MSFTNGXA02.phx.gbl microsoft.public.dotnet.security:9341
> X-Tomcat-NG: microsoft.public.dotnet.security
>
> In reality the code does not fail, CheckSignature method always
> returns FALSE under .NET 2.0 Beta 1.
>
> Please advice. Thanks in advance again.
>
> gfoga***@gmail.com (Gabriel) wrote in message
news:<352db686.0503051334.436733fa@posting.google.com>...
> > Hi,
> >
> > I'm using the following code to check signed xml files:
> >
> > SignedXml signedXml = new SignedXml();
> > //  http://support.microsoft.com/default.aspx?scid=KB;EN-US;322371
> > CspParameters cspParams = new CspParameters();
> > cspParams.Flags = CspProviderFlags.UseMachineKeyStore;
> > RSACryptoServiceProvider rsaPublicKey = new
> > RSACryptoServiceProvider(cspParams);
> > rsaPublicKey.FromXmlString(xmlPublicKey);
> > KeyInfo keyInfo = new KeyInfo();
> > keyInfo.AddClause(new RSAKeyValue(rsaPublicKey));
> > signedXml.KeyInfo = keyInfo;
> >
> > XmlNodeList nodeList = licenseData.GetElementsByTagName("Signature");
> > signedXml.LoadXml((XmlElement)nodeList[0]);
> >
> > return signedXml.CheckSignature();
> >
> > This code works great under .NET 1.x and it FAILS under .NET 2.0 Beta.
> > Do you know why?
> > Thanks in advance.
> >
> > PS: xmlPublicKey contains the public key of course.
>