jeudi 26 février 2015

Getting Certificate KeyContainerName to initialize CspParameters



How can I get the name of a Key Container that's in a smart card required for initialization of CspParameters?


CspParameters^ cspa = gcnew CspParameters(ProviderType, ProviderName, keyContainerName, cryptoSecurityKey, securityString);


RSACryptoServiceProvider^ csp = gcnew RSACryptoServiceProvider(cspa);


Since certificates from smart cards are automatically installed in a personal certificate store, I have tried looking for keyContainerName in X509Certificate2 and I couldn't find it there.


I have managed to find a container name of one of the keys outside of C++ using certutils.exe, and that way, I just entered that name and I managed to generate a digital signature using the aforementioned RSACryptoServiceProvider. It work beautifully. What what do I do with other certificates that the software might be used with? I can't ask the users to enter container name manually.


But, from what I understand, if I don't provide the container name (leave it empty), it doesn't work. So I need a way to find/get a key container name for any certificate in any smart card within the program code.


Unfortunately, most examples I've seen on the internet provide a constant predefined container name (like "example" or "test" - like here http://ift.tt/1DOBR5h ), which is useless in real life.





Aucun commentaire:

Enregistrer un commentaire