[英]Importing a certificate with "Import-PfxCertificate" results in an invalid cert
I have a certificate ( .pfx
) that works fine when I import it using the GUI with (include all extended properites) checked.我有一个证书(
.pfx
),当我使用 GUI 导入它并检查(包括所有扩展属性)时,它可以正常工作。 If I import it without that checked, I can't use it in IIS.如果我在没有选中的情况下导入它,我将无法在 IIS 中使用它。 If I try to import it via powershell (the end goal), I also can't use it in IIS.
如果我尝试通过 powershell(最终目标)导入它,我也无法在 IIS 中使用它。
When I try to use it in IIS, I get this error message:当我尝试在 IIS 中使用它时,我收到此错误消息:
A specified logon session does not exist.
指定的登录会话不存在。 It may already have been terminated.
它可能已经被终止。
I've tried a few methods for importing it, this is the most recent version of my script:我尝试了几种导入它的方法,这是我的脚本的最新版本:
$certPassword = convertto-securestring 'thecertpasswordhere' -asplaintext -force
Import-PfxCertificate $localFilePath -Password $certPassword
Does anyone have any idea how to make this work or what I can look into for more info?有没有人知道如何使这项工作或我可以查看更多信息? I've had no luck searching so far.
到目前为止,我一直没有运气搜索。
Thanks!谢谢!
Verify the script is running with the appropriate credentials (ie LOCAL SYSTEM
, etc.).验证脚本是否使用适当的凭据(即
LOCAL SYSTEM
等)运行。
You can also try piping the certificate (*.pfx) as follows:您还可以尝试通过管道传输证书 (*.pfx),如下所示:
Get-ChildItem -Path $localFilePath | Import-PfxCertificate -CertStoreLocation Cert:\LocalMachine\My -Password (ConvertTo-SecureString -String "thecertpasswordhere" -Force -AsPlainText
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.