gpt4 book ai didi

powershell - 无法将Windows证书导出为pkcs12- “Key not valid for use in specified state”

转载 作者:行者123 更新时间:2023-12-02 04:09:33 24 4
gpt4 key购买 nike

我正在尝试将具有Powershell的证书导出到pkcs12。我可以在MMC中将其导出。但是Powershell Barfs

    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

私钥可导出
PS C:\Users\paul> $cert.privatekey.cspkeycontainerinfo


MachineKeyStore : True
ProviderName : Microsoft RSA SChannel Cryptographic Provider
ProviderType : 12
KeyContainerName : fd6ce48f23c5a94dee97bf7e87ef3da2_2868494a-a319-4976-80a7-e0f129e23cfd
UniqueKeyContainerName : fd6ce48f23c5a94dee97bf7e87ef3da2_2868494a-a319-4976-80a7-e0f129e23cfd
KeyNumber : Exchange
Exportable : True
HardwareDevice : False
Removable : False
Accessible : True
Protected : False
CryptoKeySecurity : System.Security.AccessControl.CryptoKeySecurity
RandomlyGenerated : False

以本地管理员身份运行

最佳答案

这似乎是一个长镜头,但是您是否尝试过使用Pfx枚举而不是字符串?

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

我问的原因是,如果您看一下枚举的基础值,Pfx实际上的值为3。

关于powershell - 无法将Windows证书导出为pkcs12- “Key not valid for use in specified state”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5997948/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com