Pular para o conteúdo principal

Signing external content

The XML signature standard lets you create signatures whose signed content is outside the XML document, or signatures of any content.

PKI SDK offers two ways to sign external content. The @Lacuna.Pki.Xml.DetachedResourceXmlSigner signer is meant for content that is local to the application. The @Lacuna.Pki.Xml.OnlineResourceXmlSigner signer is meant for online content, outside the application.

In this signature mode, you can choose not to pass any XML document to the signer. The signedXml result is then a new XML document with the signature node as its root node.

If you pass an XML document to the signer (signer.SetXml(xmlDocument)), the signature node is included in that XML, following the insertion rules described in Insertion modes.

Below are examples of each signer:

Local external content​

var signer = new DetachedResourceXmlSigner();
signer.SetToSignDetachedResource(resource, "uri.to.resource");
signer.SetPolicy(policy);
signer.SetSigningCertificate(certWithKey);
signer.ComputeSignature();
var signedXml = signer.GetSignedXml();

Online external content​

var signer = new OnlineResourceXmlSigner();
signer.SetToSignResourceUri(resourceUri);
signer.SetPolicy(policy);
signer.SetSigningCertificate(certWithKey);
signer.ComputeSignature();
var signedXml = signer.GetSignedXml();
View as Markdown