Private key public key signedXML
How do I use a .cer file to sign a signedXML object. How do I find the password for the files?
I should be using a .cer file correct and not a .pfx or other type of certificate?
How do I use a .cer file to sign a signedXML object. How do I find the password for the files?
I should be using a .cer file correct and not a .pfx or other type of certificate?
Try the following approach:
XmlDocument doc = new XmlDocument();
doc.Load("..\\..\\xmlfile1.xml");
X509Certificate2 cert = new X509Certificate2("..\\..\\test.cer");
KeyInfo keyInfo = new KeyInfo();
keyInfo.AddClause(new KeyInfoX509Data(cert));
SignedXml signedXml = new SignedXml();
signedXml.SigningKey = new RSACryptoServiceProvider();
signedXml.AddObject(new DataObject("MySample", "text/xml", "utf-8", doc.DocumentElement));
signedXml.AddReference(new Reference("#MySample"));
signedXml.KeyInfo = keyInfo;
signedXml.ComputeSignature();