Never mind , I did it : URI have to include #XXX ( Id ) so object ( "Body"
"Arkady Frenkel" <arkadyf@hotmailxdotx.com> wrote in message
news:OpllKg7sFHA.2912@TK2MSFTNGP09.phx.gbl...
> Hi!
> I try to make digital signature of the blob and check it , but on check
> ( signature created and seems OK ) I catch exception :
> "An XmlDocument context is required to resolve the Reference Uri ."
> If instead of line
>
> reference.Uri = "";
>
> If I put here some correct Uri - like
>
> reference.Uri =
http://www.microsoft.com >
> No exception on CheckSignature() happen and resut is true
>
> Is it possible to do with blob and without URI?
>
> I tried to set : reference.Uri = "Body" but catched exception too
>
> Here the code ( C# ) :
>
> string str = "<Body>aaaaaaaaaaaaaaaaaa</Body>" ; // blob I want to sign
>
> XmlTextReader r = new XmlTextReader(new StringReader(str));
>
> XmlDocument document = new XmlDocument();
>
> document.Load(r);
>
> SignedXml signedXml = new SignedXml(document);
>
> RSA key = RSA.Create();
>
> signedXml.SigningKey = key;
>
>
> Reference reference = new Reference();
>
> reference.Uri = ""; // If I put here some correct Uri - like
> "http://www.microsoft.com"
>
> signedXml.AddReference(reference);
>
> KeyInfo keyInfo = new KeyInfo();
>
> keyInfo.AddClause(new RSAKeyValue(key));
>
> signedXml.KeyInfo = keyInfo;
>
> signedXml.ComputeSignature();
>
> XmlElement xmlDigitalSignature = signedXml.GetXml();
>
> StringWriter sw = new StringWriter();
>
> XmlTextWriter xmltw = new XmlTextWriter(sw);
>
> xmlDigitalSignature.WriteTo(xmltw);
>
> string s = sw.ToString();
>
> xmltw.Close();
>
> XmlTextReader rr = new XmlTextReader(new StringReader(s));
>
> XmlDocument xmlDocument = new XmlDocument();
>
> xmlDocument.Load(rr);
>
>
> signedXml = new SignedXml();
>
> XmlNodeList nodeList = xmlDocument.GetElementsByTagName("Signature");
>
> signedXml.LoadXml((XmlElement)nodeList[0]);
>
> // Check the signature and return the result.
>
> try
>
> {
>
> b = signedXml.CheckSignature();
>
> }
>
> catch(CryptographicException e)
>
> {
>
> Console.WriteLine(e.Message);
>
> }
>
> TIA
> Arkady
>