PDF Signature Verification

Print E-mail  

The aim of this example is to validate the document signature that was produced in the PDF Signature Generation example. To understand this example, you must first understand the CMS/PKCS#7 Signature Verification example. 

To try this example, you must download the file, sampleSW13.zip, and follow the instructions in Configuration of the Environment

The downloaded file contains the signature to be verified but if you wish you can replace it with the one generated in the PDF Signature Generation example to check the validity of the signature 

This example is very similar to the CMS/PKCS#7 Signature Verification example; however, in this case we are verifying a PDF signature. 

SmartVerifyRequest svr = new SmartVerifyRequest(host);
svr.setProfile(Constants.Profile.PDF);

To verify a PDF signature, we simply enter the PDF document because it already contains the signature. Therefore, we invoke the setInputPdfBase64Data() method. 

svr.setInputPdfBase64Data(Util.readBinaryFileB64(path_in + signatureFile));

Once all the data has been entered in the request, we invoke the send() operation to send the request to the host and collect the response in a SmartVerifyResponse object. 

SmartVerifyResponse svrs = svr.send();			

After executing the example, we obtain a response like the one below.

** RESPONSE **
---------------------
Signature num 0
---------------------
** Certificate **
Major: urn:oasis:names:tc:dss:1.0:resultmajor:Success
Minor: urn:oasis:names:tc:dss:1.0:resultminor:ValidSignature_OnAllDocuments
DN: CN=Dave, OU=Demo, O=TrustedX, C=ES
Issuer Trust Level: 0
Issuer Trust Label: Administration