如何通过PowerShell 7在Windows证书存储中的证书上设置权限?
到目前为止,我发现的每一个资源,例如这个问题,归结为:
- 将证书作为x509certificate2
- 铸造,私有私有属性到rsacryptoserviceProvider
- 在私钥上涉及CSPKeyContainerInfo属性的事情
,这在PowerShell 5中起作用,但是在PowerShell 7中,PrivateKey属性是RSACNG,而不是RsacryptoServiceProvider,因此步骤2不起作用。
Every resource I've found so far, such as this question, boils down to:
- Get the certificate as an X509Certificate2
- Cast the PrivateKey property to RSACryptoServiceProvider
- Do stuff involving CspKeyContainerInfo property on the private key
This works in PowerShell 5, but in PowerShell 7, the PrivateKey property is an RSACng, not an RSACryptoServiceProvider, and so step 2 doesn't work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
fyi,私人关键被弃用。现在,您需要使用 getrsaprivatekey扩展方法。
我找不到任何文档,但是似乎.NET框架用于返回RSA,该RSA也实现了RSAcryptoServiceProvider,我们可以在这里获得 cspkeycontainerinfo ,但是现在我们需要抓住我们需要抓住键rsa rec rs rssa dece type type type type type rsacng 通过扩展方法返回。您可以从这里获取诸如$ cert.key.niquename之类的属性
FYI, PrivateKey was deprecated. You are now required to use the GetRSAPrivateKey extension method.
I cannot find any documentation, but it appears that .Net Framework used to return an RSA that also implemented RSACryptoServiceProvider which is where we could get the CspKeyContainerInfo, but now we are required to grab the key RSA derived type RSACng which is returned by the extension method. From here you can grab properties like the $cert.Key.UniqueName