apache - 为多域生成 CSR

标签 apache ssl openssl

<分区>

如何为多域生成 CSR。

我发现为单个域生成 CSR 如下:

openssl req -new -newkey rsa:2048 -nodes -keyout yourdomain.key -out yourdomain.csr

但是我如何生成 CSR 多域

最佳答案

对于支持多个域的 X.509 证书,它必须使用多个主题备用名称 DNS 条目,根据 RFC 2818 (HTTP over TLS) (或 RFC 6125):

If a subjectAltName extension of type dNSName is present, that MUST be used as the identity. Otherwise, the (most specific) Common Name field in the Subject field of the certificate MUST be used. Although the use of the Common Name is existing practice, it is deprecated and Certification Authorities are encouraged to use the dNSName instead.

Matching is performed using the matching rules specified by [RFC2459]. If more than one identity of a given type is present in the certificate (e.g., more than one dNSName name, a match in any one of the set is considered acceptable.)

this document 中所述(除了我也会对 genrsa 命令使用 -des3 来保护私钥):

  • 复制您的初始 openssl.cnf 文件(原始文件可能位于 Linux 上的 /etc 下)。
  • 对其进行编辑,在 [ req ] 部分添加 req_extensions = v3_req
  • 编辑它以添加 subjectAltName=DNS:www.example.com,DNS:www.other-example.com(一个 DNS: 您需要的主机名条目) 在 [ v3_req ] 部分。
  • 让 OpenSSL 使用该配置文件。用 OPENSSL_CONF=/path/to/your/openssl.cnf openssl req ...
  • 调用它

话虽这么说,但我不会太担心在 CSR 中设置任何扩展名。任何好的 CA 都应该忽略您在 CSR 中设置的任何内容,并且只设置他们在颁发实际证书时实际验证过的内容。他们会很乐意替换您的主题 DN 中的任何 RDN(例如国家/地区、组织...)以及任何扩展名(SAN 或 key 用法)。首先,如果他们允许申请人在 CSR 中要求的任何延期,这将是一个安全风险,因为一些申请人真的可以得到任何东西。其次,这就是他们赚取额外收入的方式,通过向您收取一些设置费用(例如代码签名扩展):他们将确保您只得到您在证书中支付的费用。不过,我知道您可能希望将您请求的所有名称都放在您的 CSR 中,以确保万无一失。

关于apache - 为多域生成 CSR,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9158245/

相关文章:

java - 使用 SSLSockets 的正确方法是什么?为什么会收到这些错误?

encryption - 从 -password 向 openssl .pem 文件添加密码

apache - RewriteEngine on给出错误403

laravel - 更改 laravel 的 htaccess,使其路由到特定文件

php - 在 centos 中放宽 open_basedir 错误

c++ - 从 RSA key 对变量中分离公钥和私钥

php - 验证上传的文件是否为有效的 PEM 文件

php - Apache 错误: No matching DirectoryIndex

没有为 ingress-nginx 后端配置 SSL 直通

SSLITE 错误 - 使用 Websphere 并使用 apache 客户端 3.x 调用 Web 服务