I'm working with some web-service which requires digitally signed XML to be posted via HTTP post request.
They gave me only one file (key.dat) which I should apply to my XML.
How can I do it?
You can take a look over here :
private static XmlElement GetXmlDigitalSignature(XmlDocument x, AsymmetricAlgorithm key)
{
var signedXml = new SignedXml(x) { SigningKey = key };
var reference = new Reference { Uri = "", TransformChain = new TransformChain(), };
reference.AddTransform(new XmlDsigEnvelopedSignatureTransform());
signedXml.AddReference(reference);
signedXml.ComputeSignature();
return signedXml.GetXml();
}
var signature = GetXmlDigitalSignature(xmlDocument, algorithm);
xmlDocument.FirstChild.AppendChild(xmlDocument.ImportNode(signature, true));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.