PackageDigitalSignatureManager.VerifySignatures Method

Verifies the signatures on all signed parts within the package.

Namespace:  System.IO.Packaging
Assembly:  WindowsBase (in WindowsBase.dll)

'Declaration
Public Function VerifySignatures ( _
	exitOnFailure As Boolean _
) As VerifyResult

Parameters

exitOnFailure
Type: System.Boolean
true to exit on first failure; otherwise, false to continue and check all signatures.

Return Value

Type: System.IO.Packaging.VerifyResult
Success (value 0) if all signatures are verified successfully; otherwise, an enumeration that identifies the error.

This method verifies only the digital signatures; it does not verify the related X.509 certificates. The VerifyCertificate method can be used to verify the X.509 certificates.

The following example shows how to use this method to validate all signed parts within a package. For the complete sample, see Creating a Package with a Digital Signature Sample.


' ------------------------ ValidateSignatures ------------------------
''' <summary>
''' Validates all the digital signatures of a given package.</summary>
''' <param name="package">
''' The package for validating digital signatures.</param>
''' <returns>
''' true if all digital signatures are valid; otherwise false if the
''' package is unsigned or any of the signatures are invalid.</returns>
Private Shared Function ValidateSignatures(ByVal package As Package) As Boolean
    If package Is Nothing Then
        Throw New ArgumentNullException("ValidateSignatures(package)")
    End If

    ' Create a PackageDigitalSignatureManager for the given Package.
    Dim dsm As New PackageDigitalSignatureManager(package)

    ' Check to see if the package contains any signatures.
    If Not dsm.IsSigned Then
        Return False
    End If
    ' The package is not signed.
    ' Verify that all signatures are valid.
    Dim result As VerifyResult = dsm.VerifySignatures(False)
    If result <> VerifyResult.Success Then
        Return False
    End If
    ' One or more digital signatures are invalid.
    ' else if (result == VerifyResult.Success)
    ' All signatures are valid.
    Return True
End Function
' end:ValidateSignatures()


.NET Framework

Supported in: 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft