Skip to content

Commit c19eceb

Browse files
authored
enable-tls-for-mysql-client: add tiproxy (#2957) (#3116)
1 parent 02fa25c commit c19eceb

File tree

2 files changed

+59
-1
lines changed

2 files changed

+59
-1
lines changed

en/enable-tls-for-mysql-client.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,10 @@ In this step, you create a TiDB cluster and perform the following operations:
639639

640640
## Step 3. Configure the MySQL client to use a TLS connection
641641

642+
> **Note:**
643+
>
644+
> By default, the server does not validate the client certificate. To require client certificate validation, use [`ALTER USER`](https://docs.pingcap.com/tidb/stable/sql-statement-alter-user/) to configure the account with `REQUIRE X509` or other client certificate constraints.
645+
642646
To connect the MySQL client with the TiDB cluster, use the client-side certificate created above and take the following methods. For details, refer to [Configure the MySQL client to use encrypted connections](https://docs.pingcap.com/tidb/stable/enable-tls-between-clients-and-servers#configure-the-mysql-client-to-use-encrypted-connections).
643647

644648
Execute the following command to acquire the client-side certificate and connect to the TiDB server:
@@ -724,3 +728,28 @@ SHOW GLOBAL STATUS LIKE 'Ssl\_server\_not\_%';
724728
+-----------------------+--------------------------+
725729
2 rows in set (0.011 sec)
726730
```
731+
732+
## TiProxy
733+
734+
When you use TiProxy in front of multiple TiDB servers, you also need to configure TLS for TiProxy. The certificate layout depends on the `TiProxyCertLayout` setting:
735+
736+
- Not set: uses the legacy layout.
737+
- `v1`: uses version one of the layout (recommended).
738+
739+
The following are the TLS settings for each TiProxy component:
740+
741+
- `security.cluster-tls`: used for communication between TiProxy and other components in the cluster, functioning as both client and server using mutual TLS (mTLS).
742+
- `security.server-tls`: used to provide MySQL protocol access on port `6000`.
743+
- `security.sql-tls`: used for TiProxy to access the SQL port of TiDB.
744+
- `security.server-http-tls`: used to provide HTTP service on port `3080`.
745+
746+
For more information, see [the security section of TiProxy configuration file](https://docs.pingcap.com/tidb/stable/tiproxy-configuration/#security).
747+
748+
By default, TiProxy attempts to reuse the TiDB TLS secret for both client and server connections. If you use this behavior, ensure that the certificates include the hostnames of the TiProxy nodes.
749+
750+
The following settings also affect TLS behavior:
751+
752+
- `tlsCluster.enabled`
753+
- `tlsClient.enabled`
754+
755+
You can generate certificates using tools such as `cfssl` or `cert-manager`.

zh/enable-tls-for-mysql-client.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,10 @@ aliases: ['/docs-cn/tidb-in-kubernetes/dev/enable-tls-for-mysql-client/']
635635

636636
## 第三步:配置 MySQL 客户端使用 TLS 连接
637637

638+
> **注意:**
639+
>
640+
> 默认情况下,服务器不会验证客户端证书。你可以使用 [`ALTER USER`](https://docs.pingcap.com/zh/tidb/stable/sql-statement-alter-user/) 语句,通过 `REQUIRE X509` 或其他客户端证书约束来配置账户。
641+
638642
可以根据[官网文档](https://docs.pingcap.com/zh/tidb/stable/enable-tls-between-clients-and-servers#配置-mysql-client-使用安全连接)提示,使用上面创建的 Client 证书,通过下面的方法连接 TiDB 集群:
639643

640644
获取 Client 证书的方式并连接 TiDB Server 的方法是:
@@ -731,4 +735,29 @@ SHOW GLOBAL STATUS LIKE 'Ssl\_server\_not\_%';
731735
| Ssl_server_not_before | Jan 24 07:59:47 2025 UTC |
732736
+-----------------------+--------------------------+
733737
2 rows in set (0.011 sec)
734-
```
738+
```
739+
740+
## TiProxy
741+
742+
当在多个 TiDB 服务器之间部署 TiProxy 时,也需要为 TiProxy 配置 TLS。证书布局取决于 `TiProxyCertLayout` 设置:
743+
744+
- 未设置:使用旧版布局。
745+
- `v1`:使用 v1 版本布局。推荐使用该版本。
746+
747+
以下是 TiProxy 组件的 TLS 配置项:
748+
749+
- `security.cluster-tls`:用于 TiProxy 与集群中其他组件之间的通信,同时作为客户端和服务端使用 (mTLS)。
750+
- `security.server-tls`:用于在 `6000` 端口提供 MySQL 协议访问服务。
751+
- `security.sql-tls`:用于 TiProxy 访问 TiDB 的 SQL 端口。
752+
- `security.server-http-tls`:用于在 `3080` 端口提供 HTTP 服务。
753+
754+
另请参见 [TiProxy 配置文件的 security 部分](https://docs.pingcap.com/zh/tidb/stable/tiproxy-configuration/#security)。
755+
756+
默认情况下,TiProxy 会尝试使用 TiDB 的 TLS Secret 来建立客户端和服务端连接。如果采用这种方式,请确保这些证书中也包含 TiProxy 节点的主机名。
757+
758+
另外还会受以下配置项影响:
759+
760+
- `tlsCluster.enabled`
761+
- `tlsClient.enabled`
762+
763+
这些证书可以使用 `cfssl``cert-manager` 生成。

0 commit comments

Comments
 (0)