读取客户端证书容器名称
本文关键字:客户端 证书 读取 | 更新日期: 2023-09-27 18:24:11
我在计算机上安装了证书,正在尝试读取Container Name属性。这可能吗?怎么可能?
public void Read()
{
X509Store store = new X509Store(StoreName.My, StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly);
foreach (X509Certificate2 mCert in store.Certificates)
{
//Find Container name?
}
}
开始吧。
public static void Read()
{
X509Store store = new X509Store(StoreName.My, StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly);
foreach (X509Certificate2 mCert in store.Certificates)
{
//Find Container name?
var privateKey = mCert.PrivateKey as RSACryptoServiceProvider;
var uniqueKeyContainerName = privateKey.CspKeyContainerInfo.UniqueKeyContainerName;
var keyContainerName = privateKey.CspKeyContainerInfo.KeyContainerName;
var ProviderName = privateKey.CspKeyContainerInfo.ProviderName;
// etc.
}
}
有关CspKeyContainerInfo
的更多信息,请点击此处。