-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Update enable-tls-between-clients-and-servers.md #16100
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
base: master
Are you sure you want to change the base?
Conversation
Modify the method of establishing SSL encrypted communication
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Welcome @hecao100! |
Modify the method of establishing SSL encrypted communication |
Hi @hecao100, thanks for the contribution. Please click the following link in your PR description to sign the CLA. |
@@ -17,9 +17,18 @@ TiDB 服务端支持启用基于 TLS(传输层安全)协议的加密连接 | |||
|
|||
要为 TiDB 客户端与服务端间的通信开启 TLS 加密传输,首先需要在 TiDB 服务端通过配置开启 TLS 加密连接的支持,然后通过配置客户端应用程序使用 TLS 加密连接。一般情况下,如果服务端正确配置了 TLS 加密连接支持,客户端库都会自动启用 TLS 加密传输。 | |||
|
|||
TiDB 客户端与服务端间的通信开启 TLS 加密可以分为两种:1、只开启SSL加密通信;2、强制校验客户端证书。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TiDB 客户端与服务端间的通信开启 TLS 加密可以分为两种:1、只开启SSL加密通信;2、强制校验客户端证书。 | |
TiDB 服务端配置开启与客户端之间通信的 TLS 加密传输,可以分为两种类型:1、只开启 TLS 加密传输;2、服务端强制校验客户端证书。 | |
+ 只开启 TLS 加密传输:可以手动配置参数 `ssl-cert`、`ssl-key`,开启 TLS 加密传输;也可以配置参数 `auto-tls` 自动生成证书以开启 TLS 加密传输。配置参数 `ssl-ca` 可以增加对客户端证书进行校验,但是不是强制的,客户端可以不提供证书,如果提供证书则必须是合法的证书。 | |
+ 服务端强制校验客户端证书:当服务端配置了参数 `ssl-cert`、`ssl-key` 和 `ssl-ca` 的基础上,打开了系统变量`require_secure_transport` 后,服务端将强制要求客户端提供证书并校验证书合法性。 |
另外,与 MySQL 相同,TiDB 也支持在同一 TCP 端口上开启 TLS 连接或非 TLS 连接。对于开启了 TLS 连接支持的 TiDB 服务端,客户端既可以选择通过加密连接安全地连接到该 TiDB 服务端,也可以选择使用普通的非加密连接。如需使用加密连接,你可以通过以下方式进行配置: | ||
|
||
+ 通过配置系统变量 `require_secure_transport` 要求所有用户必须使用加密连接来连接到 TiDB。 | ||
+ 通过配置系统变量 `require_secure_transport` 要求所有用户必须使用加密连接来连接到 TiDB。开启后会校验客户端证书。此为上文说的强制校验客户端证书。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+ 通过配置系统变量 `require_secure_transport` 要求所有用户必须使用加密连接来连接到 TiDB。开启后会校验客户端证书。此为上文说的强制校验客户端证书。 | |
+ 通过配置系统变量 [`require_secure_transport`] (/system-variables.md#require_secure_transport-new-in-v610)要求所有用户必须基于某种形式的安全传输机制连接到 TiDB,此时服务端仅允许使用 TLS 的 TCP/IP 连接,或者使用 Unix 套接字的连接。 |
+ 通过配置系统变量 `require_secure_transport` 要求所有用户必须使用加密连接来连接到 TiDB。开启后会校验客户端证书。此为上文说的强制校验客户端证书。 | ||
+ 开启方式,修改tidb.toml | ||
```[security] | ||
require-secure-transport = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
security.require-secure-transport已经失效了,取而代之的是系统变量require_secure_transport,此系统变量的开启需要用户基于安全连接到数据库后,使用SET命令进行开启。
另外:当前章节是概述部分,要补充配置示例,请在 <##配置 TiDB 服务端启用安全连接> 章节进行。
@@ -40,7 +49,12 @@ TiDB 服务端支持启用基于 TLS(传输层安全)协议的加密连接 | |||
- [`ssl-ca`](/tidb-configuration-file.md#ssl-ca):可选,指定受信任的 CA 证书文件路径 | |||
- [`tls-version`](/tidb-configuration-file.md#tls-version):可选,指定最低 TLS 版本,例如 `TLSv1.2` | |||
|
|||
`auto-tls` 支持安全连接,但不提供客户端证书验证。有关证书验证和控制证书生成方式的说明,请参考下面配置 `ssl-cert`,`ssl-key` 和 `ssl-ca` 变量的建议: | |||
`auto-tls` 支持安全连接,但不提供客户端证书验证。此为上文说的只开启SSL加密通信。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
`auto-tls` 支持安全连接,但不提供客户端证书验证。此为上文说的只开启SSL加密通信。 | |
`auto-tls` 表示在服务端没有配置参数 `ssl-cert` 和 `ssl-key` 时,服务端会自动签发这两个证书,以支持TiDB的安全连接,但不提供 CA 证书进行客户端证书验证。有关证书验证和控制证书生成方式的说明,请参考下面配置 `ssl-cert`、`ssl-key` 和 `ssl-ca` 变量,以及系统变量 `require_secure_transport` 的建议: |
@@ -40,7 +49,12 @@ TiDB 服务端支持启用基于 TLS(传输层安全)协议的加密连接 | |||
- [`ssl-ca`](/tidb-configuration-file.md#ssl-ca):可选,指定受信任的 CA 证书文件路径 | |||
- [`tls-version`](/tidb-configuration-file.md#tls-version):可选,指定最低 TLS 版本,例如 `TLSv1.2` | |||
|
|||
`auto-tls` 支持安全连接,但不提供客户端证书验证。有关证书验证和控制证书生成方式的说明,请参考下面配置 `ssl-cert`,`ssl-key` 和 `ssl-ca` 变量的建议: | |||
`auto-tls` 支持安全连接,但不提供客户端证书验证。此为上文说的只开启SSL加密通信。 | |||
+ 开启方式,修改tidb.toml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
配置示例,请在本章节的最后添加。对比仅开启加密传输和强制要求校验客户端证书两种方式。添加的示例例如:
- 只开启 TLS 加密传输,在
config
文件或命令行参数中设置:ssl-ca = "/path/root.crt" ssl-cert = "/path/tidb.crt" ssl-key = "/path/tidb.key"
- 服务端强制校验客户端证书,在配置了参数
ssl-cert
,ssl-key
和ssl-ca
的基础上,修改系统变量require_secure_transport
:
SET GLOBAL require_secure_transport = ON;
Hi @hecao100, could you check the review comments above? We'd like to get this PR merged before February 1, so that you also score points for merged PRs. 😄 |
PR needs rebase. 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. |
Modify the method of establishing SSL encrypted communication
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).
What is the related PR or file link(s)?
Do your changes match any of the following descriptions?