为多域生成 CSR

发布于 2025-01-03 00:36:17 字数 1459 浏览 2 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

千笙结 2025-01-10 00:36:17

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

如果存在 dNSName 类型的 subjectAltName 扩展,则必须
被用作身份。否则,(最具体的)通用名称
必须使用证书的主题字段中的字段。虽然
使用通用名称是现有做法,已被弃用并且
鼓励证书颁发机构改用 dNSName。

使用指定的匹配规则进行匹配
[RFC2459]。如果给定类型的多个标识存在于
证书(例如,多个 dnsName 名称、任何一个中的匹配项)
该集合被认为是可以接受的。)

本文档中所述(除了我会使用-des3 也适用于 genrsa 命令,以保护私钥):

  • 复制您的初始 openssl.cnf 文件(原始文件可能是下面某处Linux 上的 /etc)。
  • 编辑它以在 [ req ] 部分添加 req_extensions = v3_req
  • 编辑它以在[ v3_req ] 部分。
  • 让 OpenSSL 使用该配置文件。使用 OPENSSL_CONF=/path/to/your/openssl.cnf openssl req ... 调用它,

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

For an X.509 certificate to support multiple domains, it must use multiple Subject Alternative Name DNS entries, according to RFC 2818 (HTTP over TLS) (or 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.)

As described in this document (except I would use -des3 too for the genrsa command, to protect the private key):

  • Make a copy your initial openssl.cnf file (the original is probably somewhere under /etc on Linux).
  • Edit it to add req_extensions = v3_req in the [ req ] section.
  • Edit it to add subjectAltName=DNS:www.example.com,DNS:www.other-example.com (one DNS: entry per host name you require) in the [ v3_req ] section.
  • Make OpenSSL use that configuration file. Call it with OPENSSL_CONF=/path/to/your/openssl.cnf openssl req ...

This being said, I wouldn't worry too much about setting any extension in the CSR. Any good CA should ignore whatever you've set in the CSR and only set whatever they have actually verified when issuing the actual certificate. They'll happily replace any RDN in your Subject DN (e.g. Country, Organization, ...) as well as any extension (SAN or Key Usage). Firstly, if they let any extension as requested in the CSR by the applicant, this would be a security risk, since some applicants could really get anything. Secondly, that's how they make extra money, by charging you for setting a few bits here and there (e.g. code signing extension): they'll make sure that you only get what you've paid for in your certificate. I understand, though, that you may want to put all the names you request in your CSR, just to be sure.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文