linux - 我们如何在多个 EC2 服务器上使用相同的证书设置 SSL/TLS

标签 linux amazon-web-services apache ssl

经过一番挫折,我能够设置 SSL/TLS,via these instructions .我确实遇到了一些关于“缺少证书 key ”的错误,但我能够通过重新创建 CSR 文件来解决这个问题,将通用名称修复为:*.opensourceroads.com .
我请求并安装了 Comodo 通配符证书。
一切都在开发子域上工作。
现在,对于生产服务器......
首先,我将私钥和证书文件复制到主目录,并将这些 HOME 版本的权限设置为 755。这允许我从开发服务器下载它们并将它们上传到生产服务器,我这样做了。
顺便说一句,生产服务器主机内容为 www.opensourceroads.com
这样做之后,我按照说明安装了 mod_ssl,将私有(private)和证书文件移到了正确的位置,并按照教程更改了它们的权限和所有权。

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
不知何故,找不到证书 key !!我重新检查了配置行SSLCertificateKeyFile /etc/pki/tls/private/custom.key指定的 key 文件存在:ls -al /etc/pki/tls/private/custom.key .它存在,权限为 600。
我不知道我做错了什么。我是否必须为此服务器创建不同的私钥,和/或从 CA 重新请求证书?

最佳答案

我能够让它工作。
如何?
考虑到我必须投入多少工作,我一直将其保存为调试问题的最后手段,但我尝试了以下方法:

  • 启动一个新的测试EC2服务器,安装httpdmod_ssl在它上面,并重复我在生产服务器上尝试的所有内容。

  • 我这样做了,Route53 将该服务器发送到 test子域。
    有效。
    但为什么?
    我脑海中浮现的直接假设:我的 Comodo PositiveSSL 通配符证书不知何故与 www 不兼容。子域。
    但在我完成今晚的工作之前,我决定再看看。我回头查看我的 EC2 仪表板,发现开发服务器和测试服务器位于两个不同的可用区,具有两个不同的第一个 IP 地址八位字节!
    开发服务器在us-east-2b ,而测试在 us-east-2a .
    好的,现在如果我尝试创建一个新的生产服务器呢? (感谢狗,我在生产服务器上还没有任何业务逻辑!)
    我旋转一个。冲洗。泡沫。重复。
    我Route53www子域,并对其执行我在“旧”生产服务器上尝试的所有操作。
    有用!!
    为什么?!
    我回到那个 EC2 仪表板,我注意到它也与开发服务器位于不同的可用区,并且具有不同的第一个 IP 地址八分圆。
    不知道为什么(启发我,AWS 大神!!)但似乎如果两台服务器要拥有相同的第三方证书,它们必须位于不同的可用区。

    关于linux - 我们如何在多个 EC2 服务器上使用相同的证书设置 SSL/TLS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63120822/

    相关文章:

    amazon-web-services - AWS : Bitnami : UNYSON : Cannot create temporary directory

    apache - Geoserver 建议 - HTTP 状态 400 - 错误请求

    mysql - 无法使用 HeidiSQL : "Can' t connect to MySQL server on 'localhost' "连接到 Vagrant

    linux - 使用 "top"命令了解 Linux 中的 CPU 使用情况以了解 VLC 使用情况

    linux - 从ssh注销后,如何使程序继续运行?

    linux - 将 super 键映射到 xorg.conf 中的控件?

    amazon-web-services - 如何使用 boto3 列出所有 AWS 子网的名称

    amazon-web-services - 提交后如何在 Redshift 过程中获取结果集?

    node.js - 有没有办法在 Node 服务器的 httpd conf 中设置 ProxyPass

    Apache 2.4.7 403 禁止错误