openssl生成证书
openssl生成证书
直接生成
1 | |
| 参数 | 意义 |
|---|---|
openssl req |
OpenSSL 的证书请求/生成工具。 |
-x509 |
直接输出「自签名证书」而不是证书请求。 |
-newkey rsa:2048 |
当场生成 2048 位 RSA 私钥。 |
-nodes |
no DES,即私钥 不加密(否则每次启动服务器都要输密码)。 |
-keyout key.pem |
把私钥写到 key.pem。 |
-out cert.pem |
把证书写到 cert.pem。 |
-days 3650 |
证书有效期 10 年。 |
-subj "/CN=example.com" |
证书主题只写 Common Name 字段,浏览器就把它当成域名。 |
算法特点
- RSA:老、慢、通用;命令
-newkey rsa:2048 - ECC(P-256):新、快、省流量;命令
-newkey ec:prime256v1 - Ed25519:最新、最小、最快;命令
-newkey ed25519
想用哪个把对应的 -newkey 换掉就行。
额外信息
1 | |
字段解释(一看就懂)
| 缩写 | 含义 | 示例 |
|---|---|---|
| C | 国家 | CN |
| ST | 省/州 | Beijing |
| L | 城市 | Beijing |
| O | 组织/公司 | MyCompany |
| OU | 部门 | IT |
| CN | 域名 | example.com |
| emailAddress | 邮箱 | admin@example.com |
openssl生成证书
https://blog.computerqwq.top/2025/08/11/openssl-sheng-cheng-zheng-shu/