By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,994 Members | 1,080 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,994 IT Pros & Developers. It's quick & easy.

Addition of Keyname in the xml signature

P: n/a
Hi all ,
Can anyone help me out in finding a way to add the "keyname' tag in the
keyinfo of the xml signature
the sample code here adds the DSA/RSA Keyvalue tag in the keyinfo.

// Create example data to sign.
DSA objDSAkey = DSA.Create();
string strDSAKeyXML = objDSAkey.ToXmlString(true);
XmlDocument objXMLdocument = new XmlDocument();

// Save only the PublicKey.
strDSAKeyXML = objDSAkey.ToXmlString(false);
objXMLdocument = new XmlDocument();
objXMLdocument.Save("XMLSignatureDSAPublicKey.xml" );

XmlDocument objDSAKeyPairXMLdocument = new XmlDocument();
objDSAKeyPairXMLdocument.Load("XMLSignatureDSAKeyP air.xml");
string strDSAKeyPairXML = objDSAKeyPairXMLdocument.InnerXml;
SignedXml signedXml = new SignedXml();
DSA objDSAkeyPair = DSA.Create();
objDSAkeyPair.FromXmlString(strDSAKeyPairXML );
signedXml.SigningKey = objDSAkeyPair ;
// The above sets the KeyPair used to Sign

XmlDocument objdocument = new XmlDocument();

DataObject dataObject = new DataObject();
dataObject.Data = objdocument.ChildNodes;
dataObject.Id = "CreditCardInfo";


Reference reference = new Reference();
reference.Uri = "#CreditCardInfo";


//This is optional. KeyInfo need not be transmitted along with
KeyInfo keyInfo = new KeyInfo();
keyInfo.AddClause(new DSAKeyValue(objDSAkeyPair));
signedXml.KeyInfo = keyInfo;

Generated XML contains ...

<KeyValue xmlns="">
<P>rJG9SxL0vbiMuv71LO93CQcwed+64wuOe7S8Ld9l7dPakgB dq7qDLQd52W5R08LDR9OYW5+hjTSQwu7FJbkusVpxcNAeQgBej Sg0bN9Pl/AvrXTn182RRbQxf//odSGMk4MabK4oryY596uV0FiqWG9gNHn4qWiHPYYPBqK1yVU=</P>
<G>I3k7Ya3tzQdivS0mORJUwhu48xUQlDNhsINbvaeFOlb4Aqu mDSCmFz3urueV6RVg2MrpllTll7biGeBuOwgrPDj8
uyVrjqIuUYNaubLrrcM6xwCuzUxjUKjMnS4QPtVW9+CL54b2DA Szfg/wsEiu+sNZCMfsT79N1u4FbGlRVZI=</G>
LNeGxWhazdudzIjYdRIOu3TkzdM4j+FlPQo80a6Y06lXCB+9RE hDuogeYSQc6la40sFeCIraDGhq1ubPcyqGiVX4dbJxoTyQxI61 l6cdFjLT/qRvHpVrqG69Bex3W
<J>wQ9kPQEXFRMsMADCxM3wFdnwN1goipvS8nHnzSrRoyRtYtD vWRHsWZtsVtfK/zg0R1OJsMrsZC0xsAsfvhy6EhJzRD1qcr09JQcqkfpnM

but i need it this way


Is it is possible to add/generate xmlsignature with the keyname ?
Please help

Mar 31 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.