Gervasio Amy,

Gervasio Amy wrote:
> I'm using iText to sign pdf files, and I've got my private key on an
> Aladdin eToken, which was formated with "secondary authentication mode
> with RSA key", i.e. the token private keys are protected with another
> password.
> The question is that when I sign a pdf file, the library calls twice
> PdfPKCS7>>getEncodedPKCS7()... (on PdfSignatureAppearance>>preClose() and
> PdfSignatureAppearance>>close() ) and this method calls the native C_Sign
> function, wich needs the private key password.
> 
> The problem is that this behaviour is unwanted for me, because the final
> user don't have to put the private key twice.
> 
> Do you know how can I avoid this??

The result of the first PdfPKCS7.getEncodedPKCS7() call essentially is used
to determine the exact number of bytes required for the /Contents. This
results in minimum length signed PDF files but also in two sign calls.

If you want to circumvent this default behavior, you should not let iText
build the signature dictionary in PdfSignatureAppearance.preClose() but
supply one yourself beforehand using a good guess of the expected signature
size. You actually may want to work with the PdfSignatureAppearance methods
preClose(), getRangeStream(), and close() instead of the PdfStamper method
close() and so have more control concerning the signature container creation
process. For samples have a look at:
http://itextpdf.sourceforge.net/howtosign.html

Regards,   Michael.

PS: The signature API currently is being completely re-designed. Maybe the
problem of multiple signature generation is resolved there. You, therefore,
may simply wait for the publication if you can wait.

--
View this message in context: 
http://itext-general.2136553.n4.nabble.com/Re-Using-eToken-with-secondary-authentication-format-tp3772022p3776183.html
Sent from the iText - General mailing list archive at Nabble.com.

------------------------------------------------------------------------------
EMC VNX: the world's simplest storage, starting under $10K
The only unified storage solution that offers unified management 
Up to 160% more powerful than alternatives and 25% more efficient. 
Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php

Reply via email to