您的位置:首页 > 编程语言 > C#

C#遍历数字证书

2015-01-22 09:17 155 查看
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);

}

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐