Salvo, Andreas,
Andreas Kuehne-2 wrote: > thanks for the code, But additionally I would like to see how you put the > signature into the the PDF. As Michael pointed out yesterday openening and > saving the PDF would break the old hash ... I'm also pretty sure that that is the code breaking the signature. Salvo Rapisarda wrote: > This is the VB.NET (in asp.net web page) code: That code to me very very much looks like you generate a hash in GetHash by preparing a PdfStamper for signing and later throwing it away: First you prepare it: Salvo Rapisarda wrote: > > Dim st As PdfStamper = PdfStamper.CreateSignature(reader, mm, > "\0", Nothing, True) > Dim sap As PdfSignatureAppearance = st.SignatureAppearance > [...] > sap.PreClose(exc) > Then you calculate the hash value of the range stream of this prepared PdfStamper: Salvo Rapisarda wrote: > > Dim sha As HashAlgorithm = New SHA1CryptoServiceProvider > sHash = Convert.ToBase64String(sha.ComputeHash(sap.RangeStream)) > And then you... throw away the prepared PdfStamper; at least there is nothing in the code you posted pointing in a different direction. I suppose that as soon as you receive the signature bytes you prepare a new PdfStamper and inject the signature bytes into it. If I'm right, then that's where your code is wrong. This newly prepared second PdfStamper does not contain exactly the same additions as the first one used in your GetHash method; thus, a signature to inject into it must sign a different hash than the one you have received. BTW, this has been discussed fairly often, e.g. in http://old.nabble.com/Merge-of-detached-signature-to27314294.html http://old.nabble.com/Pdf-signature-Issues-to23059531.html http://old.nabble.com/Hash-computation-problem-to22801988.html Regards, Michael. -- View this message in context: http://old.nabble.com/Java-applet-for-signing-PDF-documents-tp27888343p27896158.html Sent from the iText - General mailing list archive at Nabble.com. ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ 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/
