Validating Digital Signature

In this guide the process of validating a digital PDF signature using UniPDF will be explained.

Before you begin

You should get your API key from your UniCloud account.

If this is your first time using UniPDF SDK, follow this guide to set up a local development environment.

Project setup

Clone the project repository

In your terminal, clone examples repository using the following command: It contains the Go code we will be using for this guide.

git clone

Then navigate to the signatures folder in the unipdf-examples directory.

cd unipdf-examples/signatures

Configure environment variables

Configure your license key using the following command. Replace the UNIDOC_LICENSE_API_KEY with your API credentials from your UniCloud account.





How it works

In the example code, the import section imports all the dependencies used. The init function is used to authenticate your library request by loading the license key from your system environment.

The main function starts at line 29. In this function in lines 50-63, a couple of handlers are created using the following:

handlerX509RSASHA1, err := sighandler.NewAdobeX509RSASHA1(nil, nil)
if err != nil {
  log.Fatal("Fail: %v\n", err)

handlerPKCS7Detached, err := sighandler.NewAdobePKCS7Detached(nil, nil)
if err != nil {
  log.Fatal("Fail: %v\n", err)

handlers := []model.SignatureHandler{

Then the signatures are validated using reader.ValidateSignatures(handlers). From this function call, a list of SignatureValidationResult is returned. Line 70 checks if this list contains any result. In line 74 the IsSigned and IsVerified fields are checked.

In lines 78-80, the String() method of each SignatureValidationResult object is called, and the result is printed.

Run the code

Run the code using the following command:

go run pdf_sign_validate.go <INPUT_PDF_PATH>

Got any Questions?

We're here to help you.