Andrea, famagosta wrote: > i was trying to sing a pdf in three different steps (teorically in 3 > different machines). > 1. read pdf and calculate hash > 2. get hash and sign it (using a smartcard) > 3. get sign and apply to pdf > First question : is it possible?
This question has been discussed here quite often, e.g. in http://itext-general.2136553.n4.nabble.com/Hash-computation-problem-tt2158378.html --- you may want to read that thread and the threads referred to from it. It is possible. But you have to take care. As you have seen yourself, the naive approach wont do: famagosta wrote: > Printing the generated hash (for the same pdf), i read always different > values, how is it possible? > If the hash of a pdf is always different, how is it possible to verify the > sign? > > I'm sure i done something wrong, but waht? You are wrong in assuming that when starting to sign the same PDF at different times, the identical PDF objects are added to the PDF to embed the signature. Thinking about this, the assumption is obviously wrong as some of these objects represent the current date and time (both used as modification time pdf property and as signing time) and some may include other data depending on the very situation (ID, iText version entry, ...). Thus, to sign in your separate three steps you either have to keep the PdfStamper and PdfSignatureAppearance you originally created (or at least the temporary PDF file created by sap.preclose()) to insert the externally generated signature in or you have to patch iText to use the identical variable data in step three as you did in step 1. As far as iText is concerned, keeping the PdfStamper and PdfSignatureAppearance you originally created, waiting in some cache for the signature to arive is the easiest way, keeping the temporary PDF and injecting the generated signature requires some more coding, and patching iText to use identical variable data is most complicated. Regards, Michael. -- View this message in context: http://itext-general.2136553.n4.nabble.com/signing-a-pdf-in-three-different-steps-tp2322393p2322419.html Sent from the iText - General mailing list archive at Nabble.com. ------------------------------------------------------------------------------ This SF.net email is sponsored by Make an app they can't live without Enter the BlackBerry Developer Challenge http://p.sf.net/sfu/RIM-dev2dev _______________________________________________ iText-questions mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.itextpdf.com/book/ 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/
