4

Sign PDF Documents with an X.509 Certificate on a Hardware Device

 11 months ago
source link: https://www.textcontrol.com/blog/2023/06/05/sign-pdf-documents-with-an-x509-certificate-on-a-hardware-device/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Sign PDF Documents with an X.509 Certificate on a Hardware Device

TX Text Control can digitally sign Adobe PDF and PDF/A documents with X.509 certificates. An X.509 certificate is a digital certificate that implements the widely accepted X.509 Public Key Infrastructure (PKI) standard that verifies that a specific public key belongs to a user, computer, or service identity contained in the certificate. The certificate can be assigned in the SaveSettings class when the document is saved.

Document Signing Methods

There are two approaches to signing PDF documents with TX Text Control:

  • Sign the whole document with a digital certificate
  • Sign individual signature fields with a digital certificate(s)

In both approaches, signatures can be created with PFX, DER Cer, or Base64 CER certificate files, loaded from raw data, or selected from the local certificate store.

Windows Certificate Store

The following method opens a dialog box that allows the user to select the desired certificate from the local Windows certificate store. The selected certificate is returned and can be used to sign the document or the signature fields in a PDF document.

The X509Certificate2UI class provides a user interface for selecting and viewing X.509 certificates. The following code uses the SelectFromCollection method to open a certificate selection dialog. All registered certificates, including smart cards, are listed in the dialog.

Signing the PDF

The CreateEncryptedPDF method takes the selected certificate and a document in the internal TX Text Control format and creates a PDF document signed with the given certificate.

The following code shows how to call this method with the certificate returned from the certificate store.

The dialog box for selecting the certificate from the local Windows certificate store is shown in the following screenshot.

Windows certificate store

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK