views:

59

answers:

2

I am able to get certificate collection in particulaer store by using the following statment.

X509Store.Certificates

But not sure how I can get the list of certificate store names present under current user or local machine. I also checked the StoreName enumeration but it only lists the standard store names but not the ones defined by the user.

I want the list of CERTIFICATE STORES, not the list of certificates in the particular store.

A: 

You need to get the certificates out of the store and then from there you can grab the certificate names.

X509Store store = new X509Store ("teststore", StoreLocation.CurrentUser);
X509Certificate2Collection storecollection = (X509Certificate2Collection)store.Certificates;
    Console.WriteLine ("Store name: {0}", store.Name);
    Console.WriteLine ("Store location: {0}", store.Location);
foreach (X509Certificate2 x509 in storecollection)
{
    Console.WriteLine("certificate name: {0}",x509.Subject);
}
Kyle C
Yes. this code will work for the certificate names but I was asking about certificate STORE names not the certificate names.
Imran
A: 

http://msdn.microsoft.com/en-us/library/aa376058(VS.85).aspx

Don't think there's a managed .net way of doing this. Possibly the closest may be to use .net's registry functions to read the store names from the registry?

dotalchemy
Thanks this really solved my problem.
Imran
Cool! Click the little up arrow above the number to the left :)
dotalchemy