Hi,

Until now, I have used this code 
(http://itextpdf.sourceforge.net/howtosign.html#signextitextsharp2) to sign a 
PDF file using a digital certificate stored on Microsoft Store.

The code is great, there is no problem with it if SHA1 is used.

The problem is SignedCms class don't support SHA256 algorithm for smart cards 
or crypto tokens.

Anyway, a SHA256 signature can be made using RSACryptoServiceProvider.

RSACryptoServiceProvider rsaKey = new RSACryptoServiceProvider();
X509Certificate2 cert = GetCertificateFromMicrosoftStore();
rsaKey = cert.PrivateKey as RSACryptoServiceProvider;
byte[] signature = rsaKey.SignData(documentHash, "SHA256");

The question is this:

How I can add the RSA signature generated in advance by the 
RSACryptoServiceProvider to the PDF file in order to obtain a signed PDF.

I have tried to use this code 
(http://itextpdf.sourceforge.net/howtosign.html#signextstd) but with no 
success (the error is "At least one signature requires validating - Internal 
cyptographyc library error").

Another method to solve the problem could be: How a PKCS#7 signed message can 
be created by using the signed data provided by the RSACryptoServiceProvider.

If this will help the community, I am ready to make a PayPal donation for a 
solution. 

Thanks.
Victor ([email protected])




------------------------------------------------------------------------------
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.itextpdf.com/book/
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/

Reply via email to