gpt4 book ai didi

windows - 在 PowerShell 中运行 openssl 命令

转载 作者:可可西里 更新时间:2023-11-01 13:27:00 26 4
gpt4 key购买 nike

我正在 PowerShell 中执行以下命令:

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 除非在特定情况下,因为它容易被注入(inject))。只需运行命令并在需要可变字符串扩展的地方引用参数:

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

要忽略命令的输出,一种常用技术是通过管道传输到 Out-Null

关于windows - 在 PowerShell 中运行 openssl 命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47190555/

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