mirror of https://github.com/istio/istio.io.git
zh-translation: move and update /docs/tasks/security/plugin-ca-cert/index.md (#7037)
This commit is contained in:
parent
7a00de7323
commit
18d126f86b
|
@ -71,7 +71,7 @@ Below is our list of existing features and their current phases. This informatio
|
|||
|-------------------|-------------------
|
||||
| [Deny Checker](/zh/docs/reference/config/policy-and-telemetry/adapters/denier/) | Stable
|
||||
| [List Checker](/zh/docs/reference/config/policy-and-telemetry/adapters/list/) | Stable
|
||||
| [Pluggable Key/Cert Support for Istio CA](/zh/docs/tasks/security/citadel-config/plugin-ca-cert/) | Stable
|
||||
| [Pluggable Key/Cert Support for Istio CA](/zh/docs/tasks/security/plugin-ca-cert/) | Stable
|
||||
| [Service-to-service mutual TLS](/zh/docs/concepts/security/#mutual-TLS-authentication) | Stable
|
||||
| [Kubernetes: Service Credential Distribution](/zh/docs/concepts/security/#PKI) | Stable
|
||||
| [VM: Service Credential Distribution](/zh/docs/concepts/security/#PKI) | Beta
|
||||
|
|
|
@ -61,7 +61,7 @@ istiod 将先前由 Pilot,Galley,Citadel 和 sidecar 注入器执行的功
|
|||
|
||||
在某些情况下,您可能仍然想要独立运行 Istio 组件或替换某些组件。
|
||||
|
||||
一些用户可能想在网格外部使用证书颁发机构(CA),我们有[如何执行此操作的文档](/zh/docs/tasks/security/citadel-config/plugin-ca-cert/)。如果您使用其他工具进行证书设置,则可以使用它代替内置 CA。
|
||||
一些用户可能想在网格外部使用证书颁发机构(CA),我们有[如何执行此操作的文档](/zh/docs/tasks/security/plugin-ca-cert/)。如果您使用其他工具进行证书设置,则可以使用它代替内置 CA。
|
||||
|
||||
## 进阶{#moving-forward}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ aliases:
|
|||
|
||||
当添加非 Kubernetes 的服务到 Istio 网格时,第一步是 Istio 本身的安装配置,并生成让 VMs 连接到网格的配置文件。为 VM 准备集群需要使用集群管理员权限在一台机器上执行如下命令:
|
||||
|
||||
1. 为您的生成的 CA 证书创建 Kubernetes secret,使用如下命令。查看 [Certificate Authority (CA) certificates](/zh/docs/tasks/security/citadel-config/plugin-ca-cert/#plugging-in-the-existing-certificate-and-key) 获取更多细节。
|
||||
1. 为您的生成的 CA 证书创建 Kubernetes secret,使用如下命令。查看 [Certificate Authority (CA) certificates](/zh/docs/tasks/security/plugin-ca-cert/#plugging-in-the-existing-certificate-and-key) 获取更多细节。
|
||||
|
||||
{{< warning >}}
|
||||
样本目录中的 root 证书和中间证书已经大范围分发并被识别。**不能** 在生产环境中使用这些证书,否则您的集群容易受到安全漏洞和破坏的威胁。
|
||||
|
|
|
@ -39,7 +39,7 @@ aliases:
|
|||
|
||||
当将非 Kubernetes 服务添加到 Istio 网格中时,首先配置 Istio 它自己的设施,并生成配置文件使 VM 连接网格。在具有集群管理员特权的计算机上,使用以下命令为 VM 准备集群:
|
||||
|
||||
1. 使用类似于以下的命令,为生成的 CA 证书创建 Kubernetes secret。请参阅[证书办法机构 (CA) 证书](/zh/docs/tasks/security/citadel-config/plugin-ca-cert/#plugging-in-the-existing-certificate-and-key)获取更多的详细信息。
|
||||
1. 使用类似于以下的命令,为生成的 CA 证书创建 Kubernetes secret。请参阅[证书办法机构 (CA) 证书](/zh/docs/tasks/security/plugin-ca-cert/#plugging-in-the-existing-certificate-and-key)获取更多的详细信息。
|
||||
|
||||
{{< warning >}}
|
||||
样本目录中的 root 证书和中间证书已经大范围分发并被识别。
|
||||
|
|
|
@ -56,7 +56,7 @@ Istio [多集群部署](/zh/docs/ops/deployment/deployment-models/#control-plane
|
|||
|
||||
{{< /tip >}}
|
||||
|
||||
* 使用类似于下面的命令,为生成的 CA 证书创建 Kubernetes secret。了解详情,请参见 [CA 证书](/zh/docs/tasks/security/citadel-config/plugin-ca-cert/#plugging-in-the-existing-certificate-and-key)。
|
||||
* 使用类似于下面的命令,为生成的 CA 证书创建 Kubernetes secret。了解详情,请参见 [CA 证书](/zh/docs/tasks/security/plugin-ca-cert/#plugging-in-the-existing-certificate-and-key)。
|
||||
|
||||
{{< warning >}}
|
||||
示例目录中的根证书和中间证书已被广泛分发和知道。
|
||||
|
|
|
@ -329,7 +329,7 @@ Istio 支持在控制平面组件之间以及注入到应用的 pods 的 sidecar
|
|||
|
||||
* 禁用 `citadel` 证书自签名。
|
||||
|
||||
* Istio 控制平面命名空间中具有[证书颁发机构(CA)证书](/zh/docs/tasks/security/citadel-config/plugin-ca-cert/#plugging-in-the-existing-certificate-and-key)的名为 `cacerts` 的 secret。
|
||||
* Istio 控制平面命名空间中具有[证书颁发机构(CA)证书](/zh/docs/tasks/security/plugin-ca-cert/#plugging-in-the-existing-certificate-and-key)的名为 `cacerts` 的 secret。
|
||||
|
||||
1. 部署 Istio 远程集群需要:
|
||||
|
||||
|
@ -337,7 +337,7 @@ Istio 支持在控制平面组件之间以及注入到应用的 pods 的 sidecar
|
|||
|
||||
* 禁用 `citadel` 证书自签名。
|
||||
|
||||
* Istio 控制平面命名空间中具有 [CA 证书](/zh/docs/tasks/security/citadel-config/plugin-ca-cert/#plugging-in-the-existing-certificate-and-key)的名为 `cacerts` 的 secret。
|
||||
* Istio 控制平面命名空间中具有 [CA 证书](/zh/docs/tasks/security/plugin-ca-cert/#plugging-in-the-existing-certificate-and-key)的名为 `cacerts` 的 secret。
|
||||
主集群的证书颁发机构(CA)或根 CA 必须也为远程集群签名 CA 证书。
|
||||
|
||||
* Istio pilot 服务主机名可被 DNS 解析。
|
||||
|
@ -355,7 +355,7 @@ Istio 支持在控制平面组件之间以及注入到应用的 pods 的 sidecar
|
|||
|
||||
* 禁用 Citadel 证书自签名。
|
||||
|
||||
* Istio 控制平面命名空间中具有 [CA 证书](/zh/docs/tasks/security/citadel-config/plugin-ca-cert/#plugging-in-the-existing-certificate-and-key)的名为 `cacerts` 的 secret。
|
||||
* Istio 控制平面命名空间中具有 [CA 证书](/zh/docs/tasks/security/plugin-ca-cert/#plugging-in-the-existing-certificate-and-key)的名为 `cacerts` 的 secret。
|
||||
|
||||
1. 部署 Istio 远程集群需要:
|
||||
|
||||
|
@ -363,7 +363,7 @@ Istio 支持在控制平面组件之间以及注入到应用的 pods 的 sidecar
|
|||
|
||||
* 禁用 Citadel 证书自签名。
|
||||
|
||||
* Istio 控制平面命名空间中具有 [CA 证书](/zh/docs/tasks/security/citadel-config/plugin-ca-cert/#plugging-in-the-existing-certificate-and-key)的名为 `cacerts` 的 secret。
|
||||
* Istio 控制平面命名空间中具有 [CA 证书](/zh/docs/tasks/security/plugin-ca-cert/#plugging-in-the-existing-certificate-and-key)的名为 `cacerts` 的 secret。
|
||||
主集群的 CA 或根 CA 必须也为远程集群签名 CA 证书。
|
||||
|
||||
{{< tip >}}
|
||||
|
|
|
@ -1,120 +0,0 @@
|
|||
---
|
||||
title: 插入外部 CA 密钥和证书
|
||||
description: 运维人员如何使用现有根证书配置 Citadel 进行证书以及密钥的签发。
|
||||
weight: 10
|
||||
keywords: [security,certificates]
|
||||
aliases:
|
||||
- /zh/docs/tasks/security/plugin-ca-cert/
|
||||
---
|
||||
|
||||
本任务展示运维人员如何使用现有根证书配置 Citadel 进行证书以及密钥的签发。
|
||||
|
||||
缺省情况下 Citadel 生成自签署的根证书和密钥,用于给工作负载签署证书。Citadel 还可以使用运维人员指定的根证书、证书和密钥进行工作负载的证书颁发。该任务所演示了向 Citadel 插入外部证书和密钥的方法。
|
||||
|
||||
## 开始之前{#before-you-begin}
|
||||
|
||||
* 按照[快速启动](/zh/docs/setup/install/istioctl/)中的说明安装 Istio:
|
||||
|
||||
## 插入现有密钥和证书{#plugging-in-the-existing-certificate-and-key}
|
||||
|
||||
假设我们想让 Citadel 使用现有的 `ca-cert.pem` 证书和 `ca-key.pem`,其中 `ca-cert.pem` 是由 `root-cert.pem` 根证书签发的,我们也准备使用 `root-cert.pem` 作为 Istio 工作负载的根证书。
|
||||
|
||||
下面的例子中,Citadel 的签署(CA)证书(`root-cert.pem`)不同于根证书(`root-cert.pem`),因此工作负载无法使用根证书进行证书校验。工作负载需要一个 `cert-chain.pem` 文件作为信任链,其中需要包含所有从根证书到工作负载证书之间的中间 CA。在我们的例子中,他包含了 Citadel 的签署证书,所以 `cert-chain.pem` 和 `ca-cert.pem` 是一致的。注意如果你的 `ca-cert.pem` 和 `ca-cert.pem` 是一致的,那么 `cert-chain.pem` 就是个空文件了。
|
||||
|
||||
这些文件都会在 `samples/certs/` 目录中准备就绪提供使用。
|
||||
|
||||
{{< tip >}}
|
||||
The default Citadel installation sets [command line options](/zh/docs/reference/commands/istio_ca/index.html) to configure the location of certificates and keys based on the predefined secret and file names used in the command below (i.e., secret named `cacert`, root certificate in a file named `root-cert.pem`, Citadel key in `ca-key.pem`, etc.)
|
||||
You must use these specific secret and file names, or reconfigure Citadel when you deploy it.
|
||||
{{< /tip >}}
|
||||
|
||||
下面的步骤在 Citadel 中插入了证书和密钥:
|
||||
|
||||
1. 创建一个名为 `cacert` 的 secret,其中包含所有输入文件 `ca-cert.pem`、`ca-key.pem`、`root-cert.pem` 以及 `cert-chain.pem`:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl create secret generic cacerts -n istio-system --from-file=samples/certs/ca-cert.pem \
|
||||
--from-file=samples/certs/ca-key.pem --from-file=samples/certs/root-cert.pem \
|
||||
--from-file=samples/certs/cert-chain.pem
|
||||
{{< /text >}}
|
||||
|
||||
1. `global.mtls.enabled` 设置为 `true`,`security.selfSigned` 设置为 `false`,重新部署 Citadel。
|
||||
|
||||
{{< text bash >}}
|
||||
$ istioctl manifest apply --set values.global.mtls.enabled=true --set values.security.selfSigned=false
|
||||
{{< /text >}}
|
||||
|
||||
1. 为了确定工作负载获取了正确的证书,删除 Citadel 生成的 Secret(命名为 `istio.\*`)。在本例中就是 `istio.default`。Citadel 会签发新的证书给工作负载。
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl delete secret istio.default
|
||||
{{< /text >}}
|
||||
|
||||
## 检查新证书{#verifying-the-new-certificates}
|
||||
|
||||
本节中,我们要校验新的工作负载证书以及根证书是否正确传播。需要在本机安装 `openssl`。
|
||||
|
||||
1. 根据[部署文档](/zh/docs/examples/bookinfo/)安装 Bookinfo 应用。
|
||||
|
||||
1. 获取已加载的证书。
|
||||
下面我们使用 ratings pod 作为例子,检查这个 Pod 上加载的证书。
|
||||
|
||||
用变量 `RATINGSPOD` 保存 Pod 名称:
|
||||
|
||||
{{< text bash >}}
|
||||
$ RATINGSPOD=`kubectl get pods -l app=ratings -o jsonpath='{.items[0].metadata.name}'`
|
||||
{{< /text >}}
|
||||
|
||||
运行下列命令,获取 `proxy` 容器中加载的证书:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl exec -it $RATINGSPOD -c istio-proxy -- /bin/cat /etc/certs/root-cert.pem > /tmp/pod-root-cert.pem
|
||||
{{< /text >}}
|
||||
|
||||
`/tmp/pod-root-cert.pem` 文件中包含传播到 Pod 中的根证书。
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl exec -it $RATINGSPOD -c istio-proxy -- /bin/cat /etc/certs/cert-chain.pem > /tmp/pod-cert-chain.pem
|
||||
{{< /text >}}
|
||||
|
||||
而 `/tmp/pod-cert-chain.pem` 这个文件则包含了工作负载证书以及传播到 Pod 中的 CA 证书
|
||||
|
||||
1. 检查根证书和运维人员指定的证书是否一致:
|
||||
|
||||
{{< text bash >}}
|
||||
$ openssl x509 -in @samples/certs/root-cert.pem@ -text -noout > /tmp/root-cert.crt.txt
|
||||
$ openssl x509 -in /tmp/pod-root-cert.pem -text -noout > /tmp/pod-root-cert.crt.txt
|
||||
$ diff /tmp/root-cert.crt.txt /tmp/pod-root-cert.crt.txt
|
||||
{{< /text >}}
|
||||
|
||||
输出为空代表符合预期。
|
||||
|
||||
1. 检查 CA 证书和运维人员指定的是否一致
|
||||
|
||||
{{< text bash >}}
|
||||
$ sed '0,/^-----END CERTIFICATE-----/d' /tmp/pod-cert-chain.pem > /tmp/pod-cert-chain-ca.pem
|
||||
$ openssl x509 -in @samples/certs/ca-cert.pem@ -text -noout > /tmp/ca-cert.crt.txt
|
||||
$ openssl x509 -in /tmp/pod-cert-chain-ca.pem -text -noout > /tmp/pod-cert-chain-ca.crt.txt
|
||||
$ diff /tmp/ca-cert.crt.txt /tmp/pod-cert-chain-ca.crt.txt
|
||||
{{< /text >}}
|
||||
|
||||
输出为空代表符合预期。
|
||||
|
||||
1. 检查从根证书到工作负载证书的证书链:
|
||||
|
||||
{{< text bash >}}
|
||||
$ head -n 21 /tmp/pod-cert-chain.pem > /tmp/pod-cert-chain-workload.pem
|
||||
$ openssl verify -CAfile <(cat @samples/certs/ca-cert.pem@ @samples/certs/root-cert.pem@) /tmp/pod-cert-chain-workload.pem
|
||||
/tmp/pod-cert-chain-workload.pem: OK
|
||||
{{< /text >}}
|
||||
|
||||
## 清理{#cleanup}
|
||||
|
||||
* 移除 secret `cacerts`:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl delete secret cacerts -n istio-system
|
||||
$ istioctl manifest apply --set values.global.mtls.enabled=true
|
||||
{{< /text >}}
|
||||
|
||||
* 移除 Istio 组件:按照[卸载说明](/zh/docs/setup/getting-started/#uninstall)进行删除。
|
|
@ -0,0 +1,102 @@
|
|||
---
|
||||
title: 插入外部 CA 证书
|
||||
description: 演示系统管理员如何使用现有的根证书、签名证书和密钥配置 Istio 的 CA。
|
||||
weight: 80
|
||||
keywords: [security,certificates]
|
||||
aliases:
|
||||
- /zh/docs/tasks/security/plugin-ca-cert/
|
||||
---
|
||||
|
||||
本任务演示系统管理员如何使用现有的根证书、签名证书和密钥配置 Istio 的 CA。
|
||||
|
||||
缺省情况下 Istio 的 CA 会生成自签署的根证书和密钥,用于给工作负载签署证书。Istio 的 CA 还可以使用运维人员指定的根证书、证书和密钥进行工作负载的证书颁发。该任务演示了向 Istio CA 插入外部证书和密钥的方法。
|
||||
|
||||
## 插入现有密钥和证书{#plugging-in-the-existing-certificate-and-key}
|
||||
|
||||
假设我们想让 Istio 的 CA 使用现有的 `ca-cert.pem` 证书和 `ca-key.pem`,其中 `ca-cert.pem` 是由 `root-cert.pem` 根证书签发的,我们也准备使用 `root-cert.pem` 作为 Istio 工作负载的根证书。
|
||||
|
||||
下面的例子中,Istio CA 的签署(CA)证书(`root-cert.pem`)不同于根证书(`root-cert.pem`),因此工作负载无法使用根证书进行证书校验。工作负载需要一个 `cert-chain.pem` 文件作为信任链,其中需要包含所有从根证书到工作负载证书之间的中间 CA。在我们的例子中,它包含了 Istio CA 的签署证书,所以 `cert-chain.pem` 和 `ca-cert.pem` 是一致的。注意,如果你的 `ca-cert.pem` 和 `ca-cert.pem` 是一致的,那么 `cert-chain.pem` 就是个空文件了。
|
||||
|
||||
这些文件都会在 `samples/certs/` 目录中准备就绪提供使用。
|
||||
|
||||
{{< tip >}}
|
||||
缺省的 Istio CA 安装根据下面[命令](/zh/docs/reference/commands/istio_ca/index.html)中使用的预定义密钥和文件名来配置证书和密钥的位置(例如,secret 秘钥名为 `cacert`,根证书在一个名为 `root-cert.pem` 的文件中,Istio CA 的 key 在 `ca-key.pem` 中,等等)。
|
||||
你必须使用这些特定的 secret 秘钥名和文件名,或者在部署 Istio 时重新配置 Istio 的 CA。
|
||||
{{< /tip >}}
|
||||
|
||||
下面的步骤将外部证书和密钥存入 Kubernetes secret 对象,这些 secret 会被 Istio 的 CA 读取:
|
||||
|
||||
1. 创建一个名为 `cacert` 的 secret,其中包含所有输入文件 `ca-cert.pem`、`ca-key.pem`、`root-cert.pem` 以及 `cert-chain.pem`:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl create namespace istio-system
|
||||
$ kubectl create secret generic cacerts -n istio-system --from-file=samples/certs/ca-cert.pem \
|
||||
--from-file=samples/certs/ca-key.pem --from-file=samples/certs/root-cert.pem \
|
||||
--from-file=samples/certs/cert-chain.pem
|
||||
{{< /text >}}
|
||||
|
||||
1. 使用 `demo` 的部署配置,将 `global.mtls.enabled` 设置为 `true`,部署 Istio。
|
||||
|
||||
Istio 的 CA 会从挂载的 secret 文件中读取证书和秘钥信息。
|
||||
|
||||
{{< text bash >}}
|
||||
$ istioctl manifest apply --set profile=demo --set values.global.mtls.enabled=true
|
||||
{{< /text >}}
|
||||
|
||||
## 检查新证书{#verifying-the-new-certificates}
|
||||
|
||||
在本节中,我们将验证工作负载证书是否由插入 CA 的证书签名。这需要在本机安装 `openssl`。
|
||||
|
||||
1. 部署 `httpbin` 和 `sleep` 简单服务。
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl create ns foo
|
||||
$ kubectl apply -f <(istioctl kube-inject -f samples/httpbin/httpbin.yaml) -n foo
|
||||
$ kubectl apply -f <(istioctl kube-inject -f samples/sleep/sleep.yaml) -n foo
|
||||
{{< /text >}}
|
||||
|
||||
1. 获取 `httpbin` 的证书链。
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl exec $(kubectl get pod -l app=sleep -n foo -o jsonpath={.items..metadata.name}) -c istio-proxy -n foo -- openssl s_client -showcerts -connect httpbin.foo:8000 > httpbin-proxy-cert.txt
|
||||
{{< /text >}}
|
||||
|
||||
打开上面命令生成的 `httpbin-proxy-cert.txt` 文件,将其中的三个证书分别保存到 `proxy-cert-0.pem`、`proxy-cert-1.pem` 和 `proxy-cert-2.pem`。每个证书以 `-----BEGIN CERTIFICATE-----` 开始,以 `-----END CERTIFICATE-----` 结束。
|
||||
|
||||
1. 检查根证书和运维人员指定的证书是否一致:
|
||||
|
||||
{{< text bash >}}
|
||||
$ openssl x509 -in @samples/certs/root-cert.pem@ -text -noout > /tmp/root-cert.crt.txt
|
||||
$ openssl x509 -in ./proxy-cert-2.pem -text -noout > /tmp/pod-root-cert.crt.txt
|
||||
$ diff /tmp/root-cert.crt.txt /tmp/pod-root-cert.crt.txt
|
||||
{{< /text >}}
|
||||
|
||||
输出为空代表符合预期。
|
||||
|
||||
1. 检查 CA 证书和运维人员指定的是否一致
|
||||
|
||||
{{< text bash >}}
|
||||
$ openssl x509 -in @samples/certs/ca-cert.pem@ -text -noout > /tmp/ca-cert.crt.txt
|
||||
$ openssl x509 -in ./proxy-cert-1.pem -text -noout > /tmp/pod-cert-chain-ca.crt.txt
|
||||
$ diff /tmp/ca-cert.crt.txt /tmp/pod-cert-chain-ca.crt.txt
|
||||
{{< /text >}}
|
||||
|
||||
输出为空代表符合预期。
|
||||
|
||||
1. 检查从根证书到工作负载证书的证书链:
|
||||
|
||||
{{< text bash >}}
|
||||
$ openssl verify -CAfile <(cat @samples/certs/ca-cert.pem@ @samples/certs/root-cert.pem@) ./proxy-cert-0.pem
|
||||
./proxy-cert-0.pem: OK
|
||||
{{< /text >}}
|
||||
|
||||
## 清理{#cleanup}
|
||||
|
||||
* 移除 secret `cacerts` 并使用 Istio CA 自签署证书重新部署 Istio:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl delete secret cacerts -n istio-system
|
||||
$ istioctl manifest apply
|
||||
{{< /text >}}
|
||||
|
||||
* 移除 Istio 组件:按照[卸载说明](/zh/docs/setup/getting-started/#uninstall)进行删除。
|
|
@ -36,7 +36,7 @@ aliases:
|
|||
|
||||
## 安全{#security}
|
||||
|
||||
- **使用你自己的 CA**。多项针对 ‘使用你自己的 CA’特性的改进。[了解更多](/zh/docs/tasks/security/citadel-config/plugin-ca-cert/)
|
||||
- **使用你自己的 CA**。多项针对 ‘使用你自己的 CA’特性的改进。[了解更多](/zh/docs/tasks/security/plugin-ca-cert/)
|
||||
|
||||
- **PKCS8**。将 PKCS8 密钥的支持添加到 Istio PKI。
|
||||
|
||||
|
|
Loading…
Reference in New Issue