【发布时间】: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