将定制 TLS 证书用于与平台的 HTTPS 连接

Cloud Pak for Data 安装包含可用于启用 HTTPS 连接的自签名 TLS 证书。 缺省情况下,所有 HTTPS 客户机不信任此证书。 但是,您可以使用自己的 TLS 证书替换缺省证书。

IBM® Cloud Pak for Data 将一个 HTTPS 端口作为Web客户端和API请求的主要访问点。 ,端口暴露在外。 Red Hat® OpenShift® ,港口作为一条 OpenShift 路线。

准备工作

必需的许可权
要完成此任务,您必须具有下列其中一个角色:
  • Red Hat OpenShift 集群管理员
  • 安装了 Cloud Pak for Data 的项目上的 Red Hat OpenShift 项目管理员

要完成此任务,您必须自带满足以下需求的证书和专用密钥文件:

  • 上述两个文件均使用 PEM 格式。
  • 该证书名为 cert.crt

    该证书可以是包含服务器、中间件和(以正确顺序)合并到一个文件的根证书的捆绑软件。 必须启用必要的证书作为连接到集群的客户机上的可信证书。

  • 专用密钥名为 cert.key

过程

要将缺省 TLS 证书替换为定制 TLS 证书:

  1. cert.crtcert.key 文件放在本地文件系统上的同一目录中。
  2. 切换到这些文件所在目录。
  3. 连接到 OpenShift 集群:
    oc login OpenShift_URL:port
  4. 设置部署了 Cloud Pak for Data 的项目的上下文:
    oc project Project_name
  5. 创建私钥以用于存储证书文件:
    oc create secret generic external-tls-secret --from-file=cert.crt=./cert.crt --from-file=cert.key=./cert.key --dry-run -o yaml | oc apply -f -
    要点: 请勿更改私钥的名称。 必须使用名称 external-tls-secret

    等待命令返回消息称该私钥已创建:

    secret/external-tls-secret created

    然后,再等待一分钟,以确保 kubelet 有足够时间来检测到将在何处使用该私钥,并将该私钥装载到 ibm-nginx Pod。

  6. 重新装入 ibm-nginx:
    for i in `oc get pods | grep ibm-nginx |  cut -f1 -d\ `; do oc exec ${i} -- /scripts/reload.sh; done
    输出应该类似于以下输出:
    reloading nginx conf
    Setting up ssl certificate files...
     Custom ssl certificate files were found. Processing them... 
    lrwxrwxrwx. 1 1000321000 root 50 DATE-AND-TIME /nginx_data/defaults.d/external-server.conf -> /nginx_data/defaults.d/external-server.active.conf
    nginx: the configuration file /usr/local/openresty/nginx/conf/nginx.conf syntax is ok
    nginx: configuration file /usr/local/openresty/nginx/conf/nginx.conf test is successful
    TIMESTAMP [notice] 76#76: signal process started
    reloading nginx conf
    Setting up ssl certificate files...
    Custom ssl certificate files were found. Processing them...
    lrwxrwxrwx. 1 1000321000 root 50 DATE-AND-TIME /nginx_data/defaults.d/external-server.conf -> /nginx_data/defaults.d/external-server.active.conf
    nginx: the configuration file /usr/local/openresty/nginx/conf/nginx.conf syntax is ok
    nginx: configuration file /usr/local/openresty/nginx/conf/nginx.conf test is successful
    TIMESTAMP [notice] 76#76: signal process started
    reloading nginx conf
    Setting up ssl certificate files...
    Custom ssl certificate files were found. Processing them...
    lrwxrwxrwx. 1 1000321000 root 50 DATE-AND-TIME /nginx_data/defaults.d/external-server.conf -> /nginx_data/defaults.d/external-server.active.conf
    nginx: the configuration file /usr/local/openresty/nginx/conf/nginx.conf syntax is ok
    nginx: configuration file /usr/local/openresty/nginx/conf/nginx.conf test is successful
    TIMESTAMP [notice] 76#76: signal process started

    验证是否已找到证书文件。