Verifies the data referenced in an already signed XML digital signature document, using the embedded or a supplied public key.
var verifiedKey = objXMLDigitalSignature.verify(key);
Set verifiedKey = objXMLDigitalSignature.verify(key)
IXMLDSigKeyPtr verifiedKey = objXMLDigitalSignature->verify(key);
HRESULT verify( IXMLDSigKey* key, IXMLDSigKey** verifiedKey);
IXMLDSigKey
object obtained from one of the following methods: createKeyFromNode
, createKeyFromHMACSecret
, or createKeyFromHACSecretBinary
. If NULL, this method obtains the required key information from the Signature/KeyInfo/(KeyValue|X509Data)
elements. IXMLDSigKey
object actually used to verify. NULL if the signature and digest values are invalid and the method fails.In addition, the method passes the failure codes from CryptoAPI that are not covered by S_FALSE or NULL.
A valid signature with legitimate digest and signature values and appropriate key information, as opposed to a signature template, must be set to the signature
property before this method is called. For more information see the signature
property.
To verify signatures, your code must perform the following tasks:
<ds:SignedInfo>
using the algorithm named in the <ds:CanonicalizationMethod>
.<ds:SignedInfo>
using the SHA1 algorithm<ds:SignatureValue>
) using the provided or embedded key and the digest obtained in the previous step.verifiedKey
parameter is set to NULL. Otherwise it continues.<ds:Reference>
elements, perform all specified transforms, compute the digest, and compare it with the <ds:DigestValue>
content of each entry.After the verify
method returns successfully, you can call getVerifyingCertificate
or getVerifyingCertificateContext
to retrieve existing certificates and verify their validity using either CryptoAPI or CAPICOM.
If an embedded key contains a <ds:RetrievalMethod>
element, an additional query of the key will be made using the method declared in this element. A valid <ds:RetrieveMethod>
element must contain a valid URI attribute and may or may not contain <ds:transforms>
.
This example illustrates how to use the verify
method to verify a signature.
We've provided source files for the sample in three languages: JScript, Visual Basic, and C++. The output is the same in each language.
IXMLDigitalSignature | IXMLDigitalSignatureEx
MSXML 5.0 and later
To view reference information for Visual Basic, C/C++, or Script only, click the Language Filter button in the upper-left corner of the page.
sign Method | signature Property | createKeyFromNode Method | createKeyFromHMACSecret Property