Hello List,
I wrote a little tool using the itext library to sign and certify pdf
documents.
Here the relevant part of the code:
KeyStore ks = KeyStore.getInstance("pkcs12");
ks.load(new FileInputStream(pfxNameVal),
pfxPassVal.toCharArray());
String alias = (String)ks.aliases().nextElement();
PrivateKey key = (PrivateKey)ks.getKey(alias,
pfxPassVal.toCharArray());
java.security.cert.Certificate[] chain =
ks.getCertificateChain(alias);
PdfReader reader = new PdfReader(inPDFVal);
FileOutputStream fout = new FileOutputStream(outPDFVal);
PdfStamper stp = PdfStamper.createSignature(reader, fout,
'\0');
PdfSignatureAppearance sap = stp.getSignatureAppearance();
sap.setCrypto(key, chain, null,
PdfSignatureAppearance.WINCER_SIGNED);
sap.setReason("Ich bin der Autor dieses Dokuments.");
sap.setLocation("Wien");
stp.setEncryption(true,pdfUPWVal,pdfAPWVal,PdfWriter.AllowCopy+PdfWriter.AllowPrinting);
if(sigVisVal.equalsIgnoreCase("1")){
sap.setVisibleSignature(new Rectangle(100, 150, 200,
200), 1, null);
}
if(certVisVal.equalsIgnoreCase("1")){
sap.setCertified(true);
}
stp.close();
The result with Acrobat Reader 7.x is as expected, a signed, certified
document:
Document signature is VALID.
- The document has not been changed since the signature was applied.
- The document is signed by the current user.
When opening the same file with Acrobat Reader 6.x, it says:
Document signature is INVALID.
- There have been changes made to this document that invalidate the
signature.
- The document is signed by the current user.
When I sign & certify a document using the Adobe Acrobat 6, the
signature is valid in any of the 2 versions above.
What is wrong to this code?
Can someone help me on that?
Regards,
Felix Joussein
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
-------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions