Maybe it's supposed to fail. Are you sure that the certificate matches?
Does it verify in Acrobat?
Paulo
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On
> Behalf Of Eric Chow
> Sent: Tuesday, November 07, 2006 9:54 AM
> To: Post all your questions about iText here
> Subject: Re: [iText-questions] Verify digital signature
>
> 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
>
Aviso Legal:
Esta mensagem é destinada exclusivamente ao destinatário. Pode conter
informação confidencial ou legalmente protegida. A incorrecta transmissão desta
mensagem não significa a perca de confidencialidade. Se esta mensagem for
recebida por engano, por favor envie-a de volta para o remetente e apague-a do
seu sistema de imediato. É proibido a qualquer pessoa que não o destinatário de
usar, revelar ou distribuir qualquer parte desta mensagem.
Disclaimer:
This message is destined exclusively to the intended receiver. It may contain
confidential or legally protected information. The incorrect transmission of
this message does not mean the loss of its confidentiality. If this message is
received by mistake, please send it back to the sender and delete it from your
system immediately. It is forbidden to any person who is not the intended
receiver to use, distribute or copy any part of this message.
-------------------------------------------------------------------------
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