【问题标题】:Importing a certificate with "Import-PfxCertificate" results in an invalid cert使用“Import-PfxCertificate”导入证书会导致证书无效
【发布时间】:2016-09-04 15:03:33
【问题描述】:

我有一个证书 (.pfx),当我使用 GUI 导入它并选中(包括所有扩展属性)时,它可以正常工作。 如果我在没有检查的情况下导入它,我将无法在 IIS 中使用它。 如果我尝试通过 powershell 导入它(最终目标),我也无法在 IIS 中使用它。

当我尝试在 IIS 中使用它时,我收到以下错误消息:

指定的登录会话不存在。它可能已经 终止。

我尝试了几种导入方法,这是我的脚本的最新版本:

$certPassword = convertto-securestring 'thecertpasswordhere' -asplaintext -force
Import-PfxCertificate  $localFilePath -Password $certPassword

有没有人知道如何进行这项工作或我可以查看什么以获取更多信息?到目前为止,我没有运气搜索。

谢谢!

【问题讨论】:

  • 您是否尝试过指定证书位置?

标签: powershell ssl iis ssl-certificate x509certificate


【解决方案1】:

验证脚本是否使用适当的凭据(即LOCAL SYSTEM 等)运行。

您也可以尝试通过管道传输证书 (*.pfx),如下所示:

Get-ChildItem -Path $localFilePath | Import-PfxCertificate -CertStoreLocation Cert:\LocalMachine\My -Password (ConvertTo-SecureString -String "thecertpasswordhere"  -Force -AsPlainText

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-04-04
    • 2020-09-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-12
    • 2010-10-21
    相关资源
    最近更新 更多