|
View:
New views
5 Messages
—
Rating Filter:
Alert me
|
|
|
Annotations Modified?Hiyas
For some unknown reason, Acrobat seems to have some problems with certain files we try to sign. We use the code and file attached to this mail. It is more or less the same that is on Paulo's website. It doesn't matter if we use s self signed PKCS12 certificate or use a certificate from a PKCS11 token, the result is the same: Acrobat can open and verify the signature, but, below, mentions "Annotations modified" with the whole list of annotations that exist in the PDF. Interestingly.. not with every file. This file display that, but there's some files with only a couple annotations (or only one) where Acrobat doesn't complain. Should one worry about that or what exactly is that? Or is the code somehow wrong? Did we forget something in here? Best regards Rog /** Creator: * 23.10.2009 15:22:08 Misteli * * Maintainer: * 23.10.2009 15:22:08 Misteli * * Last Modification: * $Id: $ * * Copyright (c) 2003 ABACUS Research AG, All Rights Reserved */ package ch.abacus.test.phoenix.sign; import java.io.File; import java.io.FileInputStream; import java.io.InputStream; import java.security.Key; import java.security.KeyStore; import java.security.MessageDigest; import java.security.PrivateKey; import java.security.Provider; import java.security.Security; import java.security.Signature; import java.security.interfaces.RSAPublicKey; import java.security.cert.Certificate; import com.lowagie.text.Rectangle; import com.lowagie.text.pdf.PdfDictionary; import com.lowagie.text.pdf.PdfLiteral; import com.lowagie.text.pdf.PdfName; import com.lowagie.text.pdf.PdfPKCS7; import com.lowagie.text.pdf.PdfReader; import com.lowagie.text.pdf.PdfSigGenericPKCS; import com.lowagie.text.pdf.PdfSignatureAppearance; import com.lowagie.text.pdf.PdfStamper; import com.lowagie.text.pdf.PdfString; import org.bouncycastle.jce.provider.BouncyCastleProvider; public class PauloTest { public static void main (String[] args) throws Exception { Provider prov = new BouncyCastleProvider(); Security.addProvider(prov); KeyStore ks = KeyStore.getInstance("pkcs12"); String pw = "a"; File certFile = new File("c:\\test.p12"); FileInputStream fis = new FileInputStream(certFile); ks.load(fis, pw.toCharArray()); fis.close(); String alias = (String)ks.aliases().nextElement(); Key key = (PrivateKey)ks.getKey(alias, pw.toCharArray()); Certificate[] chain = ks.getCertificateChain(alias); PdfReader reader = new PdfReader("c:\\document_original_mit_annotations.pdf"); File fout = new File("c:\\document_1_signed.pdf"); PdfStamper stp = PdfStamper.createSignature(reader, null, '\0', fout, false); PdfSignatureAppearance sap = stp.getSignatureAppearance(); sap.setCrypto(null, chain, null, PdfSignatureAppearance.WINCER_SIGNED); sap.setReason("I'm the author"); sap.setLocation("Lisbon"); // comment next line to have an invisible signature sap.setVisibleSignature(new Rectangle(100, 100, 200, 200), 1, null); int keyLen = ((RSAPublicKey) chain[0].getPublicKey()).getModulus().bitLength() / 8; sap.setExternalDigest(new byte[keyLen], new byte[20], "RSA"); sap.preClose(); MessageDigest messageDigest = MessageDigest.getInstance("SHA1"); byte buf[] = new byte[8192]; int n; InputStream inp = sap.getRangeStream(); while ((n = inp.read(buf)) > 0) { messageDigest.update(buf, 0, n); } byte hash[] = messageDigest.digest(); PdfSigGenericPKCS sg = sap.getSigStandard(); PdfLiteral slit = (PdfLiteral) sg.get(PdfName.CONTENTS); byte[] outc = new byte[(slit.getPosLength() - 2) / 2]; PdfPKCS7 sig = sg.getSigner(); Signature thesig = Signature.getInstance("SHA1withRSA", prov); thesig.initSign((PrivateKey) key); thesig.update(hash); byte[] signature = thesig.sign(); sig.setExternalDigest(signature, hash, "RSA"); PdfDictionary dic = new PdfDictionary(); byte[] ssig = sig.getEncodedPKCS7(); System.arraycopy(ssig, 0, outc, 0, ssig.length); dic.put(PdfName.CONTENTS, new PdfString(outc).setHexWriting(true)); sap.close(dic); System.exit(0); } } ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ iText-questions mailing list iText-questions@... https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.1t3xt.com/docs/book.php Check the site with examples before you ask questions: http://www.1t3xt.info/examples/ You can also search the keywords list: http://1t3xt.info/tutorials/keywords/ |
|
|
Re: Annotations Modified? >> Acrobat can open and verify the signature, but, below, mentions "Annotations modified" with the whole list of annotations that exist in the PDF.
Forgot to mention that: Acrobat 9.1.3 and iText 2.1.7 Best regards Rog ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ iText-questions mailing list iText-questions@... https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.1t3xt.com/docs/book.php Check the site with examples before you ask questions: http://www.1t3xt.info/examples/ You can also search the keywords list: http://1t3xt.info/tutorials/keywords/ |
|
|
Re: Annotations Modified?Please post the signed PDF, I don't have Java where I am now.
Paulo > -----Original Message----- > From: Roger Misteli [mailto:roger.misteli@...] > Sent: Friday, October 23, 2009 4:45 PM > To: iText > Subject: [iText-questions] Annotations Modified? > > Hiyas > > For some unknown reason, Acrobat seems to have some problems > with certain files we try to sign. We use the code and file > attached to this mail. It is more or less the same that is > on Paulo's website. It doesn't matter if we use s self signed > PKCS12 certificate or use a certificate from a PKCS11 token, > the result is the same: Acrobat can open and verify the > signature, but, below, mentions "Annotations modified" with > the whole list of annotations that exist in the PDF. > Interestingly.. not with every file. This file display that, > but there's some files with only a couple annotations (or > only one) where Acrobat doesn't complain. > Should one worry about that or what exactly is that? Or is > the code somehow wrong? Did we forget something in here? > > Best regards > Rog > 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. ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ iText-questions mailing list iText-questions@... https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.1t3xt.com/docs/book.php Check the site with examples before you ask questions: http://www.1t3xt.info/examples/ You can also search the keywords list: http://1t3xt.info/tutorials/keywords/ |
|
|
Re: Annotations Modified?Attached is the signed document.
Best regards Rog Paulo Soares wrote: > Please post the signed PDF, I don't have Java where I am now. > > Paulo > >> -----Original Message----- >> From: Roger Misteli [mailto:roger.misteli@...] >> Sent: Friday, October 23, 2009 4:45 PM >> To: iText >> Subject: [iText-questions] Annotations Modified? >> >> Hiyas >> >> For some unknown reason, Acrobat seems to have some problems >> with certain files we try to sign. We use the code and file >> attached to this mail. It is more or less the same that is >> on Paulo's website. It doesn't matter if we use s self signed >> PKCS12 certificate or use a certificate from a PKCS11 token, >> the result is the same: Acrobat can open and verify the >> signature, but, below, mentions "Annotations modified" with >> the whole list of annotations that exist in the PDF. >> Interestingly.. not with every file. This file display that, >> but there's some files with only a couple annotations (or >> only one) where Acrobat doesn't complain. >> Should one worry about that or what exactly is that? Or is >> the code somehow wrong? Did we forget something in here? >> >> Best regards >> Rog >> > > 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. > > > > > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------------ > Come build with us! The BlackBerry(R) Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart your > developing skills, take BlackBerry mobile applications to market and stay > ahead of the curve. Join us from November 9 - 12, 2009. Register now! > http://p.sf.net/sfu/devconference > > > ------------------------------------------------------------------------ > > _______________________________________________ > iText-questions mailing list > iText-questions@... > https://lists.sourceforge.net/lists/listinfo/itext-questions > > Buy the iText book: http://www.1t3xt.com/docs/book.php > Check the site with examples before you ask questions: http://www.1t3xt.info/examples/ > You can also search the keywords list: http://1t3xt.info/tutorials/keywords/ ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ iText-questions mailing list iText-questions@... https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.1t3xt.com/docs/book.php Check the site with examples before you ask questions: http://www.1t3xt.info/examples/ You can also search the keywords list: http://1t3xt.info/tutorials/keywords/ |
|
|
Re: Annotations Modified?Roger,
Adobe Preflight states that there are syntax errors in the annotations of both the original pdf and the signed pdf: document_original_mit_annotations_report.pdf document_1_signed_report.pdf Maybe these errors make the Reader think that the annotations are modified. Regards, Michael.
|
| Free embeddable forum powered by Nabble | Forum Help |