PackageDigitalSignatureManager.IsSigned Propriedade

Definição

Obtém um valor que indica se o pacote contém alguma assinatura.Gets a value that indicates whether the package contains any signatures.

public:
 property bool IsSigned { bool get(); };
public bool IsSigned { get; }
member this.IsSigned : bool
Public ReadOnly Property IsSigned As Boolean

Valor da propriedade

true se o pacote contiver assinaturas; caso contrário, false.true if the package contains signatures; otherwise, false.

Exemplos

O exemplo a seguir mostra como usar a propriedade IsSigned para determinar se um pacote contém assinaturas digitais.The following example shows how to use the IsSigned property to determine if a package contains digital signatures. Para obter o exemplo completo, consulte criando um pacote com um exemplo de assinatura digital.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()

Comentários

A propriedade IsSigned não executa validações de assinatura.The IsSigned property does not perform signature validations. Se as assinaturas estiverem presentes e IsSigned for true, uma ou mais das assinaturas poderão não ser válidas.If signatures are present and IsSigned is true, one or more of the signatures might not be valid. Chame VerifySignatures para confirmar que as assinaturas são válidas e não foram alteradas.Call VerifySignatures to confirm that the signatures are valid and have not changed.

Aplica-se a

Veja também