OpenSSL 命令生成器
选择任务,填好空白项,复制一条可用的命令——其中每个选项都有解释。也可以粘贴你在别处找到的命令,让工具为你逐项拆解。
100% 本地运行——命令目录是静态数据,解析器在你的浏览器中运行;你输入的任何内容都不会发送到任何地方
密钥
生成 EC 私钥
现代的单条命令写法。输出 PKCS#8 私钥,Node.js、Go、Python、Java 和 WebCrypto 都能直接加载,无需转换。
参数
openssl genpkey -algorithm EC -pkeyopt ec_paramgen_curve:P-256 -out key.pem各选项的作用
- openssl genpkey
- OpenSSL 3.x 的密钥生成器。一条命令涵盖所有算法,而且总是输出 PKCS#8 容器——`-----BEGIN PRIVATE KEY-----`。
- -algorithm EC
- 生成椭圆曲线密钥。具体曲线由 -pkeyopt 指定。
- -pkeyopt ec_paramgen_curve:P-256
- 算法专用选项:在 P-256 曲线上生成。缺少此选项时,openssl 没有可用的曲线,会拒绝执行。
- -out key.pem
- 密钥的写出位置。省略这个选项,密钥就会输出到终端——看一眼很方便,用于其他任何场合都很糟糕。
说明
- 私钥文件中已经包含公钥。除非需要交给别人读取,否则完全不必单独保存公钥部分。
- P-256、prime256v1 和 secp256r1 是同一条曲线的三个名称。secp256k1 是一条真正不同的曲线,而不是第四个别名——只有在处理比特币或以太坊时才选它。
- 较旧的 `openssl ecparam -name prime256v1 -genkey -noout -out key.pem` 仍然可用,生成的密钥材料也相同,但采用的是 SEC1 容器(`BEGIN EC PRIVATE KEY`)。WebCrypto 和若干 JVM 代码路径只接受 PKCS#8。
- 这里的命令都不会改动文件权限。在共享机器上,请随后对密钥文件执行 `chmod 600`。
分步操作指南——以经过测试的分步演练完成同一任务,并解释每条命令的输出。
相关任务
目录中的每条命令在发布前都用默认参数生成,并在 OpenSSL 3.6.3 (9 Jun 2026), darwin64-arm64 上执行过。各版本之间的选项确实会有变化——凡是 1.1.1 与 3.x 不同的地方,任务中都会注明。
How it works
openssl is not one program but roughly thirty, each with its own option set, and the manual page is organised around those programs rather than around what anyone is trying to do. The result is that “make a self-signed certificate with a SAN” lives under req, which is documented as the certificate request command, and that the flag which actually decides whether browsers accept your certificate — -addext — appears nowhere near the top. This page inverts that: 36 tasks phrased as goals, each producing a command whose every flag is spelled out underneath.
The explanations are the point. A command you copied and cannot read is a command you cannot adapt, and openssl’s flags are unusually easy to misread — -noout suppresses the object rather than all output, -nocrypt is the difference between a script that runs and one that hangs at a prompt, and -copy_extensions is why a certificate you issued yourself has no hostnames in it. Each task also lists the specific ways it goes wrong, because those are what actually costs the afternoon.
Values you type are quoted for a POSIX shell before they go into the command, so a path with spaces or a subject with a comma survives the copy-paste. If a value contains something a shell would normally act on — backticks, $( ), a semicolon — the builder says so, because the quoting means it will be passed through literally rather than executed, and that is occasionally the surprise rather than the reassurance. Windows users should note that cmd.exe and PowerShell quote differently; the commands here assume sh, bash or zsh.
The reverse mode splits a pasted command the way a shell would — respecting quotes, escapes, pipes and redirections — and looks each flag up in a dictionary covering 180 options across 24 subcommands. Nothing is executed, and a flag that is not in the dictionary is labelled unknown rather than given an invented meaning. For the authoritative list your build accepts, openssl <subcommand> -help is always right and always local.