加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

windows – 在PowerShell中运行openssl命令

发布时间:2020-12-14 02:47:44 所属栏目:Windows 来源:网络整理
导读:我在Power Shell中执行以下命令: Invoke-Expression "openssl pkcs12 -in $certCN.pfx -nocerts -nodes -out $certCN.key -password pass:1111" 它工作正常,但openssl的输出导致丑陋的控制台错误: openssl : MAC verified OKAt line:1 char:1+ openssl pkc
我在Power Shell中执行以下命令:

Invoke-Expression "openssl pkcs12 -in $certCN.pfx -nocerts -nodes -out $certCN.key -password pass:1111"

它工作正常,但openssl的输出导致丑陋的控制台错误:

openssl : MAC verified OK
At line:1 char:1
+ openssl pkcs12 -in www.mywebsite.com.pfx -nocerts -node ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (MAC verified OK:String) [],RemoteException
    + FullyQualifiedErrorId : NativeCommandError

执行此OpenSSL命令并忽略输出或至少不将其解释为命令的最佳方法是什么?

解决方法

您不需要Invoke-Expression(实际上,it’s not recommended除外,因为它易受注入).只需运行命令并引用需要变量字符串扩展的参数:

openssl pkcs12 -in "$certCN.pfx" -nocerts -nodes -out "$certCN.key" -password pass:1111

要忽略命令的输出,一种常见的技术是管道输出Out-Null.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读