【问题标题】:How can we setup SSL/TLS using the same certificate on multiple EC2 servers我们如何在多个 EC2 服务器上使用相同的证书设置 SSL/TLS
【发布时间】:2020-07-27 17:51:21
【问题描述】:

经过一番挫折,我能够设置 SSL/TLS,via these instructions。我确实遇到了一些关于“缺少证书密钥”的错误,但我能够通过重新创建 CSR 文件来解决这个问题,将通用名称修复为:*.opensourceroads.com

我请求并安装了 Comodo 通配符证书。

一切都在开发子域上工作。

现在,对于生产服务器....

首先,我将私钥和证书文件复制到主目录,并将这些 HOME 版本的权限设置为 755。这允许我从开发服务器下载它们并将它们上传到生产服务器,我这样做了。

顺便说一句,生产服务器托管内容为www.opensourceroads.com

这样做之后,我按照说明安装了 mod_ssl,将私有和证书文件移到了正确的位置,并按照教程更改了它们的权限和所有权。

sudo chown root:root custom.key
sudo chmod 600 custom.key
ls -al custom.key
sudo chown root:root custom.crt
sudo chmod 600 custom.crt
ls -al custom.crt
sudo chown root:root intermediate.crt
sudo chmod 644 intermediate.crt
ls -al intermediate.crt

然后我更改/etc/httpd/conf.d/ssl.conf 以匹配开发服务器上的内容。

但是,当我转到sudo service httpd restart 时,它并没有重新启动。当我journalctl -xe 时,我在日志中看到以下几行:

-- Unit httpd-init.service has begun starting up.
Jul 27 17:30:04 ip-172-31-21-209.us-east-2.compute.internal httpd-ssl-gencerts[56816]: Missing certificate key!
Jul 27 17:30:04 ip-172-31-21-209.us-east-2.compute.internal systemd[1]: httpd-init.service: Main process exited, code=exited, status=1/FAILURE
Jul 27 17:30:04 ip-172-31-21-209.us-east-2.compute.internal systemd[1]: httpd-init.service: Failed with result 'exit-code'.
Jul 27 17:30:04 ip-172-31-21-209.us-east-2.compute.internal systemd[1]: Failed to start One-time temporary TLS key generation for httpd.service.
-- Subject: Unit httpd-init.service has failed
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
--
-- Unit httpd-init.service has failed.
--
-- The result is failed.
Jul 27 17:30:04 ip-172-31-21-209.us-east-2.compute.internal systemd[1]: Starting The Apache HTTP Server...
-- Subject: Unit httpd.service has begun start-up
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
--
-- Unit httpd.service has begun starting up.
Jul 27 17:30:04 ip-172-31-21-209.us-east-2.compute.internal systemd[1]: httpd.service: Main process exited, code=exited, status=1/FAILURE
Jul 27 17:30:04 ip-172-31-21-209.us-east-2.compute.internal systemd[1]: httpd.service: Failed with result 'exit-code'.
Jul 27 17:30:04 ip-172-31-21-209.us-east-2.compute.internal systemd[1]: Failed to start The Apache HTTP Server.
-- Subject: Unit httpd.service has failed
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
--
-- Unit httpd.service has failed.
--
-- The result is failed.
Jul 27 17:30:04 ip-172-31-21-209.us-east-2.compute.internal sudo[56802]: pam_unix(sudo:session): session closed for user root

不知何故,找不到证书密钥!!我重新检查配置行SSLCertificateKeyFile /etc/pki/tls/private/custom.key指定的密钥文件是否存在:ls -al /etc/pki/tls/private/custom.key 。存在,权限600。

我不知道我做错了什么。我是否必须为此服务器创建不同的私钥,和/或重新向 CA 请求证书?

【问题讨论】:

  • 我创建了新的私钥和CSR,同名,尝试重新启动httpd,但它仍然没有工作......

标签: linux amazon-web-services apache ssl


【解决方案1】:

我能够让它工作。

怎么做?

考虑到我必须投入大量工作,我一直将此保存为调试问题的最后手段,但我尝试了以下方法:

  • 启动一个新的测试 EC2 服务器,在其上安装 httpdmod_ssl,然后在生产服务器上重复我尝试的所有操作。

我这样做了,并且 Route53 将该服务器分配到 test 子域。

成功了。

但是为什么

我想到的直接假设是:我的 Comodo PositiveSSL 通配符证书不知何故与 www 子域不兼容。

但在我完成今晚的工作之前,我决定再看看。我回头查看我的 EC2 仪表板,发现开发服务器和测试服务器位于两个不同的可用区,具有两个不同的第一个 IP 地址八位字节

开发服务器在us-east-2b,而测试在us-east-2a

好的,现在如果我尝试创建一个新的生产服务器会怎样? (感谢狗,我在生产服务器上还没有任何业务逻辑!)

我旋转一个。冲洗。泡沫。重复。

我 Route53 将 www 子域添加到它,然后对它执行我在“旧”生产服务器上尝试过的所有操作。

有效!!

为什么?!

我回到那个 EC2 仪表板,我注意到它也与开发服务器位于不同的可用区,并且具有不同的第一个 IP 地址八分位数。

我知道为什么(启发我,AWS 大神!!)但似乎如果两台服务器要拥有相同的第三方证书,它们必须位于不同的可用区。

【讨论】:

    【解决方案2】:

    请检查文件夹/etc/pki/tls/private/的权限 该文件夹至少应设置读取和执行权限。

    网络服务器是否在特定用户下运行,例如www-data

    【讨论】:

    • sudo chown root:root /etc/pki/tls/private/ 后跟 sudo service httpd restart 不起作用。
    • 这听起来与您遇到的问题相同:bugzilla.redhat.com/show_bug.cgi?id=1494556 请检查是否还存在 Apache 配置中定义的所有其他证书。
    【解决方案3】:

    你必须在终端上写下代码

    第 1 步:

     rm -f /etc/pki/tls/private/localhost.key /etc/pki/tls/certs/localhost.crt
    

    第 2 步:

    sudo systemctl start httpd && sudo systemctl enable httpd
    

    第 3 步:

    systemctl status httpd.service
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-12-17
      • 2021-05-04
      • 2017-10-24
      • 2011-10-27
      • 2021-05-01
      • 2011-07-26
      • 2018-03-17
      相关资源
      最近更新 更多