让我们为同一个域、多个实例加密 SSL 证书

Let's Encrypt SSL certs for same domain, multiple instances

我已经在域实例上成功安装了 Let's Encrypt SSL 证书(在 Ubuntu 14.4 上),但我现在想在同一域的另一个虚拟实例上安装相同的证书。

问题:对于同一个域的多个虚拟实例,我应该只从初始初始复制证书(使用 Let's Encrypt 工具),还是有其他更好的方法?

我想您不能向 Let's Encrypt 查询新证书,否则会使第一个证书失效。

我目前正在共享证书,有效。

从对SSL/TLS证书的普遍理解来看,我觉得这个问题很有趣。我个人认为在多台计算机或虚拟实例上共享相同的 SSL/TLS 证书没有普遍问题。唯一的问题可能只存在于证书的某些属性中,例如证书的主题备用名称(DNS 名称)(我的意思是像这样的选项)。

rfc2818 的 3.1(服务器标识)部分:

If the client has external information as to the expected identity of the server, the hostname check MAY be omitted. (For instance, a client may be connecting to a machine whose address and hostname are dynamic but the client knows the certificate that the server will present.)

...

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.

唯一的问题是 Let's Encrypt 似乎还不支持通配符证书(参见 FAQ)。我不确定该限制是否仍然存在,您真的无法使用 DNS Name=www.yourdomain.com 和 DNS Name=*.yourdomain.com 等主题备用名称 (``) 创建 Let's Encrypt。因此,您问题的确切答案可能取决于证书属性。

如果您要为两个服务器使用相同的证书,您可能会遇到使用 TLS 会话缓存的一些其他问题,这会提高 TLS 的性能,并且客户端和服务器可以使用相同的会话 ID,这提高 TLS 的性能。你应该描述你使用的确切场景,以便能够准确地考虑你是否会在会话 ID 中遇到一些问题。

是的,这是可能的。至少有两个选项:

  • 运行 certbot 手动模式

    ./certbot-auto certonly --manual -d example.com
    

    在这种情况下,certbot 需要从 .well-known/acme-challenge/ 提供一个随机文件,例如:

    http://example.com/.well-known/acme-challenge/-Y5pUBNKdx5GKSloP3RifHzUW3NT9xt1UAloNkHz7wc
    

    现在您可以将挑战文件分发到所有服务器或创建从所有站点到单个挑战服务器的重写:

    rewrite ^/.well-known/acme-challenge/(.*)$ http://acme.example.com/ redirect;
    

    acme.example.com 应该从单个服务器提供服务,root 指向 /tmp/certbot/public_html/(或者您将存储有问题的文件的任何地方)。

    查看 hooks in certbot manual 以编写此过程的脚本。

  • 使用 DNS 质询。在这种情况下,系统会要求您将 TXT 记录添加到您的 DNS,对于 example.com 域:

    _acme-challenge.example.com. 300 IN TXT "gfj9Xq...Rg85nM"
    

    同样,您可以自动执行此操作 using hooks --manual-auth-hook--manual-cleanup-hook