Skip to content

Commit 45426b8

Browse files
authored
dm(encrypt): refine error message for secret key not initialized (#12476)
close #12046
1 parent 145e2ed commit 45426b8

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

dm/pkg/encrypt/encrypt.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,18 @@ func IsInitialized() bool {
5959
// we use a notInitializedCipher to always return error.
6060
type notInitializedCipher struct{}
6161

62+
const secretKeyNotInitializedError = `secret key not initialized. To enable encryption:
63+
1. Create a file containing a 32-byte (64-character) hexadecimal AES-256 secret key.
64+
2. Set 'secret-key-path' in DM-master's configuration file to point to this key file.
65+
3. Restart DM-master to apply the configuration.
66+
For details, see: https://docs.pingcap.com/tidb/stable/dm-customized-secret-key`
67+
6268
func (n *notInitializedCipher) Encrypt([]byte) ([]byte, error) {
63-
return nil, errors.New("secret key is not initialized")
69+
return nil, errors.New(secretKeyNotInitializedError)
6470
}
6571

6672
func (n *notInitializedCipher) Decrypt([]byte) ([]byte, error) {
67-
return nil, errors.New("secret key is not initialized")
73+
return nil, errors.New(secretKeyNotInitializedError)
6874
}
6975

7076
type aesCipher struct {

dm/tests/dmctl_basic/run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ function run() {
503503
check_rpc_alive $cur/../bin/check_master_online 127.0.0.1:$MASTER_PORT
504504
run_dm_ctl_cmd_mode $WORK_DIR "127.0.0.1:$MASTER_PORT" \
505505
"encrypt a" \
506-
"secret key is not initialized" 1
506+
"secret key not initialized" 1
507507
}
508508

509509
cleanup_data dmctl

0 commit comments

Comments
 (0)