PackageDigitalSignatureManager.VerifySignatures(Boolean) PackageDigitalSignatureManager.VerifySignatures(Boolean) PackageDigitalSignatureManager.VerifySignatures(Boolean) PackageDigitalSignatureManager.VerifySignatures(Boolean) Method

정의

패키지 내에서 서명된 모든 파트에서 서명을 확인합니다.Verifies the signatures on all signed parts within the package.

public:
 System::IO::Packaging::VerifyResult VerifySignatures(bool exitOnFailure);
public System.IO.Packaging.VerifyResult VerifySignatures (bool exitOnFailure);
member this.VerifySignatures : bool -> System.IO.Packaging.VerifyResult
Public Function VerifySignatures (exitOnFailure As Boolean) As VerifyResult

매개 변수

exitOnFailure
Boolean Boolean Boolean Boolean

첫 번째 실패 시 종료하려면 true이고, 계속해서 모든 서명을 확인하려면 false입니다.true to exit on first failure; otherwise, false to continue and check all signatures.

반환

모든 서명이 성공적으로 확인되면 Success(값 0)이고, 그렇지 않으면 오류를 나타내는 열거형입니다.Success (value 0) if all signatures are verified successfully; otherwise, an enumeration that identifies the error.

예제

다음 예제에서는이 메서드를 사용 하 여 패키지 내에서 서명 된 모든 파트의 유효성을 검사 하는 방법을 보여 줍니다.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 static bool ValidateSignatures(Package package)
{
    if (package == null)
        throw new ArgumentNullException("ValidateSignatures(package)");

    // Create a PackageDigitalSignatureManager for the given Package.
    PackageDigitalSignatureManager dsm =
        new PackageDigitalSignatureManager(package);

    // Check to see if the package contains any signatures.
    if (!dsm.IsSigned)
        return false;   // The package is not signed.

    // Verify that all signatures are valid.
    VerifyResult result = dsm.VerifySignatures(false);
    if (result != VerifyResult.Success)
        return false;   // One or more digital signatures are invalid.

    // else if (result == VerifyResult.Success)
    return true;        // All signatures are valid.

}// end:ValidateSignatures()
' ------------------------ 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()

설명

이 메서드는만 디지털 서명, 확인 관련 된 X.509 인증서를 확인 하지 않습니다.This method verifies only the digital signatures; it does not verify the related X.509 certificates. VerifyCertificate 메서드는 X.509 인증서는 데 사용할 수 있습니다.The VerifyCertificate method can be used to verify the X.509 certificates.

적용 대상

추가 정보