Valentin, as Andreas mentioned before, iText does not do any PKCS11 session handling.
More in detail: Your stack trace > java.security.ProviderException: Could not obtain session > at > sun.security.pkcs11.SessionManager.getOpSession(SessionManager.java:130) > at sun.security.pkcs11.Token.getOpSession(Token.java:247) > at sun.security.pkcs11.P11Signature.initialize(P11Signature.java:283) > at > sun.security.pkcs11.P11Signature.engineInitSign(P11Signature.java:375) > at java.security.Signature$Delegate.engineInitSign(Unknown Source) > at java.security.Signature.initSign(Unknown Source) > at org.btrust.signer.PDFSigner.initSignPDF(PDFSigner.java:299) > at org.btrust.signer.PDFSigner.signPDF(PDFSigner.java:486) > at org.btrust.util.SignThread.run(SignThread.java:664) shows that some org.btrust.* software obtains the PKCS11 session and, thus, is responsible for releasing it again (if there is a need for releasing it). Your other stack trace > [...] > at > com.lowagie.text.pdf.PdfSignatureAppearance.preClose(PdfSignatureAppearance.java:721) > at > org.btrust.ws.TestCVProvider.signPDFFile(TestCVProvider.java:178) > at > org.btrust.ws.TestCVProvider.testCryptovisionProvider(TestCVProvider.java:80) > at org.btrust.ws.TestCVProvider.main(TestCVProvider.java:53) indicates that some org.btrust.* software uses iText for signing, most likely after injecting the PKCS11 connection into it. The org.btrust.* responsibility for releasing the PKCS11 session, therefore, might include releasing the iText objects used for signing. Otherwise the private key object might be locked in memory for a long time. It might suffice, though, if there was a way to explicitly close the session initially obtained. Regards, Michael Sessions can be a pain in the a** in a garbage collection oriented memory handling environment... -- View this message in context: http://itext-general.2136553.n4.nabble.com/SunPKC11-Exception-when-signing-PDF-tp4340293p4347527.html Sent from the iText - General mailing list archive at Nabble.com. ------------------------------------------------------------------------------ Keep Your Developer Skills Current with LearnDevNow! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-d2d _______________________________________________ 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
