假设我有多个当前用户的个人证书。但是只有一张证书属于Aladdin eToken。
我想确定哪个证书属于Aladdin eToken。
我应该为此使用 X509Store
和 X509Crtificate
吗?
我应该试用 eToken SDK 吗?
最佳答案
这可以帮助您找到证书。 它创建了一个位置和商店列表,并给出了证书的数量。 在输入和输出 token 的情况下运行它可以帮助您找到它的位置:
public static string ListCertificatesCount()
{
string output = "";
foreach (StoreName st in (StoreName[])Enum.GetValues(typeof(StoreName)))
{
foreach (StoreLocation loc in (StoreLocation[])Enum.GetValues(typeof(StoreLocation)))
{
string line = "StoreName " + Enum.GetName(typeof(StoreName), st) + ", StoreLocation " + Enum.GetName(typeof(StoreLocation), loc) + ": Count: ";
try
{
using (X509Store keyStore = new X509Store(st, loc))
{
keyStore.Open(OpenFlags.ReadOnly);
line += keyStore.Certificates.Count;
keyStore.Close();
}
}
catch (Exception ex)
{
line += "Fail: " + ex.Message;
}
output += line + Environment.NewLine;
}
}
return output;
}
关于c# - C#中如何判断哪个个人证书来自硬件设备?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20648110/