title: iText Verify Signature with checking CRL
body: <p>I am setting up a verifier which makes it possible to check the validity of signature.</p>
  <p>The signature I do is based on DSS level LT so revocation checking is built into the document.</p>
  <p>The problem that I encounter now is at the level of the verifier that I developed in iText. It allows the verification of the validity of the signature but of the information of the revocation. IText according to my research allows to verify this information in the signature itself based on: pkcs7.getCrl().</p>
  <p>However, the DSS signature incorporates the revocation information into the dictionaries.</p>
  <p>Below is the code I use to verify the signature:</p>
  <pre><code>import com.itextpdf.text.pdf.AcroFields;
  import com.itextpdf.text.pdf.PdfDictionary;
  import com.itextpdf.text.pdf.PdfName;
  import com.itextpdf.text.pdf.PdfReader;
  import com.itextpdf.text.pdf.PdfString;
  import com.itextpdf.text.pdf.security.PdfPKCS7;
  
  import java.io.File;
  import java.io.FileInputStream;
  import java.io.IOException;
  import java.io.InputStream;
  import java.security.GeneralSecurityException;
  import java.security.Principal;
  import java.security.cert.X509Certificate;
  import java.util.Calendar;
  import java.util.List;
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  import java.security.Security;
  import org.bouncycastle.jce.provider.BouncyCastleProvider;
  
  public class TestCheck {
  
      public static String pdf_file = &quot;CURRENT_SIGNATURE.pdf&quot;;
  
      public static final boolean verifySignature(PdfReader pdfReader)
              throws GeneralSecurityException, IOException {
          
          boolean valid = false;
          AcroFields acroFields = pdfReader.getAcroFields();
          
          
          PdfDictionary sigDict = acroFields.getSignatureDictionary(&quot;Signature1&quot;); 
          System.out.println(sigDict);
          PdfString contents = sigDict.getAsString(PdfName.CONTENTS);
  
          
          List&lt;String&gt; signatureNames = acroFields.getSignatureNames();
          if (!signatureNames.isEmpty()) {
              for (String name : signatureNames) {
  //                if (acroFields.signatureCoversWholeDocument(name)) {
                      PdfPKCS7 pkcs7 = acroFields.verifySignature(name);
                      valid = pkcs7.verify();
                      String reason = pkcs7.getReason();
                      Calendar signedAt = pkcs7.getSignDate();
                      X509Certificate signingCertificate = pkcs7.getSigningCertificate();
                      Principal issuerDN = signingCertificate.getIssuerDN();
                      Principal subjectDN = signingCertificate.getSubjectDN();
                      System.out.println(&quot;valid = &quot;+valid);
                      //System.out.println(&quot;date = &quot;+signedAt.getTime());
                      ////System.out.println(&quot;reason = &quot;+reason);
                      //System.out.println(&quot;issuer = &quot;+issuerDN);
                      //System.out.println(&quot;subject = &quot;+subjectDN);
                      System.out.println(&quot;CRL : &quot; + pkcs7.getCRLs());
                      break;
                  }
             // }
          }
          return valid;
      }
  
      public static void main(String[] args) throws Exception {
  
          BouncyCastleProvider provider = new BouncyCastleProvider();
          Security.addProvider(provider);
          
          InputStream is = new FileInputStream(new File(pdf_file));
          PdfReader reader = new PdfReader(is);
          
          
          boolean ok = verifySignature(reader);
          System.out.println(&quot;Ver : &quot;+ ok);
      }
  }
  </code></pre>