Hello Thomasz,
so you have a regular XaDES signature for the original PDF file and try to
convert it into a PDF with an integrated signature?
I'm afraid this is impossible. In a PDF with an integrated signature, the
hash is not merely calculated for the original PDF revision you had to sign
but also for the additional PDF objects required to embed the signature.
Tomasz Korolczuk wrote:
> try {
> sap.preClose(exc);
> } catch (IOException e) {
> e.printStackTrace();
> } catch (DocumentException e) {
> e.printStackTrace();
> }
>
> byte[] hash = null;
> hash = Base64.decodeBase64(xml.getDocumentDigest().getBytes());
If you had not removed the original code used to calculate the hash digest,
you could have compared it to the digest you take from the XML; you would
have seen that they differ.
If you could change the process in a way that the XaDES signature is not
created for the original PDF but for the range stream returned by
sap.getRangeStream() after sap.preClose(exc), your chances get better to
produce something usable.
Unfortunately in your code you later build a new signedAttributes object.
Why do you expect you do it identically to how it was done by the code that
created the XaDES signature?
I'm afraid it's back to cryptography 101 and the whiteboard...
BTW,
Tomasz Korolczuk wrote:
> stamper = PdfStamperOSP.createSignature(reader, os, '\0');
it generally a good idea to use the createSignature overload with the append
parameter and set it to true, as otherwise prior signatures are rendered
broken.
Regards, Michael.
--
View this message in context:
http://www.nabble.com/Problem-with-transforming-PDF-from-XADES-signed-XML-file-info-%22normal%22-signed-PDF-tp25167508p25167534.html
Sent from the iText - General mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
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/