【问题标题】:windows cmd/Powershell how to export public key from private key pfx file without password prompt?windows cmd/Powershell如何在没有密码提示的情况下从私钥pfx文件中导出公钥?
【发布时间】:2021-10-06 04:24:19
【问题描述】:

Export a Certificate from pfx”可以无缝连接,无需用户输入密码。

Powershell 6.1+ commandlet 允许将-password 切换为Get-PfxCertificate

对于早期版本,possible solution 是:

powershell (Get-PfxCertificate -FilePath Private.pfx).GetPublicKey()

,用户必须在命令提示符下输入密码,否则会出错:
Get-PfxCertificate : The specified network password is not correct.

密码必须在提示时输入;不接受复制/粘贴。也没有为命令提供密码的开关。

【问题讨论】:

    标签: cmd passwords export public-key pfx


    【解决方案1】:

    Get-Pfxdata 做同样的工作,允许在 inscript 中处理密码,而无需用户干预受密码保护的 pfx 文件:

    set /p pwd="Enter password: "
    pwdstring
    set pwd=convertto-securestring \"%pwd%\" -asplaintext -force
    powershell Export-Certificate -Cert ((Get-PfxData -FilePath Private.pfx -password (%pwd%)).EndEntityCertificates[0]) -FilePath Public.cer
    

    在 Win 10 CMD 上测试

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-07-19
      • 2014-11-23
      • 2017-05-01
      • 1970-01-01
      • 2017-12-18
      • 2013-04-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多