Verifies a signature based on the signed state of the document and the legitimacy of the certificate used for signing.
expression. VerifyXmlDsig( ** QueryContinue, ** psigsetup, ** psiginfo, ** XmlDsigStream, ** pcontverres, ** pcertverres )
expression An expression that returns a SignatureProvider object.
Name | Required/Optional | Data Type | Description |
---|---|---|---|
QueryContinue | Required | IQueryContinue | Provides a way to query the host application for permission to continue the verification operation. |
psigsetup | Required | SignatureSetup | Specifies configuration information about a signature line. |
psiginfo | Required | SignatureInfo | Specifies information captured from the signing ceremony. |
XmlDsigStream | Required | IStream | Represents a steam of data containing XML, which represents an XMLDSIG object. |
pcontverres | Required | ContentVerificationResults | Specifies the status of the signature verification action. |
pcertverres | Required | CertificateVerificationResults | Specifies the status of the signing certificate verification. |
XMLDSIG is a standards-based signature format (http://www.w3.org/TR/xmldsig-core/), verifiable by third parties. This is the default format for signatures in Microsoft Office.
The following example, written in C#, shows the implementation of the VerifyXmlDsig method in a custom signature provider project.
public void VerifyXmlDsig(object queryContinue, SignatureSetup sigsetup, SignatureInfo siginfo, object xmldsigStream, ref ContentVerificationResults contverresults, ref CertificateVerificationResults certverresults)
{
using (COMStream comstream = new COMStream(xmldsigStream))
{
XmlDocument xmldsig = new XmlDocument();
xmldsig.PreserveWhitespace = true;
xmldsig.Load(comstream);
XmlElement signature = xmldsig.DocumentElement;
SignedXml signedXml = new SignedXml();
signedXml.LoadXml(signature);
contverresults = signedXml.CheckSignature() ?
Microsoft.Office.Core.ContentVerificationResults.contverresValid :
Microsoft.Office.Core.ContentVerificationResults.contverresModified;
}
}
Note Signature providers are implemented exclusively in custom COM add-ins created in managed and unmanaged code and cannot be implemented in Microsoft Visual Basic® for Applications (VBA).