如何通过PowerShell 7在Windows证书存储中的证书上设置权限?

发布于 2025-02-05 17:10:16 字数 337 浏览 3 评论 0原文

到目前为止,我发现的每一个资源,例如这个问题,归结为:

  1. 将证书作为x509certificate2
  2. 铸造,私有私有属性到rsacryptoserviceProvider
  3. 在私钥上涉及CSPKeyContainerInfo属性的事情

,这在PowerShell 5中起作用,但是在PowerShell 7中,PrivateKey属性是RSACNG,而不是RsacryptoServiceProvider,因此步骤2不起作用。

Every resource I've found so far, such as this question, boils down to:

  1. Get the certificate as an X509Certificate2
  2. Cast the PrivateKey property to RSACryptoServiceProvider
  3. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

固执像三岁 2025-02-12 17:10:16

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文