gpt4 book ai didi

ssl - DSC - 客户端错误 - 无法获取私钥

转载 作者:太空宇宙 更新时间:2023-11-03 14:42:29 25 4
gpt4 key购买 nike

我有一个 WMF5 下的 Windows 2012R2 DSC Pull 服务器和一个 WMF5.1 下的 Windows 2008R2 客户端。由于需要访问网络资源,凭据由 Pull 服务器编码到 MOF 中,并使用驻留在 Cert:\LocalMachine\My

中的证书进行加密

基于 https://msdn.microsoft.com/en-us/powershell/dsc/securemof key 是使用以下方法创建的:

New-SelfsignedCertificateEx `
-Subject "CN=${ENV:ComputerName}.${ENV:UserDnsDomain}" `
-EKU 'Document Encryption' `
-KeyUsage 'KeyEncipherment, DataEncipherment' `
-SAN ${ENV:ComputerName}.${ENV:UserDnsDomain} `
-FriendlyName 'DSC Credential Encryption certificate' `
-Exportable `
-StoreLocation 'LocalMachine' `
-StoreName 'My' `
-KeyLength 2048 `
-ProviderName 'Microsoft Enhanced Cryptographic Provider v1.0' `
-AlgorithmName 'RSA' `
-SignatureAlgorithm 'SHA256' `
-NotBefore $effDate `
-NotAfter $expiryDate

我已导出此证书,并将其导入到客户端计算机中,也在 Cert:\LocalMachine\My 中使用此命令

certutil -addstore My C:\DSC\DscPublicKey.cer

两台机器都可以通过以下代码找到证书(以交互式管理员用户运行)

$Cert =  Get-ChildItem -Path cert:\LocalMachine\My | Where-Object {
(
($_.Issuer -eq $IssuerCN) -and ($_.Subject -eq $IssuerCN)
)
}
Write-Host " Thumbprint : " $Cert.Thumbprint

我可以在 Pull 服务器上的 MOF 中看到加密的凭据。加密似乎按预期工作。

在客户端,MOF 处理日志显示了一个 MSFT_DSCMetaConfiguration 实例,该实例具有用于加密的匹配 CertificateID,并且 LCM 已使用拉取正确证书的函数进行了初始化。

function Get-LocalEncryptionCertificateThumbprint 
{
(dir Cert:\LocalMachine\my) | %{
# Verify the certificate is for Encryption and valid
If (($_.Issuer -eq $encryCertCN ) -and ($_.Subject -eq $encryCertCN ) )
{
return $_.Thumbprint
}
}
}

但是,Get-DSCConfigurationStatus 显示失败状态。当我查看日志时,我看到了错误

Status = "Failure";
Error = "The private key could not be acquired.";

我所有的管道阶段最终都从 InDesiredState = False; 切换到 InDesiredState = True;(我假设 DSC 这样做是为了避免永久尝试做一些它没有希望实现的事情)。

此时我唯一的想法是客户端的证书不在 SYSTEM 用户可以访问的位置 - 但我无法确定这是原因。

如果 Cert:\LocalMachine\My 位置不正确 - 证书应该安装在哪里?

编辑:

证书在 PULL 服务器上创建,.CER 文件导出并手动导入到目标节点(目前 - 最终将在 AD 中处理)。我还尝试导出完整的 PFX 并将其导入目标节点,结果相同。

在这一点上,我怀疑生成的证书是自签名的,不足以达到目的...

最佳答案

基于一些假设,您正在 Pull 服务器上创建证书,包括公钥和私钥。然后只在目标节点上导入公钥(.cer 文件)。问题是 Pull Server 不是需要私钥的机器。目标节点需要私钥。该过程应该更像这样。

  1. 在配置的目标节点上创建证书,包括公钥和私钥。参见 Securing the MOF File - Creating the Certificate on the Target Node .
  2. 导出公钥
  3. 在 Pull Server 上导入公钥
  4. 在 Pull Server 上编译配置
  5. 配置以某种方式在目标节点上运行

这被认为是一种不好的做法,但如果您想拥有一个证书,该过程将如下所示:

  1. 在 Pull Server 上创建证书,包括公钥和私钥。参见 Securing the MOF File - Creating the Certificate on the Target Node .
  2. 使用 Export-PfxCertificate 导出完整证书
  3. 将 key 安全地传输到目标节点(这通常不安全,为什么这是一种不好的做法)
  4. 在配置的目标节点导入pull key
  5. 在 Pull Server 上编译配置
  6. 配置以某种方式在目标节点上运行

关于ssl - DSC - 客户端错误 - 无法获取私钥,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42033834/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com