Hello!
I already asked a question about signing from smartcard and timestamping
(Java), but nobody replied, so I'm splitting it in two... :D 

I need to sign a PDF file using a smartcard, which I currently access via
SunPKCS11Provider. 
I have some simple code which does excatly that in the following manner
(just a snippet):

 PdfReader reader = new PdfReader(data); 
 baos = new ByteArrayOutputStream(); 
 PdfStamper stamper = PdfStamper.createSignature(reader, baos, '\0', null,
true);  
 PdfSignatureAppearance  sap = stamper.getSignatureAppearance(); 
 sap.setCrypto(key, certs, null, PdfSignatureAppearance.SELF_SIGNED); 
 stamper.close(); 

But now I need to add a timestamp, so I figured this approach would not
suffice, thus I chose to use the info I found in

 http://itextpdf.sourceforge.net/howtosign.html#signextdiccms

specifically the encapsulated method, using the Adobe.PPKMS filter.

I encountered a problem (InvalidKeyException) when accessing the private key
from the smartcard in

 generator.addSigner(key, (X509Certificate)chain[0],
CMSSignedDataGenerator.DIGEST_SHA1);

The problem is that no key are extracted from the smartcard, so "key" is not
an instance of RSAPrivateKey.

I could change PKCS11 provider (maybe using OpenSC, which I've never used
yet), but I doubt it could provide an RSA Private Key...



Is there any way to sign a PDF from a smartcard in a way which does not
prevent adding a timestamp?


Thanks in advance for your help!


-- 
View this message in context: 
http://www.nabble.com/Encapsulated-signature-using-smartcard-tp20500512p20500512.html
Sent from the iText - General mailing list archive at Nabble.com.


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
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