Hi Guys,

I have a PDF which is signed with a timestamp. When I try to verify the signature I get the message that this signature is not valid. Especially when I try to read the signatures date - it's null.
See the following code and find the attached pdf.
I use Java 1.5 and iText 5.1.3

Thanks in advance for any help
Christian

Code:

public class SignatureVerificationItext {

    public static void main(String[] args) {

        try {
Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider()); PdfReader pdfReader = new PdfReader("C:\\Users\\pete\\Desktop\\testfiles\\outfile.pdf");
            AcroFields af = pdfReader.getAcroFields();
            ArrayList<String> names = af.getSignatureNames();
            for (String name : names) {
                System.out.println("Signature name: " + name);
System.out.println("Signature covers whole document: " + af.signatureCoversWholeDocument(name)); System.out.println("Document revision: " + af.getRevision(name) + " of " + af.getTotalRevisions());
                PdfPKCS7 pk = af.verifySignature(name);
                Calendar cal = pk.getSignDate(); //always null
                Certificate[] pkc = pk.getCertificates();
System.out.println("Subject: " + PdfPKCS7.getSubjectFields(pk.getSigningCertificate()));
                System.out.println("Revision modified: " + !pk.verify());
Object fails[] = PdfPKCS7.verifyCertificates(pkc, PdfPKCS7.loadCacertsKeyStore(), null, cal);
                if (fails == null)
                    System.out.println("works");
                else
                    System.out.println("is not working");
            }
        } catch (IOException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
        } catch (SignatureException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
        }
    }

}

Attachment: outputfile_signed_empty_pdf.pdf
Description: Adobe PDF document

------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php

Reply via email to