Win 8.1 64位。 .NET 4.5。 Powershell 4.0。 (虽然我觉得这个问题是关系到.NET一般和不特定于PowerShell的。)无法读取X509Certificate2上的私钥
我生成自签名证书是这样的:
New-SelfSignedCertificate -DnsName 'TheIncredibleHulk' -CertStoreLocation Cert:\CurrentUser\My
然后我检索证书:
$Cert = Get-Item Cert:\CurrentUser\My\9E5A8322B890DA1247BD98BDAB288CA9D11CF99E
证书具有私有密钥:
$Cert.HasPrivateKey
True
还是没有呢?
$Cert.PrivateKey
(null)
为什么PrivateKey
成员为空?我如何检索私钥?
我推测这是使用PSPKI(https://pspki.codeplex.com/)? – Kev
@Kev不,没有使用自定义模块。 –
有必要授予访问权限的用户对私钥的访问权限。在certmgr.msc中,右键单击证书,执行“所有任务” - >管理私钥并授予访问权限。 –