ssl - 在 PowerShell 上使用 netsh 失败并出现错误 : The parameter is incorrect

标签 ssl powershell cmd ssl-certificate netsh

我一直在尝试在 PowerShell 上运行以下命令:

    netsh http add sslcert ipport=0.0.0.0:443 certhash=<some certhash> appid={<random guid>}

问题是,它每次都返回"The parameter is incorrect"。我已经检查了证书哈希号和生成的 guid,它们都没有问题。事实上,我在 cmd.exe 中运行了相同的命令并且它运行良好,这增加了挫败感。

我想将变量作为 certhashappid 传递,这就是我使用 PowerShell 的原因。

如果有人能帮助我理解为什么它不起作用,或者它是否缺少某些东西才能在 PowerShell 上运行。

最佳答案

我终于知道了问题所在:虽然在 PowerShell 中你可以执行 cmd native 命令,命令的解析略有变化,在这种情况下,它打乱了 appid 的解释参数(那些大括号!)。

为了解决它,我只是用方括号 ( {} ) 和 <random guid> 括起来在单引号中,因此,

    netsh http add sslcert ipport=0.0.0.0:443 certhash=<certhash> appid='{<random guid>}'

与(注意缺少的“引号”)相反,

    netsh http add sslcert ipport=0.0.0.0:443 certhash=<certhash> appid={<random guid>}

并且该命令完美运行。

有关 PowerShell 解析的更多信息,Understanding PowerShell Parsing Modes .

关于ssl - 在 PowerShell 上使用 netsh 失败并出现错误 : The parameter is incorrect,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9722273/

相关文章:

windows - Cygwin 加载后对 Cygwin 执行批处理命令

Unicode 中的 Java System.out 输出

amazon-web-services - 如何为 Coreos kubernetes aws 集群创建工作证书

powershell - 如何在 PowerShell 中检索 IIS 网站的 SSL 证书

regex - 如何将 -replace 中的捕获字符串更改为结果中的大写?

powershell - 可选的静态类方法以实现接口(interface)兼容性

PHP curl : enforce low TLS version

ssl - Hyperledger Fabric SDK 未启动 TLS 握手

javascript - 未捕获的 ReferenceError : web3 is not defined at window. onload

windows - bat 文件、函数和插入符号