I have one question regarding signing XmlDocument
with a chain of certificates.My current try is to load the root, intermediate and the signing certificates separately, and add them to the KeyInfoX509Data
of the KeyInfo
class.
var keyInfo = new KeyInfo();
var keyInfoData = new KeyInfoX509Data(_certificateManager.Certificate);
keyInfoData.AddCertificate(_certificateManager.Intermediate);
keyInfoData.AddCertificate(_certificateManager.Root);
keyInfo.AddClause(keyInfoData);
Something like this.
Then I assign the SignedXml
KeyInfo
property with the keyInfo
variable. Then i call the .ComputeSignature()
method.
My question is - is this the right way to sign the xml message, or recently I found out the class X509Chain
, and I have to use in in some way, because I want to sign the xml with the whole chain.
Thanks in advance,
Julian
Here is what helped me!
signedXml.KeyInfo.AddClause(
new KeyInfoX509Data(certificate, X509IncludeOption.WholeChain));
Hope that helps other with the same problem!