【问题标题】:MariaDB 10.6.3 fails to start after enabling File Key Management EncryptionMariaDB 10.6.3 启用文件密钥管理加密后无法启动
【发布时间】:2022-08-09 20:52:46
【问题描述】:

我正在尝试在 MariaDB 10.6.3 服务器(Rocky Linux)中启用文件密钥管理加密。我正在使用 open ssl 生成密钥文件。我已遵循本指南https://mariadb.com/resources/blog/mariadb-encryption-tde-using-mariadbs-file-key-management-encryption-plugin/

echo \"1;\"$(openssl rand -hex 32) > /etc/mysql/encryption/keyfile
openssl rand -hex 128 > /etc/mysql/encryption/keyfile.key

使用生成加密文件时

openssl enc -aes-256-cbc -md sha1 -pass file:/etc/mysql/encryption/keyfile.key -in /etc/mysql/encryption/keyfile -out /etc/mysql/encryption/keyfile.enc

我收到警告

*** WARNING : deprecated key derivation used.
Using -iter or -pbkdf2 would be better.

由于上面的代码产生了一个警告,我用

openssl enc -aes-256-cbc -md sha512 -pbkdf2 -iter 100000 
 -pass file:/etc/mysql/encryption/keyfile.key -in /etc/mysql/encryption/keyfile -out /etc/mysql/encryption/keyfile.enc

这是我在 server.cnf 中添加的配置

#File Key Management Plugin
plugin_load_add = file_key_management
file_key_management_filename = /etc/mysql/encryption/keyfile.enc
file_key_management_filekey = FILE:/etc/mysql/encryption/keyfile.key
file_key_management_encryption_algorithm = AES_CTR

# InnoDB Encryption Setup
innodb_encrypt_tables = ON
innodb_encrypt_log = ON
innodb_encrypt_temporary_tables = ON
innodb_encryption_threads = 4
innodb_encryption_rotation_iops = 2000

# Temp & Log Encryption
encrypt_tmp_disk_tables = ON
encrypt_tmp_files = ON
encrypt_binlog = ON
aria_encrypt_tables = ON

保存配置后,当我尝试重新启动 MariaDB 时,它无法启动。 MariaDB 状态产生

[ERROR] mariadbd: Cannot decrypt /etc/mysql/encryption/keyfile.enc. Wrong key?
[ERROR] Plugin \'file_key_management\' init function returned error.


[ERROR] Plugin \'file_key_management\' registration as a ENCRYPTION failed.
[ERROR] InnoDB: cannot enable encryption, encryption plugin is not available
[ERROR] Plugin \'InnoDB\' init function returned error.
[ERROR] Plugin \'InnoDB\' registration as a STORAGE ENGINE failed.
[Note] Plugin \'FEEDBACK\' is disabled.
[ERROR] Failed to enable encryption of temporary files
[ERROR] Aborting
systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
systemd[1]: mariadb.service: Failed with result \'exit-code\'.
systemd[1]: Failed to start MariaDB 10.6.3 database server.

我检查了 /var/lib/mysql/ 并且 file_key_management.so 文件可用。

我确定添加-pbkdf2 -iter 100000 是问题所在。

谁能告诉我哪里出了问题?

    标签: mysql encryption mariadb tde mariadb-10.6


    【解决方案1】:

    当 file_key_management 插件不支持更新的格式和不同的密钥派生方法时,事情就会出错。但它可能在未来,见this bug report

    现在,您需要按照说明加密密钥文件:

    关于加密密钥文件,有一些重要的细节需要牢记,例如: MariaDB 目前唯一支持加密密钥文件的算法是高级加密标准 (AES) 的密码块链接 (CBC) 模式。 加密密钥大小可以是 128 位、192 位或 256 位。 加密密钥是根据加密密码的 SHA-1 哈希创建的。 加密密码的最大长度为 256 个字符。

    https://mariadb.com/kb/en/file-key-management-encryption-plugin/#encrypting-the-key-file

    $ sudo openssl enc -aes-256-cbc -md sha1 \
    -pass file:/etc/mysql/encryption/keyfile.key \
    -in /etc/mysql/encryption/keyfile \
    -out /etc/mysql/encryption/keyfile.enc
    

    如果您使用 -aes-256-cbc 加密,请确保文件密钥管理加密算法是不是设置为 AES_CTR。

    祝你好运!

    【讨论】:

      猜你喜欢
      • 2020-06-26
      • 1970-01-01
      • 2019-01-30
      • 1970-01-01
      • 2016-11-14
      • 2017-05-07
      • 2017-08-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多