【发布时间】:2021-06-10 12:07:30
【问题描述】:
根据this Medium post,我正在尝试使用 HTTPS 设置本地 Next.js 开发服务器。
但是当我在 Windows 10 Powershell 中运行这个命令时:
openssl req -x509 -out localhost.crt -keyout localhost.key \
-newkey rsa:2048 -nodes -sha256 \
-subj '/CN=localhost' -extensions EXT -config <( \
printf "[dn]\nCN=localhost\n[req]\ndistinguished_name = dn\n[EXT]\nsubjectAltName=DNS:localhost\nkeyUsage=digitalSignature\nextendedKeyUsage=serverAuth")
我收到此错误The '<' operator is reserved for future use.:
At line:1 char:142
+ ... des -sha256 \ -subj '/CN=localhost' -extensions EXT -config <( \ prin ...
+ ~
The '<' operator is reserved for future use.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : RedirectionNotSupported
我尝试了一些方法,但无法使此命令正常工作。
【问题讨论】:
-
为什么不直接删除
<? -
您的麻烦来自在 Powershell 中重定向输入,我可以在这里回答,但您还有其他帖子 [在 Windows PowerShell 中重定向标准输入\输出](stackoverflow.com/a/11788475/608772) 或 Can I send some text to the STDIN of an active process under Windows?跨度>
-
@JPBlanc 我已经阅读了这两个主题,但我仍然不确定我是否理解。类似... ```Get-Content code.ext | openssl ...?``? code.ext 中有什么内容?
-
好吧,我设法绕过这个问题,根据这个 stackoverflow 线程将命令一分为二:gist.github.com/cecilemuller/9492b848eb8fe46d462abeb26656c4f8
-
@Chris,其他人发布您的解决方案作为答案会很有用。
标签: powershell ssl next.js escaping