问题描述
作为标题,我可以将 networkService 帐户添加到我在本地计算机上安装的 .pfx 证书中。我没有安装带有任何私钥密码的 .pfx。
Powershell 解决方案:
$cert = Get-ChildItem -Path cert:\LocalMachine\My | ? -FilterScript { $PSItem.Subject -like "*<MyCertMatch>*" }
$keyPath = Join-Path -Path $env:ProgramData -Childpath "\Microsoft\Crypto\RSA\MachineKeys"
$keyContainerName = $cert.PrivateKey.CspKeyContainerInfo.UniqueKeyContainerName
$keyFullPath = Join-Path -Path $keyPath -Childpath $keyName
# Here I can get-acl: using get-acl and see results
现在当我有了 fullPath 时,我可以添加一个新的 acl。然而,这个(上面)我被c#困住了:
if (cert.Subject.Contains("<myCertMatch>"))
{
RSACryptoServiceProvider rsa = cert.PrivateKey as RSACryptoServiceProvider;
if (rsa != null)
{
// Add logic here
}
}
这里 rsa 默认为 null
但 cert.PrivateKey
不是 null
,因此我无法检索容器或任何 ACL。
我很感激任何输入/反馈。
谢谢,
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)