----------------------------读取本地CA证书并绑定---------------
protected void Bind_CA()
{
string mail = null;
string realname = null;
X509Store store = new X509Store(StoreName.My,StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadOnly|OpenFlags.OpenExistingOnly);
X509Certificate2Collection collection = (X509Certificate2Collection)store.Certificates;
X509Certificate2Collection fcollection = (X509Certificate2Collection)collection.Find(X509FindType.FindByIssuerName, "Foxconn CA", false);
foreach (X509Certificate2 x509 in fcollection)
{
string[] dn = x509.Subject.Split(',');
foreach (string str in dn)
{
if (str.Trim().StartsWith("E"))
{
mail = str.Trim().Substring(str.Trim().IndexOf("=") + 1);
}
else if (str.Trim().StartsWith("CN"))
{
realname = str.Trim().Substring(str.Trim().IndexOf("=") + 1);
}
}
CAList.Items.Add(new ListItem(realname, mail));
}
}