Skip to content

tiup-cluster(tls): support custom TLS certificates instead of the self-signed ones#2703

Open
panda2134 wants to merge 5 commits into
pingcap:masterfrom
panda2134:feature/custom-cert
Open

tiup-cluster(tls): support custom TLS certificates instead of the self-signed ones#2703
panda2134 wants to merge 5 commits into
pingcap:masterfrom
panda2134:feature/custom-cert

Conversation

@panda2134
Copy link
Copy Markdown

What problem does this PR solve?

Support custom TLS certificates in TiUP so users don't have to use the self-signed certificates. Close #2693.

What is changed and how it works?

A dedicate TLS mode "custom" is added. Specs of all TiDB components are adjusted, so in that mode, TiUP will not touch TLS certificate related configs (e.g., [security] section's ca-cert, client-cert, client-key in PD/TiKV) in config generation, keeping the user-specified certificate paths. TiUP itself is also configured to use a client TLS certificate in custom TLS mode. Users are expected to bring their own certificates for this mode (instead of depending on TiUP generating the certificates), preferably using internal certificates signed and distributed by organizations' internal CA.
CLI is modified to allow switching between the default TLS mode (called "managed") and the "custom" TLS mode.

DISCLAIMER: LLM is used for generation of some of the code, but all code is reviewed and polished by hand. Changes are also tested manually and reliably on a 3-node test cluster. See below for detailed steps of testing.

Check List

Tests

  • Manual test (add detailed scripts or steps below)

Code changes

  • Has exported function/method change
  • Has exported variable/fields change
  • Has persistent data change

Side effects

  • None

Related changes

  • Need to update the documentation

Release notes:

Support using custom TLS certificates for TLS cluster mode.

Add TLSMode field to GlobalOptions with IsCustomTLS() as the single
branching predicate. In custom mode, each component's setTLSConfig()
validates user-provided security.*-path keys instead of overwriting
them, and buildCertificateTasks()/loadCertificate() are skipped
entirely.

Manager.TLS() accepts CustomTLSOptions for cert validation, mode
transitions (managed↔custom with --force), and client cert
backup+copy via swapClientCertFiles(). SwapClientCert() guards
standalone cert rotation to custom-mode clusters only.

CLI adds --custom, --client-ca/cert/key flags and swap-client-cert
as an action in the existing tls <cluster> <action> switch.

Claude was used but code has been manually reviewed and polished. This should close pingcap#2693.
Before this change, blackbox_exporter is hardcoded to use self-signed TLS
certificates, regardless of whether TLS mode is custom.
Now we skip managed cert generation for blackbox_exporter when IsCustomTLS(),
and add blackbox_ca/cert/key fields to MonitoredOptions so users can specify cert paths via edit-config.
@ti-chi-bot
Copy link
Copy Markdown
Contributor

ti-chi-bot Bot commented Apr 28, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign xhebox for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

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

Details 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
Copy link
Copy Markdown
Contributor

ti-chi-bot Bot commented Apr 28, 2026

Welcome @panda2134! It looks like this is your first PR to pingcap/tiup 🎉

@pingcap-cla-assistant
Copy link
Copy Markdown

pingcap-cla-assistant Bot commented Apr 28, 2026

CLA assistant check
All committers have signed the CLA.

@ti-chi-bot ti-chi-bot Bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Apr 28, 2026
@panda2134
Copy link
Copy Markdown
Author

panda2134 commented Apr 28, 2026

Custom TLS Certificate Testing Steps

Environment: 3 VMs (172.18.0.8, 172.18.0.9, 172.18.0.10), user tidb, TiDB cluster v8.5.5

1. Baseline: Deploy cluster with managed TLS

Topology (no custom TLS):

# topo.yaml
global:
  user: tidb

pd_servers:
  - host: 172.18.0.8

tikv_servers:
  - host: 172.18.0.8
  - host: 172.18.0.9
  - host: 172.18.0.10

tidb_servers:
  - host: 172.18.0.8

Deploy and enable managed TLS:

tiup cluster deploy test-cluster v8.5.5 topo.yaml -u tidb -i ~/.ssh/tidb_deploy
tiup cluster start test-cluster
tiup cluster tls test-cluster enable

Verify managed certs:

openssl s_client -connect 172.18.0.8:2379 -showcerts </dev/null 2>/dev/null | openssl x509 -noout -subject -issuer
openssl s_client -connect 172.18.0.8:20160 -showcerts </dev/null 2>/dev/null | openssl x509 -noout -subject -issuer
openssl s_client -connect 172.18.0.9:20160 -showcerts </dev/null 2>/dev/null | openssl x509 -noout -subject -issuer
openssl s_client -connect 172.18.0.10:20160 -showcerts </dev/null 2>/dev/null | openssl x509 -noout -subject -issuer

Result: all show issuer=O=PingCAP, OU=TiUP (TiUP self-signed CA).

2. Generate custom certificates

Certs must be generated on Linux to avoid Windows line-ending corruption.

ssh tidb@172.18.0.8 "bash -s" << 'EOF'
mkdir -p ~/certs && cd ~/certs

# CA
openssl genrsa -out ca.pem 4096
openssl req -new -x509 -days 3650 -key ca.pem -out ca.crt \
  -subj "/CN=TiDB BYOC CA" \
  -addext "basicConstraints=critical,CA:TRUE" \
  -addext "keyUsage=critical,keyCertSign,cRLSign"

gen_cert() {
  local name=$1 ip=$2
  openssl genrsa -out ${name}.pem 2048
  openssl req -new -key ${name}.pem -out ${name}.csr -subj "/CN=${name}"
  openssl x509 -req -days 3650 -in ${name}.csr -CA ca.crt -CAkey ca.pem \
    -CAcreateserial -out ${name}.crt \
    -extfile <(printf "subjectAltName=IP:${ip}\nbasicConstraints=CA:FALSE\nkeyUsage=digitalSignature,keyEncipherment\nextendedKeyUsage=serverAuth,clientAuth")
  rm ${name}.csr
}

gen_cert pd      172.18.0.8
gen_cert pd-9    172.18.0.9
gen_cert tikv-8  172.18.0.8
gen_cert tikv-9  172.18.0.9
gen_cert tikv-10 172.18.0.10
gen_cert tidb    172.18.0.8
gen_cert client  127.0.0.1

# Install locally on .8
sudo cp ca.crt pd.crt pd.pem tidb.crt tidb.pem /etc/pki/tidb/
sudo cp tikv-8.crt /etc/pki/tidb/tikv.crt
sudo cp tikv-8.pem /etc/pki/tidb/tikv.pem
EOF

Distribute to other nodes:

# .9
ssh tidb@172.18.0.8 "cat ~/certs/ca.crt" | ssh tidb@172.18.0.9 "sudo tee /etc/pki/tidb/ca.crt > /dev/null"
ssh tidb@172.18.0.8 "cat ~/certs/tikv-9.crt" | ssh tidb@172.18.0.9 "sudo tee /etc/pki/tidb/tikv.crt > /dev/null"
ssh tidb@172.18.0.8 "cat ~/certs/tikv-9.pem" | ssh tidb@172.18.0.9 "sudo tee /etc/pki/tidb/tikv.pem > /dev/null"
ssh tidb@172.18.0.8 "cat ~/certs/pd-9.crt" | ssh tidb@172.18.0.9 "sudo tee /etc/pki/tidb/pd.crt > /dev/null"
ssh tidb@172.18.0.8 "cat ~/certs/pd-9.pem" | ssh tidb@172.18.0.9 "sudo tee /etc/pki/tidb/pd.pem > /dev/null"

# .10
ssh tidb@172.18.0.8 "cat ~/certs/ca.crt" | ssh tidb@172.18.0.10 "sudo tee /etc/pki/tidb/ca.crt > /dev/null"
ssh tidb@172.18.0.8 "cat ~/certs/tikv-10.crt" | ssh tidb@172.18.0.10 "sudo tee /etc/pki/tidb/tikv.crt > /dev/null"
ssh tidb@172.18.0.8 "cat ~/certs/tikv-10.pem" | ssh tidb@172.18.0.10 "sudo tee /etc/pki/tidb/tikv.pem > /dev/null"

Copy client cert to control machine:

scp tidb@172.18.0.8:~/certs/ca.crt ~/byoc-certs/ca.crt
scp tidb@172.18.0.8:~/certs/client.crt ~/byoc-certs/client.crt
scp tidb@172.18.0.8:~/certs/client.pem ~/byoc-certs/client.pem

3. Install patched tiup-cluster

# Build
make cluster

# Replace (adjust version as needed)
cp bin/tiup-cluster ~/.tiup/components/cluster/v1.16.5/tiup-cluster

4. Switch managed to custom TLS

Set cert paths for all instances:

tiup cluster edit-config test-cluster

Add config sections:

pd_servers:
  - host: 172.18.0.8
    config:
      security.cacert-path: /etc/pki/tidb/ca.crt
      security.cert-path: /etc/pki/tidb/pd.crt
      security.key-path: /etc/pki/tidb/pd.pem

tikv_servers:
  - host: 172.18.0.8
    config:
      security.ca-path: /etc/pki/tidb/ca.crt
      security.cert-path: /etc/pki/tidb/tikv.crt
      security.key-path: /etc/pki/tidb/tikv.pem
  - host: 172.18.0.9
    config:
      security.ca-path: /etc/pki/tidb/ca.crt
      security.cert-path: /etc/pki/tidb/tikv.crt
      security.key-path: /etc/pki/tidb/tikv.pem
  - host: 172.18.0.10
    config:
      security.ca-path: /etc/pki/tidb/ca.crt
      security.cert-path: /etc/pki/tidb/tikv.crt
      security.key-path: /etc/pki/tidb/tikv.pem

tidb_servers:
  - host: 172.18.0.8
    config:
      security.cluster-ssl-ca: /etc/pki/tidb/ca.crt
      security.cluster-ssl-cert: /etc/pki/tidb/tidb.crt
      security.cluster-ssl-key: /etc/pki/tidb/tidb.pem

monitored:
  blackbox_ca: /etc/pki/tidb/ca.crt
  blackbox_cert: /etc/pki/tidb/tikv.crt
  blackbox_key: /etc/pki/tidb/tikv.pem

Switch to custom mode:

tiup cluster tls test-cluster enable --custom --force \
  --client-ca=$HOME/byoc-certs/ca.crt \
  --client-cert=$HOME/byoc-certs/client.crt \
  --client-key=$HOME/byoc-certs/client.pem

Result: all 5 nodes came up successfully.

Check if swap-client-cert works:

% echo "# swapped-marker" >> ~/byoc-certs/client.crt
% echo "# swapped-marker" >> ~/byoc-certs/client.pem
% echo "# swapped-marker" >> ~/byoc-certs/ca.crt
% tiup cluster tls test-cluster swap-client-cert --client-ca ca.crt --client-cert client.crt --client-key client.pem
% cd /home/jiangyi.liu/.tiup/storage/cluster/clusters/test-cluster/tls/
% grep -r "swapped-marker" # should give 3 files: ca.crt, client.crt, client.pem

5. Verify BYOC certs are active

openssl s_client -connect 172.18.0.8:2379 -showcerts </dev/null 2>/dev/null | openssl x509 -noout -subject -issuer
openssl s_client -connect 172.18.0.8:20160 -showcerts </dev/null 2>/dev/null | openssl x509 -noout -subject -issuer
openssl s_client -connect 172.18.0.9:20160 -showcerts </dev/null 2>/dev/null | openssl x509 -noout -subject -issuer
openssl s_client -connect 172.18.0.10:20160 -showcerts </dev/null 2>/dev/null | openssl x509 -noout -subject -issuer

Result:

subject=CN=pd         issuer=CN=TiDB BYOC CA
subject=CN=tikv-8     issuer=CN=TiDB BYOC CA
subject=CN=tikv-9     issuer=CN=TiDB BYOC CA
subject=CN=tikv-10    issuer=CN=TiDB BYOC CA

6. Verify blackbox_exporter with custom certs

Check process and health:

ssh tidb@172.18.0.8 "ps aux | grep blackbox_exporter"
ssh tidb@172.18.0.8 "curl -s http://localhost:9115/health"

Verify config has custom paths:

ssh tidb@172.18.0.8 "cat /home/tidb/deploy/monitor-9100/conf/blackbox.yml"

Result: tls_connect module shows /etc/pki/tidb/ paths.

Probe TLS endpoints through blackbox:

ssh tidb@172.18.0.8 "curl -s 'http://localhost:9115/probe?target=172.18.0.8:2379&module=tls_connect' | grep probe_success"
ssh tidb@172.18.0.8 "curl -s 'http://localhost:9115/probe?target=172.18.0.8:20160&module=tls_connect' | grep probe_success"
ssh tidb@172.18.0.8 "curl -s 'http://localhost:9115/probe?target=172.18.0.9:20160&module=tls_connect' | grep probe_success"
ssh tidb@172.18.0.8 "curl -s 'http://localhost:9115/probe?target=172.18.0.10:20160&module=tls_connect' | grep probe_success"

Result: all probe_success 1.

7. Display shows TLS mode

tiup cluster display test-cluster

Output includes:

TLS encryption:     enabled
TLS mode:           custom

8. Scale-out PD with custom TLS

PD Certificate is already copied to 172.18.0.9.

Scale-out topology:

# scale-out-pd.yaml
pd_servers:
  - host: 172.18.0.9
    config:
      security.cacert-path: /etc/pki/tidb/ca.crt
      security.cert-path: /etc/pki/tidb/pd.crt
      security.key-path: /etc/pki/tidb/pd.pem
tiup cluster scale-out test-cluster scale-out-pd.yaml

Verify:

tiup cluster display test-cluster
openssl s_client -connect 172.18.0.9:2379 -showcerts </dev/null 2>/dev/null | openssl x509 -noout -subject -issuer
# Expected: issuer=CN=TiDB BYOC CA

9. Backward Compat

Tested swapping tiup-cluster from official version to version compiled from this branch. tiup cluster display [cluster-name] on a TLS-enable cluster correctly shows the cluster as "managed".

10. Custom -> Managed Switch

First, remove all but one PD nodes:

 % tiup cluster scale-in test-cluster -N 172.18.0.9:2379
This operation will delete the 172.18.0.9:2379 nodes in `test-cluster` and all their data.
Do you want to continue? [y/N]:(default=N) y
Scale-in nodes...
+ [ Serial ] - SSHKeySet: privateKey=/home/jiangyi.liu/.tiup/storage/cluster/clusters/test-cluster/ssh/id_rsa, publicKey=/home/jiangyi.liu/.tiup/storage/cluster/clusters/test-cluster/ssh/id_rsa.pub
+ [Parallel] - UserSSH: user=tidb, host=172.18.0.10
+ [Parallel] - UserSSH: user=tidb, host=172.18.0.8
+ [Parallel] - UserSSH: user=tidb, host=172.18.0.8
+ [Parallel] - UserSSH: user=tidb, host=172.18.0.9
+ [Parallel] - UserSSH: user=tidb, host=172.18.0.9
+ [Parallel] - UserSSH: user=tidb, host=172.18.0.8
+ [ Serial ] - ClusterOperate: operation=DestroyOperation, options={Roles:[] Nodes:[172.18.0.9:2379] Force:false SSHTimeout:5 OptTimeout:120 APITimeout:600 IgnoreConfigCheck:false NativeSSH:false SSHType: Concurrency:5 SSHProxyHost: SSHProxyPort:22 SSHProxyUser:jiangyi.liu SSHProxyIdentity:/home/jiangyi.liu/.ssh/id_rsa SSHProxyUsePassword:false SSHProxyTimeout:5 SSHCustomScripts:{BeforeRestartInstance:{Raw:} AfterRestartInstance:{Raw:}} CleanupData:false CleanupLog:false CleanupAuditLog:false RetainDataRoles:[] RetainDataNodes:[] DisplayMode:default Operation:StartOperation}
Stopping component pd
        Stopping instance 172.18.0.9
        Stop pd 172.18.0.9:2379 success
Destroying component pd
        Destroying instance 172.18.0.9
Destroy 172.18.0.9 finished
- Destroy pd paths: [/home/tidb/deploy/pd-2379/data /home/tidb/deploy/pd-2379/log /home/tidb/deploy/pd-2379 /etc/systemd/system/pd-2379.service]
+ [ Serial ] - UpdateMeta: cluster=test-cluster, deleted=`'172.18.0.9:2379'`
+ [ Serial ] - UpdateTopology: cluster=test-cluster
+ [ Serial ] - SSHKeySet: privateKey=/home/jiangyi.liu/.tiup/storage/cluster/clusters/test-cluster/ssh/id_rsa, publicKey=/home/jiangyi.liu/.tiup/storage/cluster/clusters/test-cluster/ssh/id_rsa.pub
+ [Parallel] - UserSSH: user=tidb, host=172.18.0.8
+ [Parallel] - UserSSH: user=tidb, host=172.18.0.9
+ [Parallel] - UserSSH: user=tidb, host=172.18.0.10
+ [Parallel] - UserSSH: user=tidb, host=172.18.0.8
+ [Parallel] - UserSSH: user=tidb, host=172.18.0.8
+ Refresh instance configs
  - Generate config pd -> 172.18.0.8:2379 ... Done
  - Generate config tikv -> 172.18.0.8:20160 ... Done
  - Generate config tikv -> 172.18.0.9:20160 ... Done
  - Generate config tikv -> 172.18.0.10:20160 ... Done
  - Generate config tidb -> 172.18.0.8:4000 ... Done
+ Reload prometheus and grafana
Scaled cluster `test-cluster` in successfully

Then, perform the switch:

% tiup cluster tls --force test-cluster enable
Switching from custom to managed TLS will generate a new self-signed CA.
Existing custom certificates on remote nodes will no longer be trusted.
Do you want to continue? [y/N]:(default=N) y
Enable/Disable TLS will stop and restart the cluster `test-cluster`
Do you want to continue? [y/N]:(default=N) y
Generate certificate: /home/jiangyi.liu/.tiup/storage/cluster/clusters/test-cluster/tls
+ [ Serial ] - SSHKeySet: privateKey=/home/jiangyi.liu/.tiup/storage/cluster/clusters/test-cluster/ssh/id_rsa, publicKey=/home/jiangyi.liu/.tiup/storage/cluster/clusters/test-cluster/ssh/id_rsa.pub
+ [Parallel] - UserSSH: user=tidb, host=172.18.0.8
+ [Parallel] - UserSSH: user=tidb, host=172.18.0.9
+ [Parallel] - UserSSH: user=tidb, host=172.18.0.10
+ [Parallel] - UserSSH: user=tidb, host=172.18.0.8
+ [Parallel] - UserSSH: user=tidb, host=172.18.0.8
+ Copy certificate to remote host
  - Generate certificate pd -> 172.18.0.8:2379 ... Done
  - Generate certificate tikv -> 172.18.0.8:20160 ... Done
  - Generate certificate tikv -> 172.18.0.9:20160 ... Done
  - Generate certificate tikv -> 172.18.0.10:20160 ... Done
  - Generate certificate tidb -> 172.18.0.8:4000 ... Done
+ Copy monitor certificate to remote host
  - Generate certificate node_exporter -> 172.18.0.10 ... Done
  - Generate certificate node_exporter -> 172.18.0.8 ... Done
  - Generate certificate node_exporter -> 172.18.0.9 ... Done
  - Generate certificate blackbox_exporter -> 172.18.0.8 ... Done
  - Generate certificate blackbox_exporter -> 172.18.0.9 ... Done
  - Generate certificate blackbox_exporter -> 172.18.0.10 ... Done
+ Refresh instance configs
  - Generate config pd -> 172.18.0.8:2379 ... Done
  - Generate config tikv -> 172.18.0.8:20160 ... Done
  - Generate config tikv -> 172.18.0.9:20160 ... Done
  - Generate config tikv -> 172.18.0.10:20160 ... Done
  - Generate config tidb -> 172.18.0.8:4000 ... Done
+ Refresh monitor configs
  - Generate config node_exporter -> 172.18.0.10 ... Done
  - Generate config node_exporter -> 172.18.0.8 ... Done
  - Generate config node_exporter -> 172.18.0.9 ... Done
  - Generate config blackbox_exporter -> 172.18.0.8 ... Done
  - Generate config blackbox_exporter -> 172.18.0.9 ... Done
  - Generate config blackbox_exporter -> 172.18.0.10 ... Done
+ [ Serial ] - Save meta
+ [ Serial ] - Restart Cluster
Stopping component tidb
        Stopping instance 172.18.0.8
        Stop tidb 172.18.0.8:4000 success
Stopping component tikv
        Stopping instance 172.18.0.10
        Stopping instance 172.18.0.8
        Stopping instance 172.18.0.9
        Stop tikv 172.18.0.10:20160 success
        Stop tikv 172.18.0.9:20160 success
        Stop tikv 172.18.0.8:20160 success
Stopping component pd
        Stopping instance 172.18.0.8
        Stop pd 172.18.0.8:2379 success
Stopping component node_exporter
        Stopping instance 172.18.0.10
        Stopping instance 172.18.0.8
        Stopping instance 172.18.0.9
        Stop 172.18.0.9 success
        Stop 172.18.0.8 success
        Stop 172.18.0.10 success
Stopping component blackbox_exporter
        Stopping instance 172.18.0.10
        Stopping instance 172.18.0.8
        Stopping instance 172.18.0.9
        Stop 172.18.0.10 success
        Stop 172.18.0.9 success
        Stop 172.18.0.8 success
Starting component pd
        Starting instance 172.18.0.8:2379
        Start instance 172.18.0.8:2379 success
Starting component tikv
        Starting instance 172.18.0.10:20160
        Starting instance 172.18.0.8:20160
        Starting instance 172.18.0.9:20160
        Start instance 172.18.0.9:20160 success
        Start instance 172.18.0.10:20160 success
        Start instance 172.18.0.8:20160 success
Starting component tidb
        Starting instance 172.18.0.8:4000
        Start instance 172.18.0.8:4000 success
Starting component node_exporter
        Starting instance 172.18.0.10
        Starting instance 172.18.0.8
        Starting instance 172.18.0.9
        Start 172.18.0.8 success
        Start 172.18.0.9 success
        Start 172.18.0.10 success
Starting component blackbox_exporter
        Starting instance 172.18.0.10
        Starting instance 172.18.0.8
        Starting instance 172.18.0.9
        Start 172.18.0.8 success
        Start 172.18.0.9 success
        Start 172.18.0.10 success
+ [ Serial ] - Reload PD Members
        Update pd-172.18.0.8-2379 peerURLs: [https://172.18.0.8:2380]
Enabled TLS between TiDB components for cluster `test-cluster` successfully

Verify the certificate is now managed.

% tiup cluster display test-cluster
Cluster type:       tidb
Cluster name:       test-cluster
Cluster version:    v8.5.5
Deploy user:        tidb
SSH type:           builtin
TLS encryption:     enabled
TLS mode:           managed
CA certificate:     /home/jiangyi.liu/.tiup/storage/cluster/clusters/test-cluster/tls/ca.crt
Client private key: /home/jiangyi.liu/.tiup/storage/cluster/clusters/test-cluster/tls/client.pem
Client certificate: /home/jiangyi.liu/.tiup/storage/cluster/clusters/test-cluster/tls/client.crt
Dashboard URL:      https://172.18.0.8:2379/dashboard
Dashboard URLs:     https://172.18.0.8:2379/dashboard
ID                 Role  Host         Ports        OS/Arch       Status   Data Dir                           Deploy Dir
--                 ----  ----         -----        -------       ------   --------                           ----------
172.18.0.8:2379    pd    172.18.0.8   2379/2380    linux/x86_64  Up|L|UI  /home/tidb/deploy/pd-2379/data     /home/tidb/deploy/pd-2379
172.18.0.8:4000    tidb  172.18.0.8   4000/10080   linux/x86_64  Up       -                                  /home/tidb/deploy/tidb-4000
172.18.0.10:20160  tikv  172.18.0.10  20160/20180  linux/x86_64  Up       /home/tidb/deploy/tikv-20160/data  /home/tidb/deploy/tikv-20160
172.18.0.8:20160   tikv  172.18.0.8   20160/20180  linux/x86_64  Up       /home/tidb/deploy/tikv-20160/data  /home/tidb/deploy/tikv-20160
172.18.0.9:20160   tikv  172.18.0.9   20160/20180  linux/x86_64  Up       /home/tidb/deploy/tikv-20160/data  /home/tidb/deploy/tikv-20160
Total nodes: 5
% echo|openssl s_client -connect 172.18.0.9:20160
Connecting to 172.18.0.9
CONNECTED(00000003)
Can't use SSL_get_servername
depth=1 O=PingCAP, OU=TiUP
verify error:num=19:self-signed certificate in certificate chain
verify return:1
depth=1 O=PingCAP, OU=TiUP
verify return:1
depth=0 O=PingCAP, OU=TiUP + OU=tikv, CN=tikv
verify return:1
---
Certificate chain
 0 s:O=PingCAP, OU=TiUP + OU=tikv, CN=tikv
   i:O=PingCAP, OU=TiUP
   a:PKEY: RSA, 2048 (bit); sigalg: sha256WithRSAEncryption
   v:NotBefore: Apr 28 03:19:58 2026 GMT; NotAfter: Apr 25 03:19:58 2036 GMT
 1 s:O=PingCAP, OU=TiUP
   i:O=PingCAP, OU=TiUP
   a:PKEY: RSA, 2048 (bit); sigalg: sha256WithRSAEncryption
   v:NotBefore: Apr 28 03:19:52 2026 GMT; NotAfter: Apr 15 03:19:52 2076 GMT
---
Server certificate
-----BEGIN CERTIFICATE-----
MIIDXTCCAkWgAwIBAgIRANodWVz3+xigbRoKrqBvh9UwDQYJKoZIhvcNAQELBQAw
ITEQMA4GA1UEChMHUGluZ0NBUDENMAsGA1UECxMEVGlVUDAeFw0yNjA0MjgwMzE5
NThaFw0zNjA0MjUwMzE5NThaMD0xEDAOBgNVBAoTB1BpbmdDQVAxGjALBgNVBAsT
BFRpVVAwCwYDVQQLEwR0aWt2MQ0wCwYDVQQDEwR0aWt2MIIBIjANBgkqhkiG9w0B
AQEFAAOCAQ8AMIIBCgKCAQEAy8SIa6Yvd+i33ir/54qYB2kwYhV8bb3lp/WG7UBB
bWOVVT7+5Z6gvuAsE6FeZDQFRVhZPWxQOnkyH+sLg2GYVJ97zXrYODc++9zjYTrv
O6G+qf43f+0V/tW8ZOTVVM2rprATZxHCAIzlAzdAIFdotH1R14iuJRDmUg3c78Wz
GoJI2RiMdZNkDqkvCgaEDYAuTatYsyBn7Ts76eLuZQWIV4b1oK/vIh2XE4Pv3HzB
bo78F8wx0F1Cx4J/6HronbrNmF4mMA6Qe10ap9GsOZ3WoAeXvS+iFoq3jHGy9JsX
dqFMQ7d8mz2p8tJE7OEfgIehBTU3u0+m9+a3Sc8MzXweyQIDAQABo3QwcjAOBgNV
HQ8BAf8EBAMCBaAwHQYDVR0lBBYwFAYIKwYBBQUHAwIGCCsGAQUFBwMBMB8GA1Ud
IwQYMBaAFKbT3OQESDb7fwGUVhLsv+fdd++SMCAGA1UdEQQZMBeCCWxvY2FsaG9z
dIcEfwAAAYcErBIACTANBgkqhkiG9w0BAQsFAAOCAQEAAnCIfhxBjl+X4vnGHbne
3IAfU0UMwvreQSrGdmOyaaYBWZFMVwsmxv3GKtBvJYXukEosUR1YJGoQk5vB8fx8
aohkCvlofYBUfgvFb95Idm6ddjgljl/OFr8JLcqDDld8Y7og9dRxOaRekXfwNfjK
SZ4pcMxAQNIFQI2ASe6F9di6BuATYYJlugnIBoj0DznZctDTolV0qzRC1YYcazMU
LiWEULpe2oTRBW+NC2uVu3QYvogLZikkrJa5DWqVhaltdA1t3vnkRwBMFT8RntBw
zwTJa0UBcWBoI8aAi7h4eZsnVisoXNncsbtEVV5QbmjlTeKV/lOJUFg/YGWMLJhD
9Q==
-----END CERTIFICATE-----
subject=O=PingCAP, OU=TiUP + OU=tikv, CN=tikv
issuer=O=PingCAP, OU=TiUP
---
Acceptable client certificate CA names
O=PingCAP, OU=TiUP
Requested Signature Algorithms: id-ml-dsa-65:id-ml-dsa-87:id-ml-dsa-44:ECDSA+SHA256:ECDSA+SHA384:ECDSA+SHA512:ed25519:ed448:ecdsa_brainpoolP256r1_sha256:ecdsa_brainpoolP384r1_sha384:ecdsa_brainpoolP512r1_sha512:rsa_pss_pss_sha256:rsa_pss_pss_sha384:rsa_pss_pss_sha512:RSA-PSS+SHA256:RSA-PSS+SHA384:RSA-PSS+SHA512:RSA+SHA256:RSA+SHA384:RSA+SHA512
Shared Requested Signature Algorithms: ECDSA+SHA256:ECDSA+SHA384:ECDSA+SHA512:ed25519:ed448:rsa_pss_pss_sha256:rsa_pss_pss_sha384:rsa_pss_pss_sha512:RSA-PSS+SHA256:RSA-PSS+SHA384:RSA-PSS+SHA512:RSA+SHA256:RSA+SHA384:RSA+SHA512
Peer signing digest: SHA256
Peer signature type: rsa_pss_rsae_sha256
Peer Temp Key: ECDH, prime256v1, 256 bits
---
SSL handshake has read 2489 bytes and written 753 bytes
Verification error: self-signed certificate in certificate chain
---
New, TLSv1.3, Cipher is TLS_AES_256_GCM_SHA384
Protocol: TLSv1.3
Server public key is 2048 bit
This TLS version forbids renegotiation.
Compression: NONE
Expansion: NONE
No ALPN negotiated
Early data was not sent
Verify return code: 19 (self-signed certificate in certificate chain)
---
DONE

11. Disable TLS

Disable TLS:

% tiup cluster tls test-cluster disable
Enable/Disable TLS will stop and restart the cluster `test-cluster`
Do you want to continue? [y/N]:(default=N) y
+ [ Serial ] - SSHKeySet: privateKey=/home/jiangyi.liu/.tiup/storage/cluster/clusters/test-cluster/ssh/id_rsa, publicKey=/home/jiangyi.liu/.tiup/storage/cluster/clusters/test-cluster/ssh/id_rsa.pub
+ [Parallel] - UserSSH: user=tidb, host=172.18.0.8
+ [Parallel] - UserSSH: user=tidb, host=172.18.0.8
+ [Parallel] - UserSSH: user=tidb, host=172.18.0.8
+ [Parallel] - UserSSH: user=tidb, host=172.18.0.9
+ [Parallel] - UserSSH: user=tidb, host=172.18.0.10
+ Copy certificate to remote host
+ Copy monitor certificate to remote host
+ Refresh instance configs
  - Generate config pd -> 172.18.0.8:2379 ... Done
  - Generate config tikv -> 172.18.0.8:20160 ... Done
  - Generate config tikv -> 172.18.0.9:20160 ... Done
  - Generate config tikv -> 172.18.0.10:20160 ... Done
  - Generate config tidb -> 172.18.0.8:4000 ... Done
+ Refresh monitor configs
  - Generate config node_exporter -> 172.18.0.8 ... Done
  - Generate config node_exporter -> 172.18.0.9 ... Done
  - Generate config node_exporter -> 172.18.0.10 ... Done
  - Generate config blackbox_exporter -> 172.18.0.8 ... Done
  - Generate config blackbox_exporter -> 172.18.0.9 ... Done
  - Generate config blackbox_exporter -> 172.18.0.10 ... Done
+ [ Serial ] - Save meta
+ [ Serial ] - Cleanup TLS files
+ [ Serial ] - Restart Cluster
Stopping component tidb
        Stopping instance 172.18.0.8
        Stop tidb 172.18.0.8:4000 success
Stopping component tikv
        Stopping instance 172.18.0.10
        Stopping instance 172.18.0.8
        Stopping instance 172.18.0.9
        Stop tikv 172.18.0.10:20160 success
        Stop tikv 172.18.0.8:20160 success
        Stop tikv 172.18.0.9:20160 success
Stopping component pd
        Stopping instance 172.18.0.8
        Stop pd 172.18.0.8:2379 success
Stopping component node_exporter
        Stopping instance 172.18.0.8
        Stopping instance 172.18.0.9
        Stopping instance 172.18.0.10
        Stop 172.18.0.10 success
        Stop 172.18.0.9 success
        Stop 172.18.0.8 success
Stopping component blackbox_exporter
        Stopping instance 172.18.0.8
        Stopping instance 172.18.0.9
        Stopping instance 172.18.0.10
        Stop 172.18.0.9 success
        Stop 172.18.0.10 success
        Stop 172.18.0.8 success
Starting component pd
        Starting instance 172.18.0.8:2379
        Start instance 172.18.0.8:2379 success
Starting component tikv
        Starting instance 172.18.0.10:20160
        Starting instance 172.18.0.8:20160
        Starting instance 172.18.0.9:20160
        Start instance 172.18.0.8:20160 success
        Start instance 172.18.0.10:20160 success
        Start instance 172.18.0.9:20160 success
Starting component tidb
        Starting instance 172.18.0.8:4000
        Start instance 172.18.0.8:4000 success
Starting component node_exporter
        Starting instance 172.18.0.10
        Starting instance 172.18.0.8
        Starting instance 172.18.0.9
        Start 172.18.0.9 success
        Start 172.18.0.8 success
        Start 172.18.0.10 success
Starting component blackbox_exporter
        Starting instance 172.18.0.10
        Starting instance 172.18.0.8
        Starting instance 172.18.0.9
        Start 172.18.0.8 success
        Start 172.18.0.10 success
        Start 172.18.0.9 success
+ [ Serial ] - Reload PD Members
        Update pd-172.18.0.8-2379 peerURLs: [http://172.18.0.8:2380]
        Cleanup localhost tls file success
Disabled TLS between TiDB components for cluster `test-cluster` successfully
 tiup cluster display test-cluster
Cluster type:       tidb
Cluster name:       test-cluster
Cluster version:    v8.5.5
Deploy user:        tidb
SSH type:           builtin
Dashboard URL:      http://172.18.0.8:2379/dashboard
Dashboard URLs:     http://172.18.0.8:2379/dashboard
ID                 Role  Host         Ports        OS/Arch       Status   Data Dir                           Deploy Dir
--                 ----  ----         -----        -------       ------   --------                           ----------
172.18.0.8:2379    pd    172.18.0.8   2379/2380    linux/x86_64  Up|L|UI  /home/tidb/deploy/pd-2379/data     /home/tidb/deploy/pd-2379
172.18.0.8:4000    tidb  172.18.0.8   4000/10080   linux/x86_64  Up       -                                  /home/tidb/deploy/tidb-4000
172.18.0.10:20160  tikv  172.18.0.10  20160/20180  linux/x86_64  Up       /home/tidb/deploy/tikv-20160/data  /home/tidb/deploy/tikv-20160
172.18.0.8:20160   tikv  172.18.0.8   20160/20180  linux/x86_64  Up       /home/tidb/deploy/tikv-20160/data  /home/tidb/deploy/tikv-20160
172.18.0.9:20160   tikv  172.18.0.9   20160/20180  linux/x86_64  Up       /home/tidb/deploy/tikv-20160/data  /home/tidb/deploy/tikv-20160
Total nodes: 5

@panda2134 panda2134 changed the title Feature/custom cert tls: support custom TLS certificates instead of the self-signed ones Apr 28, 2026
@panda2134 panda2134 changed the title tls: support custom TLS certificates instead of the self-signed ones tiup-cluster(tls): support custom TLS certificates instead of the self-signed ones Apr 28, 2026
@panda2134
Copy link
Copy Markdown
Author

/cc @kaaaaaaang Please have a look when possible, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contribution first-time-contributor size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support bring-your-own-certificate for TLS

1 participant