Digital Signature with IText 2.1.7 — Part 2 — Asynchronous Sign

Rafael Franchi
3 min readSep 12, 2021

So guys, in the part 1 of this article we saw how to digitally sign a pdf document using PKCS7, iText 2.1.7 (2009) and a hash to be signed.

As the requirement says, we should call a webservice sending a hash of the document to be signed, and this webservice will respond with another hash signed. We should use this hash to make the pdf document digitally signed.

Now, my job here is show how to make this on the easy way, because we cannot change the library used (itext-2.1.7) and all that I tried (deferred signing, external signing, late signing) don’t worked.

So let’s review…

The code of the part 1:

This is the code that we use on part 1, a synchronous class that sign a pdf document using the version 2.1.7 of itext:

Now, we will change a little bit to make the part of the sign the hash to be appart of the main flow. So we will separate the code in three parts:

  1. Prepare to signature;

--

--