DigitalSignatureCollection Class
Provides a read-only collection of digital signatures attached to a document.
Inheritance Hierarchy
SystemObject
  Aspose.WordsDigitalSignatureCollection

Namespace: Aspose.Words
Assembly: Aspose.Words (in Aspose.Words.dll) Version: 19.11
Syntax
public class DigitalSignatureCollection : IEnumerable<DigitalSignature>, 
	IEnumerable

The DigitalSignatureCollection type exposes the following members.

Constructors
  NameDescription
Public methodDigitalSignatureCollection
Initializes a new instance of the DigitalSignatureCollection class
Properties
  NameDescription
Public propertyCode exampleCount
Gets the number of elements contained in the collection.
Public propertyCode exampleIsValid
Returns true if all digital signatures in this collection are valid and the document has not been tampered with Also returns true if there are no digital signatures. Returns false if at least one digital signature is invalid.
Public propertyCode exampleItem
Gets a document signature at the specified index.
Methods
  NameDescription
Public methodEquals (Inherited from Object.)
Protected methodFinalize (Inherited from Object.)
Public methodCode exampleGetEnumerator
Returns a dictionary enumerator object that can be used to iterate over all items in the collection.
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Protected methodMemberwiseClone (Inherited from Object.)
Public methodToString (Inherited from Object.)
Remarks
Examples
Shows how to validate all signatures in a document.
// Load the signed document.
Document doc = new Document(MyDir + "Document.DigitalSignature.docx");
DigitalSignatureCollection digitalSignatureCollection = doc.DigitalSignatures;

if (digitalSignatureCollection.IsValid)
{
    Console.WriteLine("Signatures belonging to this document are valid");
    Console.WriteLine(digitalSignatureCollection.Count);
    Console.WriteLine(digitalSignatureCollection[0].SignatureType);
}
else
{
    Console.WriteLine("Signatures belonging to this document are NOT valid");
}
Examples
Shows how to validate each signature in a document and display basic information about the signature.
// Load the document which contains signature.
Document doc = new Document(MyDir + "Document.DigitalSignature.docx");

foreach (DigitalSignature signature in doc.DigitalSignatures)
{
    Console.WriteLine("*** Signature Found ***");
    Console.WriteLine("Is valid: " + signature.IsValid);
    Console.WriteLine("Reason for signing: " +
                      signature.Comments); // This property is available in MS Word documents only.
    Console.WriteLine("Signature type: " + signature.SignatureType);
    Console.WriteLine("Time of signing: " + signature.SignTime);
    Console.WriteLine("Subject name: " + signature.CertificateHolder.Certificate.SubjectName);
    Console.WriteLine("Issuer name: " + signature.CertificateHolder.Certificate.IssuerName.Name);
    Console.WriteLine();
}
See Also