在 Linux 下使用 OpenSSL 生成 CSR(证书签名请求) 通常分几种常见场景。下面给你最常用、最清晰的做法。
openssl req -new -newkey rsa:2048 -nodes \
-keyout domain.key -out domain.csr
说明:
rsa:2048:2048 位 RSA 私钥(也可 4096)-nodes:私钥不加密(无密码)domain.key:生成的私钥domain.csr:生成的 CSR执行后会提示输入:
如果你已经有私钥(如 domain.key):
openssl req -new -key domain.key -out domain.csr
csr.conf[req]
default_bits = 2048
prompt = no
default_md = sha256
distinguished_name = dn
req_extensions = v3_req
[dn]
C = CN
ST = Beijing
L = Beijing
O = My Company
OU = IT
CN = example.com
[v3_req]
subjectAltName = @alt_names
[alt_names]
DNS.1 = example.com
DNS.2 = www.example.com
openssl req -new -key domain.key \
-config csr.conf -out domain.csr
openssl ecparam -genkey -name prime256v1 -noout -out domain.key
openssl req -new -key domain.key -out domain.csr
openssl req -in domain.csr -noout -text
| 用途 | 命令 |
|---|---|
| Web 服务器证书 | Common Name = 域名 |
| 多域名 | 使用 SAN(subjectAltName) |
| 本地测试 | CN = localhost |
| 企业内部 | O / OU 填写公司信息 |
如果你告诉我:
我可以直接帮你写出可用的命令或配置文件。