Hi,
I have signed a pdf file and when this file is opened the signature is
correctly validated.
But I would like to validate the signature programatically.
I'm using the code example of the javadoc
verifySignature
public PdfPKCS7
<http://127.0.0.1:8082/resource/jar%3Afile%3A/home/javier/wrk/java/workspace/applets/applet6/lib/itextpdf-5.1.3-javadoc.jar%21/com/itextpdf/text/pdf/PdfPKCS7.html>
*verifySignature*(String
<http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html> name)
Verifies a signature. An example usage is:
PdfReader reader = new PdfReader("my_signed_doc.pdf");
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));
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, myKeyStore, null, cal);
if (fails == null)
System.out.println("Certificates verified against the KeyStore");
else
System.out.println("Certificate failed: " + fails[1]);
}
*Parameters:*name - the signature field name *Returns:*a PdfPKCS7 class to
continue the verification myKeyStore is the KeyStore used to sign the
document
pkc has got the intermediate and CA certificates.
I'm getting the next error:
Certificate failed: Cannot be verified against the KeyStore
or the certificate chain
I'm getting the signature name, if the signature covers whole document the
document revision 1 of 1, the subject and the Document modified: false
Any suggestion?
Regards.
------------------------------------------------------------------------------
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
[email protected]
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