Reputation: 11
I'm trying to use the following code to sign some data using a key stored in smartcard
CspParameters csp = new CspParameters(1, "Advanced Card Systems CSP v3.0");
csp.Flags = CspProviderFlags.UseDefaultKeyContainer;
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(csp);
the app work on the first time, but second time throws an exception while executing line "3".
the exception message is "The parameter is incorrect.".
Upvotes: 1
Views: 334
Reputation: 801
ImportParameters
method have two reasons to throw this CryptographicException
.
"The Cryptographic Service Provider (CSP) cannot be acquired". Another is "The parameters parameter has missing fields". See the below page for more information - RSA CSP Import Parameters. The first solution, try the below code and let me know the result.
RSACryptoServiceProvider.UseMachineKeyStore = True
The error message shows that CSP missed parameter fields. Please refer to the page and test the example - Cryptography CSP Parameters.
Upvotes: 1