VerifyResult 枚举
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
指定证书或签名验证的结果。
public enum class VerifyResult
public enum VerifyResult
type VerifyResult =
Public Enum VerifyResult
- 继承
字段
CertificateRequired | 2 | X.509 证书不可用于验证签名。 |
InvalidCertificate | 3 | X.509 证书无效。 |
InvalidSignature | 1 | 该签名无效。 |
NotSigned | 5 | 指定的包或部件不具有签名。 |
ReferenceNotFound | 4 | 找不到签名的引用关系。 |
Success | 0 | 验证成功。 |
示例
以下示例演示如何使用 VerifyResult 枚举。
// ------------------------ 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()