Is it possible to sign resources pointed to from an xml doc and the
element that contains those urls at the same time?
This is the xml:
<osfm:assets name="">
<osfm:asset media-type="text/xml" name="META-INF/
Container.xml" />
<osfm:asset media-type="text/xml" name="META-INF/Manifest.xml" /
><osfm:asset media-type="text/xml" name="META-INF/Metadata.xml" /
></osfm:assets>
So, after hashing those three files I would also like to hash the
osfm:assets element, but I can't find a way to do that without
creating a new SignedXml object, which then means I've got two
signatures. Does anyone know if I can add the element here as well?
This is the code so far:
public void hashAssets(XmlD ocument Doc, RSA Key)
{
// Create a SignedXml object
SignedXml signedXml = new SignedXml(Doc);
// Add the key
signedXml.Signi ngKey = Key;
// Get urls to assets with signed = true
assetUris = getAssetUris();
foreach (string assetUri in assetUris)
{
// Create a reference to be signed
Reference reference = new Reference();
reference.Uri = assetUri;
//// Add an enveloped transformation to the reference
//XmlDsigEnvelope dSignatureTrans form env = new
XmlDsigEnvelope dSignatureTrans form();
//reference.AddTr ansform(env);
// Add the reference to the SignedXml object
signedXml.AddRe ference(referen ce);
}
// This is where I would like to hash the xml element
XmlElement assetElement = Doc.GetElements ByTagName("osfm :assets")[0]
as XmlElement;
// Compute the signature
signedXml.Compu teSignature();
// Get the XML representation of the signature and save it to an
XmlElement object
XmlElement xmlDigitalSigna ture = signedXml.GetXm l();
// Append the element to the XML document
Doc.DocumentEle ment.AppendChil d(Doc.ImportNod e(xmlDigitalSig nature,
true));
}
Many thanks,
Annelie