VerifyResult 列舉

定義

指定憑證或簽章驗證的結果。

C#
public enum VerifyResult
繼承
VerifyResult

欄位

名稱 Description
CertificateRequired 2

X.509 憑證無法用來驗證簽章。

InvalidCertificate 3

X.509 憑證無效。

InvalidSignature 1

簽章無效。

NotSigned 5

指定的封裝或組件沒有簽章。

ReferenceNotFound 4

找不到簽章的參考關聯性。

Success 0

驗證成功。

範例

下列範例示範如何使用 VerifyResult 列舉。

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

適用於

產品 版本
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

另請參閱