X509 Certficate Reading

Hi,

I’m attempting to read a clients certificate using the following c# code:

            var store = new X509Store(StoreLocation.CurrentUser);

            store.Open(OpenFlags.ReadOnly);

            var certificates = store.Certificates;
            foreach (var certificate in certificates)
            {
                var friendlyName = certificate.FriendlyName;
                var xname = certificate.GetName(); //obsolete
                Console.WriteLine(friendlyName);
            }

            store.Close();

The problem is that it is giving details for the certificate on the server that the ASP code is running.

Any ideas? I’ve tried changing the constructor to

            var store = new X509Store(StoreName.My, StoreLocation.CurrentUser);
but I still can’t access it.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s