搜索

8.2. 更改 SSL 证书

download PDF

要更改 SSL 证书,您可以编辑清单文件并运行安装程序。安装程序验证所有 Ansible Automation Platform 组件是否正常工作。安装程序可能需要很长时间才能运行。

或者,您可以手动更改 SSL 证书。这速度更快,但没有自动验证。

8.2.1. 先决条件

  • 如果存在中间证书颁发机构,您必须将它附加到服务器证书中。
  • 自动化控制器和自动化中心都使用 NGINX,因此服务器证书必须采用 PEM 格式。
  • 为证书使用正确的顺序:服务器证书首先,后跟中间证书颁发机构。

如需更多信息,请参阅 NGINX 文档中的 ssl 证书部分

8.2.2. 使用安装程序更改 SSL 证书和密钥

以下流程描述了如何更改清单文件中的 SSL 证书和密钥。

流程

  1. 将新的 SSL 证书和密钥复制到相对于 Ansible Automation Platform 安装程序的路径。
  2. 将 SSL 证书和密钥的绝对路径添加到清单文件。有关设置这些变量的指导,请参阅 Red Hat Ansible Automation Platform 安装指南中的 Automation controller 变量和 Automation hub 变量部分。

    • 自动化控制器: web_server_ssl_cert,web_server_ssl_key,custom_ca_cert
    • 自动化中心:automationhub_ssl_cert,automationhub_ssl_key,custom_ca_cert
    注意

    custom_ca_cert 必须是签署中间证书颁发机构的根证书颁发机构。此文件安装在 /etc/pki/ca-trust/source/anchors 中。

  3. 运行安装程序。

8.2.3. 手动更改 SSL 证书

8.2.3.1. 在自动化控制器中手动更改 SSL 证书和密钥

以下流程描述了如何在 Automation Controller 上手动更改 SSL 证书和密钥。

流程

  1. 备份当前的 SSL 证书:

    cp /etc/tower/tower.cert /etc/tower/tower.cert-$(date +%F)
  2. 备份当前密钥文件:

    cp /etc/tower/tower.key /etc/tower/tower.key-$(date +%F)+
  3. 将新 SSL 证书复制到 /etc/tower/tower.cert
  4. 将新密钥复制到 /etc/tower/tower.key
  5. 恢复 SELinux 上下文:

    restorecon -v /etc/tower/tower.cert /etc/tower/tower.key
  6. 为证书和密钥文件设置适当的权限:

    chown root:awx /etc/tower/tower.cert /etc/tower/tower.key
    chmod 0600 /etc/tower/tower.cert /etc/tower/tower.key
  7. 测试 NGINX 配置:

    nginx -t
  8. 重新载入 NGINX:

    systemctl reload nginx.service
  9. 验证是否安装了新的 SSL 证书和密钥:

    true | openssl s_client -showcerts -connect ${CONTROLLER_FQDN}:443

8.2.3.2. 在 OpenShift Container Platform 上更改自动化控制器的 SSL 证书和密钥

以下流程描述了如何为 OpenShift Container Platform 上运行的自动化控制器更改 SSL 证书和密钥。

流程

  1. 将签名的 SSL 证书和密钥复制到安全位置。
  2. 在 OpenShift 中创建 TLS secret:

    oc create secret tls ${CONTROLLER_INSTANCE}-certs-$(date +%F) --cert=/path/to/ssl.crt --key=/path/to/ssl.key
  3. 修改自动化控制器自定义资源,将 route_tls_secret 和新 secret 的名称添加到 spec 部分。

    oc edit automationcontroller/${CONTROLLER_INSTANCE}
    ...
    spec:
      route_tls_secret: automation-controller-certs-2023-04-06
    ...

TLS secret 的名称是任意的。在本例中,它的时间戳为创建 secret 的日期,以便将其与应用到自动化控制器实例的其他 TLS secret 进行区分。

  1. 等待几分钟,以便应用更改。
  2. 验证是否安装了新的 SSL 证书和密钥:

    true | openssl s_client -showcerts -connect ${CONTROLLER_FQDN}:443

8.2.3.3. 在自动化中心中手动更改 SSL 证书和密钥

以下流程描述了如何在自动化中心中手动更改 SSL 证书和密钥。

流程

  1. 备份当前的 SSL 证书:

    cp /etc/pulp/certs/pulp_webserver.crt /etc/pulp/certs/pulp_webserver.crt-$(date +%F)
  2. 备份当前密钥文件:

    cp /etc/pulp/certs/pulp_webserver.key /etc/pulp/certs/pulp_webserver.key-$(date +%F)
  3. 将新 SSL 证书复制到 /etc/pulp/certs/pulp_webserver.crt
  4. 将新密钥复制到 /etc/pulp/certs/pulp_webserver.key
  5. 恢复 SELinux 上下文:

    restorecon -v /etc/pulp/certs/pulp_webserver.crt /etc/pulp/certs/pulp_webserver.key
  6. 为证书和密钥文件设置适当的权限:

    chown root:pulp /etc/pulp/certs/pulp_webserver.crt /etc/pulp/certs/pulp_webserver.key
    chmod 0600 /etc/pulp/certs/pulp_webserver.crt /etc/pulp/certs/pulp_webserver.key
  7. 测试 NGINX 配置:

    nginx -t
  8. 重新载入 NGINX:

    systemctl reload nginx.service
  9. 验证是否安装了新的 SSL 证书和密钥:

    true | openssl s_client -showcerts -connect ${CONTROLLER_FQDN}:443
Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.