VerifyResult Перечисление

Определение

Указывает результат проверки сертификата или подписи.Specifies the result of a certificate or signature verification.

public enum class VerifyResult
public enum VerifyResult
type VerifyResult = 
Public Enum VerifyResult
Наследование
VerifyResult

Поля

CertificateRequired 2

Сертификат X.509 недоступен для проверки подписи.The X.509 certificate is not available to verify the signature.

InvalidCertificate 3

Сертификат X.509 недействителен.The X.509 certificate is not valid.

InvalidSignature 1

Недопустимая подпись.The signature is not valid.

NotSigned 5

Указанный пакет или часть не имеет подписи.The specified package or part has no signature.

ReferenceNotFound 4

Не найдена ссылочная связь с подписью.A reference relationship to the signature was not found.

Success 0

Проверка пройдена успешно.The verification was successful.

Примеры

В следующем примере показано, как использовать VerifyResult перечисление.The following example shows how to use the VerifyResult enumeration.

// ------------------------ 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()

Полный пример см. в разделе Создание пакета с примером цифровой подписи.For the complete sample, see Creating a Package with a Digital Signature Sample.

Применяется к

См. также раздел