This project is read-only.

XMLDSig Examples

Here you can see some examples on how to use the XMLDSig API in XAdES .NET Project. They are pretty trivial, but that's the point (isn't it?). The following code is based on the current 0.1 alpha version, so it's likely some portions may change over time.

All examples requires that you include the namespaces XadesNetLib.xmlDsig and XadesNetLib.certificates in your classes.

Signing a file:

Signing a xml file in a simple way:
XmlDsig.Sign(inputPath).Using(selectedCertificate).SaveTo(outputPath);

Signing a xml file including the certificate in the signature file:
XmlDsig.Sign(inputPath).Using(certificate).IncludingCertificateInSignature().SaveTo(outputPath);

Signing a xml file (detached format):
XmlDsig.Sign(inputPath).Using(certificate).IncludingCertificateInSignature().Detached().SaveTo(outputPath);

Signing a xml file (enveloping format):
XmlDsig.Sign(inputPath).Using(certificate).IncludingCertificateInSignature().Enveloping().SaveTo(outputPath);

Signing a xml file (enveloped format):
XmlDsig.Sign(inputPath).Using(certificate).IncludingCertificateInSignature().Enveloped().SaveTo(outputPath);

Validating a file:

Validating a signature with certificate attached:
XmlDsig.Validate(signaturePath).Perform();

Validating a signature with certificate attached:
XmlDsig.Validate(signaturePath).Using(certificate).Perform();

Last edited Nov 1, 2010 at 10:38 PM by vvillap, version 3

Comments

No comments yet.