简体   繁体   English

导入带有“Import-PfxCertificate”的证书会导致证书无效

[英]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.

相关问题 Import-PfxCertificate 未将证书保存在指定的系统存储位置 - Import-PfxCertificate not saving certificate in designated System Store Location 通过 Import-PFXCertificate 导入 PFX 时没有私钥? - No Private Key when importing PFX via Import-PFXCertificate? Import-PFXCertificate密码问题 - Import-PFXCertificate password issue Import-PfxCertificate没有提示? - Import-PfxCertificate without prompt? 导入 PfxCertificate 返回 FileNotFoundException - Import-PfxCertificate returns FileNotFoundException Import-PFXCertificate:指定的网络密码不正确 - Import-PFXCertificate: The specified network password is not correct 在 powershell 中使用 Import-PfxCertificate 命令安装证书 pfx 文件时找不到私钥 - private key not found while certificate pfx file installed with Import-PfxCertificate command in powershell Import-PfxCertificate no-ops,但没有错误或任何内容 - Import-PfxCertificate no-ops, but no error or anything Import-PfxCertificate Powershell功能在Localmachine上运行正常,但在其他虚拟机上使用Powershell远程处理时不起作用 - Import-PfxCertificate powershell function work fine on Localmachine but not working when using powershell remoting on other virtual machine 当证书的现有指纹与站点匹配时,我想导入 SSL 证书 - I want to import the SSL Certificate when the existing thumbprint of the cert matched to the site
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM