sábado, 18 de julho de 2015

X509Certificate2

    public X509Certificate2 SearchByName(string Name)
        {
            X509Store store = new X509Store("MY", StoreLocation.CurrentUser);
            store.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly);
            X509Certificate2Collection collection = (X509Certificate2Collection)store.Certificates;
            X509Certificate2Collection collection1 = (X509Certificate2Collection)collection.Find(X509FindType.FindBySubjectDistinguishedName, Name, false);
            if (collection1.Count == 1)
            {
                return collection1[0];
            }
            else
            {
                return null;
            }

        }
Postar um comentário