DigitalSignature class

DigitalSignature class

Represents a digital signature on a document and the result of its verification. To learn more, visit the Work with Digital Signatures documentation article.

Properties

NameDescription
certificate_holderReturns the certificate holder object that contains the certificate was used to sign the document.
commentsGets the signing purpose comment.
is_validReturns True if this digital signature is valid and the document has not been tampered with.
issuer_nameReturns the subject distinguished name of the certificate isuuer.
sign_timeGets the time the document was signed.
signature_typeGets the type of the digital signature.
signature_valueGets an array of bytes representing a signature value.
subject_nameReturns the subject distinguished name of the certificate that was used to sign the document.

Examples

Shows how to validate and display information about each signature in a document.

doc = aw.Document(MY_DIR + 'Digitally signed.docx')
for signature in doc.digital_signatures:
    print(f"\n{('Valid' if signature.is_valid else 'Invalid')} signature: ")
    print(f'\tReason:\t{signature.comments}')
    print(f'\tType:\t{signature.signature_type}')
    print(f'\tSign time:\t{signature.sign_time}')
    # System.Security.Cryptography.X509Certificates.X509Certificate2 is not supported. That is why the following information is not accesible.
    #print(f"\tSubject name:\t{signature.certificate_holder.certificate.subject_name}")
    #print(f"\tIssuer name:\t{signature.certificate_holder.certificate.issuer_name.name}")
    print()

See Also