Hi Paulo,

thanks for the info, but we append the 2nd signature as follows:

PdfStamper stp = PdfStamper.createSignature(reader, fout, '\0', null, true);

Below the code we use.

Can you maybe check the internal code of the PDF and see what is wrong ?
Thank a lot for your feedback.

We are really stuck with this ...

KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
ks.load(new FileInputStream("C:\\Data\\keystore\\test.keystore"),
"123456".toCharArray());
String alias = ks.aliases().nextElement();
PrivateKey key = (PrivateKey)ks.getKey(alias, "123456".toCharArray());
Certificate[] chain = ks.getCertificateChain(alias);
PdfReader reader = new
PdfReader("C:\\samples\\mill\\output\\Example_minimal-v300.pdf");
FileOutputStream fout = new
FileOutputStream("C:\\samples\\mill\\output\\Example_template-minimal-signed-itext-v300.pdf");
//PdfStamper stp = PdfStamper.createSignature(reader, fout, '\0');
PdfStamper stp = PdfStamper.createSignature(reader, fout, '\0', null, true);

PdfSignatureAppearance sap = stp.getSignatureAppearance();
sap.setCrypto(key, chain, null, PdfSignatureAppearance.SELF_SIGNED);
sap.setReason("I'm the author");
sap.setLocation("Lisbon");
//sap.setCertificationLevel(PdfSignatureAppearance.CERTIFIED_NO_CHANGES_ALLOWED);
// comment next line to have an invisible signature
sap.setVisibleSignature(new Rectangle(100, 100, 200, 200), 1, null);
stp.close();

Regards,

HT.


Paulo Soares wrote:
> 
> The second and later signatures must be done in append mode.
> 
> Paulo
> 
> ----- Original Message ----- 
> From: "HidekiT" <[email protected]>
> To: <[email protected]>
> Sent: Sunday, December 28, 2008 11:46 AM
> Subject: [iText-questions] itext invalidates first signature. Why ?
> 
> 
> 
> Hi,
> 
> we get signed PDF documents made with 3rd party software we need to add
> additional signature with iText.
> 
> Problem is that the 1st signature gets invalid when 2nd is added. The
> error
> is:
> 
> Error during signature verification.  
> Unexpected byte range values defining scope of signed data.
> Details: The signature byte range is invalid
> 
> We don't understand why this happens ? When we open the original document
> (with only 1st signature) no error is given so why is this invalidated
> with
> iText when new signature is added ?
> 
> I attach the file with the 2 signatures (only 10 kb) so if someone can
> tell
> us what the problem is we might solve it.
> 
> Any help much appreciated.
> 
> 
> ------------------------------------------------------------------------------
> _______________________________________________
> 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
> 
> 

-- 
View this message in context: 
http://www.nabble.com/itext-invalidates-first-signature.-Why---tp21191679p21199730.html
Sent from the iText - General mailing list archive at Nabble.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

Reply via email to