473,388 Members | 1,234 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Digital signature of the blob?

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
Nov 12 '05 #1
1 4962
Never mind , I did it : URI have to include #XXX ( Id ) so object ( "Body"
in my case ) have to have "Id=XXX" and xml for Check have to include both
( original xml text and signature ) to be checked corrrectly
Arkady

"Arkady Frenkel" <ar*****@hotmailxdotx.com> wrote in message
news:Op**************@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

Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Kim H Madsen | last post by:
I have created a .Net Service that is sending mails using SMTP Server/Exchange Server how do i put in a Digital Signature so the reciver is 100% sure that the mail i from the owner of Server where...
7
by: Guangxi Wu | last post by:
Hi all, Happy New Year. I am using SignedXML and an X509 certificate to digitally sign a SOAP message body and put the signature in the SOAP header for a B2B business application. Can you...
5
by: John Campbell | last post by:
Hi everyone I've been doing my best to understand the specifics of implimentating XML Digital Signatures, but I seem to be missing a fundamental concept. Let me start with a description of the...
0
by: CLarkou | last post by:
I bought a digital signature for my MSaccess application in Office 2003. I select TOOLS\Digital Signatures in Visual Basic Editor and I am not able to see my digital signature in the available...
2
by: Martin Høst Normark | last post by:
Hi everyone Has anyone got the least experience in integrating the Digital Signature with an ASP.NET Web Application? Here in Denmark, as I supose in many other countries, they're promoting...
6
by: Matt Frame | last post by:
I have a client that has asked us to get a digital signature certificate and start digitally signing all files we pass between each other. I have heard of the subject and know about the certs but...
1
by: claudia_usa | last post by:
Hello, Does anyone know how to include the signature field when creating PDF crystal reports with VB.net? Our intension is to allow the user to generate the report with their digital signature...
0
by: Geagleeye | last post by:
Hi everyone. I have some vba code to generate a pdf document through word, and add also digital signature. My problem is : how can i change the way the signature layout, it always show the...
3
by: tmoloy | last post by:
I am using RFID tags to store some data which will then be read by a 3rd party. I need to include a digital signature (or some variation) along with the data so that the 3rd party can verify the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.