【问题标题】:How to export all certificates in certification path (.P7B)?如何导出证书路径(.P7B)中的所有证书?
【发布时间】:2021-01-31 02:49:19
【问题描述】:

我正在编写导出脚本。然而,我被困住了,因为无法通过将证书包含在证书路径中来导出我的证书。

I would like to reproduce this option in my script.

$ChainCertName = "fooCert"  # name of the certificate to export
$ChainIssuerName = "BarCert"        # certificate issuer

# search for a certificate which contains the requested name and provided by the requested issuer
$ChainCertListToExport = Get-ChildItem -Path cert:\CurrentUser\CA | ?{$_.Subject -Like "*CN=*$ChainCertName*" -and $_.Issuer -Like "CN=$ChainIssuerName*"}

foreach($ChainCertToExport in $ChainCertListToExport | Sort-Object Subject){

    # export P7B certificate
    $ChainCertDestPath = Join-Path -Path $ExportDirectory -ChildPath "Chain_certificate.p7b"
    Export-Certificate -Cert $ChainCertToExport -FilePath $ChainCertDestPath -Type p7b
}

我可以看到可以使用 Export-PfxCertificate 函数找到一些解决方案,但我还没有找到 p7b 的任何解决方案。

如果有人遇到这个问题,你能分享一下你的解决方案吗?

【问题讨论】:

  • 放弃了我的答案,因为我们仍然没有匹配项,Export-PfxCertificate 执行 pfx,这意味着您需要使用工具将其转换为 P7b 或如我之前的评论中所述,查看外部工具:Certutil - 在中间 CA social.technet.microsoft.com/Forums/en-US/… 等上使用 PowerShell 以 base64 格式导出根证书和中间 CA 证书。

标签: powershell


【解决方案1】:

如果您只需要以 .p7b 格式导出证书,请使用以下命令:

Get-ChildItem -Path Cert:\CurrentUser\CA | Export-Certificate -FilePath c:\certs\CA.p7b -Type P7B

更多详情请访问link

【讨论】:

    猜你喜欢
    • 2017-10-03
    • 2019-01-20
    • 2011-09-06
    • 2019-12-09
    • 2021-05-02
    • 1970-01-01
    • 1970-01-01
    • 2016-06-26
    • 2021-11-26
    相关资源
    最近更新 更多