Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell 无法将windows证书导出为pkcs12-“;密钥在指定状态下无效;_Powershell_Pkcs#12 - Fatal编程技术网

Powershell 无法将windows证书导出为pkcs12-“;密钥在指定状态下无效;

Powershell 无法将windows证书导出为pkcs12-“;密钥在指定状态下无效;,powershell,pkcs#12,Powershell,Pkcs#12,我正在尝试使用powershell将证书导出到pkcs12。我可以在MMC中很好地导出它。但powershell会呕吐 PS C:\Users\paul> $cert.export('PFX'," pass") Exception calling "Export" with "2" argument(s): "Key not valid for use in specified state. " At line:1 char:13 + $cert.export <<&l

我正在尝试使用powershell将证书导出到pkcs12。我可以在MMC中很好地导出它。但powershell会呕吐

    PS C:\Users\paul> $cert.export('PFX'," pass")
Exception calling "Export" with "2" argument(s): "Key not valid for use in specified state.
"
At line:1 char:13
+ $cert.export <<<< ('PFX'," pass")
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException

以本地管理员身份运行这似乎是一个不太可能的选择,但是您是否尝试过使用Pfx枚举而不是字符串

$pfx = [System.Security.Cryptography.X509Certificates.X509ContentType]::Pfx
$cert.Export($pfx,"pass")

我问这个问题的原因是,如果你看一下枚举背后的值,Pfx实际上有一个值3。

不知什么原因,当我清理完所有内容并重新开始时,它就开始工作了——软件的奥秘!
$pfx = [System.Security.Cryptography.X509Certificates.X509ContentType]::Pfx
$cert.Export($pfx,"pass")