gpt4 book ai didi

windows - 有人知道 powershell 证书提供程序路径如何映射到 certmgr.msc 文件夹吗?

转载 作者:可可西里 更新时间:2023-11-01 13:28:31 25 4
gpt4 key购买 nike

使用powershell调查Certificate Provider时我注意到所有路径看起来都相似但与 certmgr 中的文件夹结构不同.似乎很清楚:

Certs:\LocalMachine ~= Certificates (Local Computer)
Certs:\CurrentUser ~= Certificates - Current User

我也猜测:
Root ~= Trusted Root Certification Authority
My ~= Personal
WebHosting ~= WebHosting
...

但是我一直找不到任何官方引用(甚至合理的解释)来给我 warm fuzzy我在找...

我的目的是在本地测试 https WCF 服务(服务器端和客户端)。我可以使用 New-SelfSignedCertificate 轻松生成服务器所需的自签名证书.但是,如果我尝试将我的客户端(也是 .NET)指向该服务,它就无法连接,因为该服务提供了一个不受信任的证书。

我发现了各种过时的引用资料(如 this one ),展示了如何使用 makecert 的组合。 (现已弃用)和 certmgr 生成证书颁发机构,然后使用它为我的 https 服务签署证书,然后将证书颁发机构证书安装到受信任的根证书颁发机构容器中以使一切正常。虽然这种方法可能会奏效,但它肯定对开发人员/自动化不友好。

也就是说,我能够使用 powershell 来做到这一点:
$my_cert_store_location = "Cert:\LocalMachine\My"
$root_cert_store_location = "Cert:\LocalMachine\Root"
$root_friendly_name = "Test Root Authority"
$root_cert_subject = "CN=$($root_friendly_name)"
# The ip and port you want to reserve for your app
$ipport = "127.0.0.11:8734"
# Your app guid (found in ApplicationInfo.cs)
$appid = "{f77c65bd-d592-4a7b-ae32-cab24130fdf6}"
# Your dns name
$dns_name = "my-machine-local"
$rebuild_root_cert = $false

$root_cert = Get-ChildItem $my_cert_store_location |
Where-Object {$_.SubjectName.Name.Equals($root_cert_subject)}
if ($root_cert -and $rebuild_root_cert)
{
Get-ChildItem $root_cert_store_location |
Where-Object {$_.SubjectName.Name.Equals($root_cert_subject)} |
Remove-Item

Remove-Item $root_cert
$root_cert = $false
}
if (-not $root_cert)
{
$root_cert = New-SelfSignedCertificate `
-Type Custom `
-FriendlyName $root_friendly_name `
-HashAlgorithm sha384 `
-KeyAlgorithm RSA `
-KeyLength 4096 `
-Subject $root_cert_subject `
-KeyUsage DigitalSignature, CertSign `
-NotAfter (Get-Date).AddYears(20) `
-CertStoreLocation $my_cert_store_location
Write-Output "Created root cert: $($root_cert.Thumbprint)"

$exported_cert = New-TemporaryFile
Export-Certificate -Cert $root_cert -FilePath $exported_cert.FullName
$imported_root_cert = Import-Certificate -FilePath $exported_cert.FullName `
-CertStoreLocation $root_cert_store_location
Write-Output "Imported root cert to: $($root_cert_store_location)\$($imported_root_cert.Thumbprint)"
}

Write-Output "Root cert is: $($root_cert.Thumbprint)"

$test_signed_cert_subject = "CN=$($dns_name)"
$test_signed_cert = Get-ChildItem $my_cert_store_location |
Where-Object {$_.SubjectName.Name.Equals($test_signed_cert_subject)}
if (-not $test_signed_cert)
{
$test_signed_cert = New-SelfSignedCertificate `
-Type Custom `
-Subject $test_signed_cert_subject `
-FriendlyName $dns_name `
-Signer $root_cert `
-CertStoreLocation $my_cert_store_location
Write-Output "Created signed cert: $($test_signed_cert.Thumbprint)"
}

Write-Output "Signed cert is: $($test_signed_cert.Thumbprint)"

if ($test_signed_cert)
{
netsh http delete sslcert `
ipport="$($ipport)"
netsh http add sslcert `
ipport="$($ipport)" `
appid="$($appid)" `
certstorename="My" `
certhash="$($test_signed_cert.Thumbprint)"
Write-Output "Assigned signed cert to: $($ipport)"
}

但问题仍然存在......是否有任何关于证书提供者路径如何映射到 certmgr 文件夹的信息?

最佳答案

这是容器(括号中)及其描述之间的映射:

  • 个人(我的) — 此容器用于存储带有私钥的证书。当使用证书私钥时,应用程序会查找此容器以查找适当的证书和关联的私钥。
  • 受信任的根证书颁发机构 (ROOT) — 此容器包含没有私钥的可信自签名证书。每个证书链必须链接到以自签名形式提供的证书。此自签名证书是“根证书”或“受信任的 anchor ”。但是,并非所有根证书都可以视为受信任的。您应该仔细选择您认为受信任的新证书。
  • 企业信托(信托) — 此容器用于存储证书信任列表 (CTL)。例如, key 管理服务器将其证书添加到此容器中。
  • 中级认证机构 (CA) — 这个容器保存了许多不同类型的 CA 证书。这些证书通常由证书链引擎用于构建证书链。
  • 可信发布商 (TrustedPublisher) — 此容器保留明确受信任的签名证书。虽然数字签名证书链接到受信任的根证书颁发机构,但许多应用程序(如 Microsoft Office 和 Windows PowerShell)需要在此容器中存储特定的签名证书,以便信任来自该特定签名者的签名。这意味着数字签名感知应用程序可以信任一个签名证书,但不信任另一个签名证书,即使两个证书都是由同一证书颁发机构颁发的。
  • 不受信任的证书(不允许) — 此容器保留明确不受信任的证书。如果您决定不信任特定证书或特定证书颁发机构颁发的所有证书,只需将这些证书添加到此容器即可。默认情况下,此容器已包含两个证书。强烈建议不要从容器中取出它们。有关更多信息,请阅读以下文章:http://support.microsoft.com/kb/293817 .
  • 第三方根证书颁发机构 (AuthRoot) — 此证书容器类似于受信任的根证书颁发机构。它保留来自 Microsoft 根证书计划的证书。有关 Microsoft 根证书计划的详细信息,请阅读以下文章:http://support.microsoft.com/kb/931125 .
  • 受信任的人 (TrustedPeople) — 此容器保存颁发给明确信任的人员或最终实体的证书。大多数情况下,这些是自签名证书或 Microsoft Outlook 等应用程序中明确信任的证书。要与其他方共享 EFS 加密文件,您必须在此存储中拥有他们的证书。
  • 证书注册请求 (REQUEST) — 此容器存储证书注册请求,直到这些请求提交给证书颁发机构。当证书颁发机构响应请求颁发证书时,您需要使用特殊实用程序(例如 CertReq.exe)将证书安装到此容器中。之后,证书注册请求将作为证书传输到 Personal (My) 容器。
  • 智能卡可信根 (SmartCardRoot) — 此容器用于存储受信任的智能卡证书。
  • 其他人(通讯录) — 此容器维护已添加到 Outlook 联系人的证书。
  • Active Directory 用户对象 (UserdDS) — 此容器用于存储与用户对象关联并在 Active Directory 中发布的证书。当查看用户对象的属性时,此容器的内容等于在 Active Directory 用户和计算机控制台的高级 View 中显示的证书。
  • 关于windows - 有人知道 powershell 证书提供程序路径如何映射到 certmgr.msc 文件夹吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40440958/

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