Click here to Skip to main content
15,912,329 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
We have CspParameters as
C#
private const string _providerName = "Microsoft Base Smart Card Crypto Provider"
CspParameters cspParameters = new CspParameters();
cspParameters.ProviderName = _providerName;
cspParameters.ProviderType = 1;
cspParameters.KeyContainerName = container;
cspParameters.Flags = CspProviderFlags.UseExistingKey;


These CspParameters are assigned to RSACryptoServiceProvider to create instance of the CSP as
C#
using (RSACryptoServiceProvider rsaProvider = new RSACryptoServiceProvider(cspParameters))
                    {
                        pubKeyXml = rsaProvider.ToXmlString(false);
                    } // using


This function fails to acquire the CSP from the existing key containers. Where am i going wrong ?

What I have tried:

I have tried by changing the flags of the CspParameters. If the flag is set as cspParameters.Flags = CspProviderFlags.UseDefaultKeyContainer; , then it is assuming default container and creating the instance of CSP.
Posted
Comments
FARONO 24-Mar-16 6:53am    
how does it fail? does it return an error?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900