Hi Paulo, I referenced from that example, but it always showed "System.out.println("Certificate failed: " + ......);
as I showed in the example. Eric On 11/6/06, Paulo Soares <[EMAIL PROTECTED]> wrote: > http://itextpdf.sourceforge.net/howtosign.html has an example. > > Paulo > > ----- Original Message ----- > From: "Eric Chow" <[EMAIL PROTECTED]> > To: <itext-questions@lists.sourceforge.net> > Sent: Monday, November 06, 2006 9:18 AM > Subject: [iText-questions] Verify digital signature > > > > Hello, > > > > How can verify the signature in iText? > > - does the document modify? > > - does the certificate valid ? > > > > > > For the modification, I can get some examples for reference but for > > the certificate validation, it always FAILED. > > > > > > The following is my code: > > > > PdfReader reader = new PdfReader(signedPDF); > > > > AcroFields af = reader.getAcroFields(); > > ArrayList names = af.getSignatureNames(); > > > > for (int k = 0; k < names.size(); ++k) { > > String name = (String) names.get(k); > > 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(); > > Certificate pkc[] = pk.getCertificates(); > > System.out.println("Subject: " + > > PdfPKCS7.getSubjectFields(pk.getSigningCertificate())); > > System.out.println("Document modified: " + !pk.verify()); > > Object fails[] = PdfPKCS7.verifyCertificates(pkc, keystore, null, cal); > > > > if (fails == null) > > System.out.println("Certificates verified against the KeyStore"); > > else > > System.out.println("Certificate failed: " + fails[1]); > > } > > > > > > > > Best regards, > > Eric > > > > ------------------------------------------------------------------------- > > Using Tomcat but need to do more? Need to support web services, security? > > Get stuff done quickly with pre-integrated technology to make your job > > easier > > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > > _______________________________________________ > > iText-questions mailing list > > iText-questions@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/itext-questions > > > ------------------------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > iText-questions mailing list > iText-questions@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/itext-questions > ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions