Hi Christian, we do some useless signing with a fake key just to keep the give iText API happy. When iText has signed the PDF it can be written to disk as usual. But after this step we know the hash and the position of the PKCS7 signature. Once our own signing process is thru we replace the signature in the PDF by brute force ( replace byte x to byte y in file z with my content ). That's far from elegant but we don't need to tweak iText's code.
Initially we don't expect our external signing problem deserves a solution within iText but if several people show up with such a demand, maybe we could make a proposal for a new interface. Or you just use our ready-build signing server ( http://sourceforge.net/projects/sirius-sign/ ) and we don't confuse people by adding more complex signing functionality to iText ;-) Greetings Andreas ----- Original Message ---- From: java-chris <[email protected]> To: [email protected] Sent: Wed, January 27, 2010 10:51:14 PM Subject: Re: [iText-questions] Merge of detached signature Hello Andreas, im on the same issue here. When you talk about " store the half-baked pdf on the disk ". Im trying to do that by making some serialization on the Stamper but nothing is serializable in ITEXT. So , im trying to do this way. [CODE] // write the current file. byte[] buf = new byte[8192]; java.io.InputStream s = sap.getRangeStream(); ByteArrayOutputStream ss = new ByteArrayOutputStream(); int read = 0; while ((read = s.read(buf, 0, buf.length)) > 0) { ss.write(buf, 0, read); } // write SS to the disk. FileOutputStream fos = new FileOutputStream("blank.in_process"); ss.writeTo(fos); fos.close(); ss.close(); [/CODE] But when im trying to read the stamper again to put the signature on : PdfReader reader = new PdfReader("blank.in_process"); PdfStamper stamper = new PdfStamper(reader,new FileOutputStream("signedDoc.pdf")); PdfSignatureAppearance sa = stamper.getSignatureAppearance(); The signature PdfSignatureAppearance is null .... I think im missing something here ... How you procede to store the half-baked pdf on the disk ? Did i procede the right way ? Cheer's Christian Leclerc Couldn't remember that I ever disagreed with Leonard, but now it's the time ! Of course it's possible what your describing : - Build a semi-signed PDF with room for the signature - Get the hash value - Store the half-baked PDF on disk - Sign the hash and create a PKCS7-Signature, somtimes later, somewhere - Insert the signature into the spare bytes in the PDF - Ready Due to wierd legal requirements we had to take this multi-step approach and it works ! Greetings Andreas -- View this message in context: http://old.nabble.com/Merge-of-detached-signature-tp27314294p27347402.html Sent from the iText - General mailing list archive at Nabble.com. ------------------------------------------------------------------------------ The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com _______________________________________________ iText-questions mailing list [email protected] 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/ ------------------------------------------------------------------------------ The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com _______________________________________________ iText-questions mailing list [email protected] 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/
