Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

encryption: add tikv kms encryption for gcp and azure #16737

Merged
merged 14 commits into from
Mar 20, 2024

Conversation

glorv
Copy link
Contributor

@glorv glorv commented Mar 1, 2024

First-time contributors' checklist

What is changed, added or deleted? (Required)

Which TiDB version(s) do your changes apply to? (Required)

Tips for choosing the affected version(s):

By default, CHOOSE MASTER ONLY so your changes will be applied to the next TiDB major or minor releases. If your PR involves a product feature behavior change or a compatibility change, CHOOSE THE AFFECTED RELEASE BRANCH(ES) AND MASTER.

For details, see tips for choosing the affected versions (in Chinese).

  • master (the latest development version)
  • v8.0 (TiDB 8.0 versions)
  • v7.6 (TiDB 7.6 versions)
  • v7.5 (TiDB 7.5 versions)
  • v7.4 (TiDB 7.4 versions)
  • v7.1 (TiDB 7.1 versions)
  • v6.5 (TiDB 6.5 versions)
  • v6.1 (TiDB 6.1 versions)
  • v5.4 (TiDB 5.4 versions)
  • v5.3 (TiDB 5.3 versions)
  • v5.2 (TiDB 5.2 versions)
  • v5.1 (TiDB 5.1 versions)
  • v5.0 (TiDB 5.0 versions)

What is the related PR or file link(s)?

  • This PR is translated from:
  • Other reference link(s):

Do your changes match any of the following descriptions?

  • Delete files
  • Change aliases
  • Need modification after applied to another branch
  • Might cause conflicts after applied to another branch

@glorv glorv requested a review from qiancai March 1, 2024 10:21
@ti-chi-bot ti-chi-bot bot added missing-translation-status This PR does not have translation status info. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 1, 2024
@glorv
Copy link
Contributor Author

glorv commented Mar 1, 2024

@LykxSassinator Please help review the azure part thanks.

@qiancai qiancai self-assigned this Mar 4, 2024
@qiancai qiancai added the translation/doing This PR’s assignee is translating this PR. label Mar 4, 2024
@ti-chi-bot ti-chi-bot bot removed the missing-translation-status This PR does not have translation status info. label Mar 4, 2024
@qiancai qiancai added v8.0 This PR/issue applies to TiDB v8.0. area/security Relates to TiDB security and privilege. labels Mar 4, 2024
github-actions bot pushed a commit to qiancai/pingcap-docsite-preview that referenced this pull request Mar 4, 2024
@@ -65,9 +65,31 @@ TiKV 当前支持的加密算法包括 AES128-CTR、AES192-CTR、AES256-CTR 和

无论用户配置了哪种数据加密方法,数据密钥都使用 AES256-GCM 算法进行加密,以方便对主密钥进行验证。所以当使用文件而不是 KMS 方式指定主密钥时,主密钥必须为 256 位(32 字节)。

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


创建密钥

在 Azure 平台创建密钥,请参考文档 [使用 Azure 门户在 Azure Key Vault 中设置和检索密钥](https://learn.microsoft.com/zh-cn/azure/key-vault/keys/quick-create-portal)。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

credential-file-path = "/path/to/credential.json"
```

`key-id` 指定 KMS CMK 的密钥 ID, `credential-file-path` 指向验证凭据配置文件的路径,目前支持 Serivce Account 和 Authentition User 两种凭据。如果 TiKV 的运行环境已配置 [应用默认凭据](https://cloud.google.com/docs/authentication/application-default-credentials?hl=zh-cn),则无须此配置项。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`key-id` 指定 KMS CMK 的密钥 ID, `credential-file-path` 指向验证凭据配置文件的路径,目前支持 Serivce Account 和 Authentition User 两种凭据。如果 TiKV 的运行环境已配置 [应用默认凭据](https://cloud.google.com/docs/authentication/application-default-credentials?hl=zh-cn),则无须此配置项。
`key-id` 指定 KMS CMK 的密钥 ID, `credential-file-path` 指向验证凭据配置文件的路径,目前支持 Service Account 和 Authentication User 两种凭据。如果 TiKV 的运行环境已配置 [应用默认凭据](https://cloud.google.com/docs/authentication/application-default-credentials?hl=zh-cn),则无须此配置项。

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

```
[security.encryption.master-key]
type = "kms"
key-id = key-id = "projects/project-name/locations/global/keyRings/key-ring-name/cryptoKeys/key-name"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
key-id = key-id = "projects/project-name/locations/global/keyRings/key-ring-name/cryptoKeys/key-name"
key-id = "projects/project-name/locations/global/keyRings/key-ring-name/cryptoKeys/key-name"

@ljun0712 ljun0712 closed this Mar 4, 2024
@ljun0712
Copy link
Contributor

ljun0712 commented Mar 4, 2024

Please add a description of the new configuration parameters in the configuration file.

@ljun0712 ljun0712 reopened this Mar 4, 2024
github-actions bot pushed a commit to qiancai/pingcap-docsite-preview that referenced this pull request Mar 5, 2024

如果启用了加密(即 `data-encryption-method` 的值不是 `"plaintext"`),则必须指定主密钥。TiKV 支持 KMS 和文件两种方式指定密钥。

#### 配置 KMS 密钥
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#### 配置 KMS 密钥
#### 通过 KMS 指定主密钥


</SimpleTab>

#### 配置文件密钥
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#### 配置文件密钥
#### 通过文件指定主密钥


`data-encryption-method` 的可选值为 `"aes128-ctr"`、`"aes192-ctr"`、`"aes256-ctr"`、`"sm4-ctr"` (仅 v6.3.0 及之后版本) 和 `"plaintext"`。默认值为 `"plaintext"`,即默认不开启加密功能。`data-key-rotation-period` 指定 TiKV 轮换密钥的频率。可以为新 TiKV 集群或现有 TiKV 集群开启加密,但只有启用后写入的数据才保证被加密。要禁用加密,请在配置文件中删除 `data-encryption-method`,或将该参数值为 `"plaintext"`,然后重启 TiKV。若要替换加密算法,则将 `data-encryption-method` 替换成已支持的加密算法,然后重启 TiKV。替换加密算法后,旧加密算法生成的加密文件会随着新数据的写入逐渐被重写成新加密算法所生成的加密文件。

如果启用了加密(即 `data-encryption-method` 的值不是 `"plaintext"`),则必须指定主密钥。TiKV 支持 KMS 和文件两种方式指定密钥。
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
如果启用了加密(即 `data-encryption-method` 的值不是 `"plaintext"`),则必须指定主密钥。TiKV 支持 KMS 和文件两种方式指定密钥
如果启用了加密(即 `data-encryption-method` 的值不是 `"plaintext"`),则必须指定主密钥。你可以通过以下方式之一来指定主密钥
- [通过 KMS 指定主密钥](#通过-KMS-指定主密钥)
- [通过文件指定主密钥](#通过文件指定主密钥)


#### 配置 KMS 密钥

TiKV 支持 AWS、GCP 和 Azure 3 个平台的 KMS 加密,根据服务部署的平台,使用不同的方式配置 KMS 加密。
Copy link
Collaborator

@qiancai qiancai Mar 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
TiKV 支持 AWS、GCP 和 Azure 3 个平台的 KMS 加密,根据服务部署的平台,使用不同的方式配置 KMS 加密。
TiKV 支持 AWS、Google Cloud 和 Azure 这三个平台的 KMS 加密。你可以根据服务部署的平台,你可以选择其中之一配置 KMS 加密。


<div label="AWS KMS">

创建密钥
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
创建密钥
**第 1 步:创建主密钥**

gcloud kms keys create "key-name" --keyring "key-ring-name" --location "global" --purpose "encryption" --rotation-period "30d"
```

请将上述命令中的 "key-ring-name"、"key-name"、"global"、"30d" 等字段替换为实际密钥对应的名称和配置。
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
请将上述命令中的 "key-ring-name"、"key-name"、"global"、"30d" 等字段替换为实际密钥对应的名称和配置
请将上述命令中的 "key-ring-name"、"key-name"、"global"、"30d" 等字段的值替换为实际密钥对应的名称和配置


创建密钥

在 GCP 平台上创建一个密钥,请执行以下步骤:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
在 GCP 平台上创建一个密钥,请执行以下步骤
要在 Google Cloud 上创建一个密钥,请进行以下操作


在 GCP 平台上创建一个密钥,请执行以下步骤:

1. 进入 GCP 控制台的 [密钥管理](https://console.cloud.google.com/security/kms/keyrings)。
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
1. 进入 GCP 控制台的 [密钥管理](https://console.cloud.google.com/security/kms/keyrings)
1. 进入 Google Cloud 控制台的[**密钥管理**](https://console.cloud.google.com/security/kms/keyrings)页面

在 GCP 平台上创建一个密钥,请执行以下步骤:

1. 进入 GCP 控制台的 [密钥管理](https://console.cloud.google.com/security/kms/keyrings)。
2. 点击**创建密钥环**,创建密钥环,注意密钥环所在的位置需要覆盖 TiDB 集群部署的区域。
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
2. 点击**创建密钥环**,创建密钥环,注意密钥环所在的位置需要覆盖 TiDB 集群部署的区域。
2. 点击**创建密钥环**。输入密钥环的名称,选择密钥环的位置,然后点击**创建**。注意密钥环的位置需要覆盖 TiDB 集群部署的区域。


1. 进入 GCP 控制台的 [密钥管理](https://console.cloud.google.com/security/kms/keyrings)。
2. 点击**创建密钥环**,创建密钥环,注意密钥环所在的位置需要覆盖 TiDB 集群部署的区域。
3. 选择上一步创建的密钥环,在密钥环详情页面点击**创建密钥**,注意密钥的**保护级别**选择**软件**或 **HSM**,**密钥材料**选择**生成的密钥**,**用途**选择 **Symmetric encrypt/decrypt**。
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
3. 选择上一步创建的密钥环,在密钥环详情页面点击**创建密钥**,注意密钥的**保护级别**选择**软件****HSM****密钥材料**选择**生成的密钥****用途**选择 **Symmetric encrypt/decrypt**
3. 选择上一步创建的密钥环,在密钥环详情页面点击**创建密钥**
4. 输入密钥的名称,设置密钥的信息如下,然后点击**创建**
- **保护级别**:**软件**或 **HSM**
- **密钥材料**:**生成的密钥**
- **用途**:**Symmetric encrypt/decrypt**

@@ -108,6 +120,81 @@ endpoint = "https://kms.us-west-2.amazonaws.com"
`key-id` 指定 KMS CMK 的密钥 ID。`region` 为 KMS CMK 的 AWS 区域名。`endpoint` 通常无需指定,除非你在使用非 AWS 提供的 AWS KMS 兼容服务或需要使用 [KMS VPC endpoint](https://docs.aws.amazon.com/kms/latest/developerguide/kms-vpc-endpoint.html)。

你也可以使用 AWS [多区域键](https://docs.aws.amazon.com/zh_cn/kms/latest/developerguide/multi-region-keys-overview.html)。为此,你需要在一个特定的区域设置一个主键,并在需要的区域中添加副本密钥。
</div>

<div label="GCP KMS">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<div label="GCP KMS">
<div label="Google Cloud KMS">

github-actions bot pushed a commit to qiancai/pingcap-docsite-preview that referenced this pull request Mar 6, 2024
encryption-at-rest.md Outdated Show resolved Hide resolved
encryption-at-rest.md Outdated Show resolved Hide resolved
encryption-at-rest.md Outdated Show resolved Hide resolved
encryption-at-rest.md Outdated Show resolved Hide resolved
encryption-at-rest.md Outdated Show resolved Hide resolved
encryption-at-rest.md Outdated Show resolved Hide resolved
encryption-at-rest.md Outdated Show resolved Hide resolved
encryption-at-rest.md Outdated Show resolved Hide resolved
github-actions bot pushed a commit to qiancai/pingcap-docsite-preview that referenced this pull request Mar 11, 2024
Co-authored-by: lucasliang <nkcs_lykx@hotmail.com>
Copy link

ti-chi-bot bot commented Mar 12, 2024

@LykxSassinator: adding LGTM is restricted to approvers and reviewers in OWNERS files.

In response to this:

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

encryption-at-rest.md Outdated Show resolved Hide resolved
encryption-at-rest.md Outdated Show resolved Hide resolved
encryption-at-rest.md Outdated Show resolved Hide resolved
encryption-at-rest.md Outdated Show resolved Hide resolved
encryption-at-rest.md Outdated Show resolved Hide resolved
encryption-at-rest.md Outdated Show resolved Hide resolved
Co-authored-by: Lilian Lee <lilin@pingcap.com>
github-actions bot pushed a commit to qiancai/pingcap-docsite-preview that referenced this pull request Mar 15, 2024
encryption-at-rest.md Outdated Show resolved Hide resolved
encryption-at-rest.md Outdated Show resolved Hide resolved
encryption-at-rest.md Outdated Show resolved Hide resolved
github-actions bot pushed a commit to qiancai/pingcap-docsite-preview that referenced this pull request Mar 18, 2024
Copy link
Member

@lilin90 lilin90 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Mar 19, 2024
Copy link

ti-chi-bot bot commented Mar 19, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lilin90

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added the approved label Mar 19, 2024
Copy link

ti-chi-bot bot commented Mar 19, 2024

@lilin90: Please do not delete or edit you lgtm type comment!

In response to this:

/lgtm

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Mar 20, 2024
Copy link

ti-chi-bot bot commented Mar 20, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-03-19 07:12:23.604690362 +0000 UTC m=+1360770.626936751: ☑️ agreed by lilin90.
  • 2024-03-20 07:23:15.744333525 +0000 UTC m=+1447822.766579913: ☑️ agreed by qiancai.

@ti-chi-bot ti-chi-bot bot merged commit 5d31592 into pingcap:master Mar 20, 2024
7 checks passed
github-actions bot pushed a commit to qiancai/pingcap-docsite-preview that referenced this pull request Mar 20, 2024
@qiancai qiancai added translation/done This PR has been translated from English into Chinese and updated to pingcap/docs-cn in a PR. and removed translation/doing This PR’s assignee is translating this PR. labels Apr 16, 2024
@glorv glorv deleted the kms branch June 21, 2024 07:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved area/security Relates to TiDB security and privilege. lgtm size/L Denotes a PR that changes 100-499 lines, ignoring generated files. translation/done This PR has been translated from English into Chinese and updated to pingcap/docs-cn in a PR. v8.0 This PR/issue applies to TiDB v8.0.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants