码迷,mamicode.com
首页 > Windows程序 > 详细

C#遍历数字证书

时间:2015-01-22 09:26:35      阅读:194      评论:0      收藏:0      [点我收藏+]

标签:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Security.Cryptography.X509Certificates;

namespace WebApplication3
{
    public partial class WebForm4 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //System.Security.Cryptography.X509Certificates.X509Store
            //System.Security.Cryptography.X509Certificates.X509Store x = new System.Security.Cryptography.X509Certificates.X509Store();
            //string ss = x.Name;

            X509Store store = new X509Store(StoreName.My);
            store.Open(OpenFlags.ReadWrite);
            X509Certificate2 certificate = new X509Certificate2();
            X509Certificate2Collection storecollection3 = (X509Certificate2Collection)store.Certificates;
            string ss = "";
            if (storecollection3.Count == 0)
            {
                Console.WriteLine("Store contains no certificates.");
            }
            else
            {
                foreach (X509Certificate2 x509 in storecollection3)
                {
                    //Console.WriteLine("certificate name: {0}", x509.Subject);
                    ss = ss + "||" + x509.SerialNumber;
                    //x509.Issuer 颁发者
                }
            }
            Response.Write(ss);
        }
    }
}

C#遍历数字证书

标签:

原文地址:http://blog.csdn.net/sunny_lv/article/details/43014869

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!