问题
Hi I am trying to prevent multiple pin prompts for every pdf that needs to be signed.
I am using code from this example :
Pin is required when this part of code get process :
MakeSignature.SignDetached(appearance, pks, chain, crlList, ocspClient, tsaClient, estimatedSize,
subfilter);
Is there any way to memorize token pin and sing rest of pdfs without prompting for pin?
回答1:
Finally I found solution, this code does the trick :
...
RSACryptoServiceProvider rsa = (RSACryptoServiceProvider)pk.PrivateKey;
CspParameters cspp = new CspParameters();
cspp.KeyContainerName = rsa.CspKeyContainerInfo.KeyContainerName;
cspp.ProviderName = rsa.CspKeyContainerInfo.ProviderName;
// cspp.ProviderName = "Microsoft Smart Card Key Storage Provider";
cspp.ProviderType = rsa.CspKeyContainerInfo.ProviderType;
cspp.Flags = CspProviderFlags.NoPrompt;
RSACryptoServiceProvider rsa2 = new RSACryptoServiceProvider(cspp);
rsa.PersistKeyInCsp = true;
...
MakeSignature.SignDetached(...);
Creating CspParameters
before signing, remebers the pin code. There is official documentacion on msdn .
来源:https://stackoverflow.com/questions/27523779/sign-multiple-pdf-with-itextsharp-and-token-prompts-for-pin-every-time