我有时间决定X509Certificate2证书的私钥是否可导出。根据我所做的研究,我应该使用 CspKeyContainerInfo 。这是我到目前为止(为简洁起见,删除错误检查)。假设RSA证书指纹 存在且 拥有私钥。
X509Certificate2 cert = Cryptography.GetCertificateFromStore(thumbprint);
RSACryptoServiceProvider provider = (RSACryptoServiceProvider)cert.PublicKey.Key;
Debug.WriteLine("RSA Certificate Gettting Exportable status");
// next line generates exception "Key does not exist"
bool isexportable = provider.CspKeyContainerInfo.Exportable;
Debug.WriteLine("RSA Certificate Exportable="+isexportable.ToString());