You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何为New-SelfSignedCertificate正确设置加密提供程序并解决类型错误?

解决New-SelfSignedCertificate的Provider Type未定义错误

你的问题出在-Provider参数的取值上——New-SelfSignedCertificate并不接受加密提供程序的显示名称(比如Microsoft Base Cryptographic Provider v1.0),而是需要对应的类型标识符(数字ID)。错误提示里的Provider type not defined就是因为系统无法识别你输入的显示名称对应的类型。

正确的解决方案

Microsoft Base Cryptographic Provider v1.0对应的类型ID是1,把你的命令里的-Provider参数值换成这个数字即可:

New-SelfSignedCertificate -CertStoreLocation "Cert:\LocalMachine\My" -Provider "1" -Subject "CN=test" -KeyUsage "CertSign", "CRLSign", "DigitalSignature", "NonRepudiation" -KeyExportPolicy Exportable -NotAfter (Get-Date).AddYears(40) -Type Custom

额外验证步骤

如果你需要确认其他加密提供程序的类型ID,可以在管理员PowerShell中运行以下命令,查看完整的提供程序列表及其对应的类型:

certutil -csplist

在输出结果里,你能找到Microsoft Base Cryptographic Provider v1.0的条目,其中会明确标注Type: 1。

注意事项

  • 确保你以管理员身份运行PowerShell,因为要向LocalMachine证书存储写入证书。
  • 这个旧的加密提供程序仅支持有限的密钥长度(最大1024位),如果你的测试应用需要更长的密钥,可能需要额外调整,但根据你的需求,保持使用这个提供程序即可。

内容的提问来源于stack exchange,提问作者Mehdi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.13 08:35:49