powershell - 未获取所需状态配置凭据私钥

标签 powershell certificate public-key dsc

我正在尝试将 powershell DSC 用于一些事情。我想按照 http://technet.microsoft.com/en-us/library/dn781430.aspx 处的说明对传递的凭据进行加密。在我在目标节点上运行 start-DscConfiguration 并出现错误之前,这一切似乎都运行良好:

The private key could not be acquired. + CategoryInfo : NotSpecified: (root/Microsoft/...gurationManager:String) [], CimException + FullyQualifiedErrorId : MI RESULT 1 + PSComputerName : DmitriyDev



回过头来,我检查了 mof 是否包含加密的凭据,而 meta.mof 包含匹配的指纹等。

回到原始文章,我看到了示例代码:

# Get the certificate that works for encryption 
function Get-LocalEncryptionCertificateThumbprint 
{ 
    (dir Cert:\LocalMachine\my) | %{ 
                    # Verify the certificate is for Encryption and valid 
                    if ($_.PrivateKey.KeyExchangeAlgorithm -and $_.Verify()) 
                    { 
                        return $_.Thumbprint 
                    } 
                } 
}


当我使用此代码(在目标节点上)测试我的证书时,我看到证书的 PrivateKey 为空。我不确定证书如何为空。用 certutil 和提到的技术尝试一些事情 http://blogs.technet.com/b/vishalagarwal/archive/2010/03/30/verifying-the-private-key-property-for-a-certificate-in-the-store.aspx看来我确实有一个私钥,但是 Powershell 仅将其视为 null。

在目标节点上,我什至手动导出了公共(public)私钥并重新导入它们,没有另一个 dsc 教程中概述的运气。

我还尝试使用 procmon 查看目标节点上的问题。我看到 wmiprvse 进程并看到它作为系统运行(如预期的那样),并且我检查以确保系统允许私钥的权限(全部在目标节点上)

所以我的问题是如何让我的私钥供 DSC 使用,特别是目标节点上的 LCM?或者我如何更多地诊断问题?

最佳答案

使用 New-SelfSignedCertificate 创建我的证书时,我遇到了类似的错误。对于任何有类似问题的人,我怀疑问题与 New-SelfSignedCertificate 使用的存储提供程序有关(请参阅 http://blogs.technet.com/b/vishalagarwal/archive/2010/03/30/verifying-the-private-key-property-for-a-certificate-in-the-store.aspx,其中谈到了 Microsoft 软件 key 存储提供程序和 .NET 类的问题)。 technet 上有一个 powershell 脚本可用它创建自签名证书,并默认使用不同的存储提供程序,这为我解决了这个问题。

关于powershell - 未获取所需状态配置凭据私钥,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26954085/

相关文章:

parsing - Powershell中的文本解析: Identify a target line and parse the next X lines to create objects

heroku - 在 Heroku 服务器上创建公钥

javascript - ethereumjs-util 中的 pubToAddress 方法抛出 AssertionError : false == true

json - PowerShell 将字符串转换为 json

powershell - Azure Powershell 失败并出现模糊错误 : One or more errors occurred

c# - Java Force 接受 SSL 证书

linux - 使用来自主机的 CA Trust Bundle 构建 Docker

python - 如何在 python 中翻译 RSA 公钥的 Perl 代码?

visual-studio - 第二次运行脚本后,Powershell 无法覆盖持续错误?

ios - 带有自签名证书的 HTTPS iOS