AutoMySQLBackup加密备份解密问题浅析
|
AutoMySQLBackup备份配置了加密选项过后,它会将数据库的备份文件加密。测试解密这些加密的备份文件时遇到错误(密钥做了脱敏处理)。- $ openssl enc -aes-256-cbc -d -in daily_mysql_2024-05-14_09h09m_Tuesday.sql.gz.enc \
- > -out daily_mysql_2024-05-14_09h09m_Tuesday.sql.gz -pass pass:********
- *** WARNING : deprecated key derivation used.
- Using -iter or -pbkdf2 would be better.
- bad decrypt
- 140587404826432:error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad decrypt:crypto/evp/evp_enc.c:643:
复制代码 其中加密的密钥是正确的,但是每次都会提示下面错误信息:
*** WARNING : deprecated key derivation used.Using -iter or -pbkdf2 would be better.bad decrypt140587404826432:error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad decrypt:crypto/evp/evp_enc.c:643:
这里加密和解密都位于同一台服务器上,所以openssl的版本都是一样的,不会因为openssl版本导致这类问题,openssl的具体版本信息如下所示:- $ openssl version
- OpenSSL 1.1.1k FIPS 25 Mar 2021
复制代码 看了一下AutoMySQLBackup的加密文件的代码,如下所示,它使用openssl进行加密。- # @info: This function is called after data has already been saved. It performs encryption and
- # hardlink-copying of files to a latest folder.
- # @return: flags
- # @deps: load_default_config
- files_postprocessing () {
- local flags
- let "flags=0x00"
- let "flags_files_postprocessing_success_encrypt=0x01"
- # -> CONFIG_encrypt
- [[ "${CONFIG_encrypt}" = "yes" && "${CONFIG_encrypt_password}" ]] && {
- if (( $CONFIG_dryrun )); then
- printf 'dry-running: openssl enc -aes-256-cbc -pbkdf2 -iter 1000 -e -in %s -out %s.enc -pass pass:%s\n' ${1} ${1} "${CONFIG_encrypt_password}"
- else
- openssl enc -aes-256-cbc -pbkdf2 -iter 1000 -e -in ${1} -out ${1}.enc -pass pass:"${CONFIG_encrypt_password}"
- if (( $? == 0 )); then
- if rm ${1} 2>&1; then
- echo "Successfully encrypted archive as ${1}.enc"
- let "flags |= $flags_files_postprocessing_success_encrypt"
- else
- echo "Successfully encrypted archive as ${1}.enc, but could not remove cleartext file ${1}."
- let "E |= $E_enc_cleartext_delfailed"
- fi
- else
- let "E |= $E_enc_failed"
- fi
- fi
- }
- # <- CONFIG_encrypt
- # -> CONFIG_mysql_dump_latest
- [[ "${CONFIG_mysql_dump_latest}" = "yes" ]] && {
- if (( $flags & $flags_files_postprocessing_success_encrypt )); then
- if (( $CONFIG_dryrun )); then
- printf 'dry-running: cp -al %s.enc %s/latest/\n' "${1}" "${CONFIG_backup_dir}"
- else
- cp -al "${1}.enc" "${CONFIG_backup_dir}"/latest/
- fi
- else
- if (( $CONFIG_dryrun )); then
- printf 'dry-running: cp -al %s %s/latest/\n' "${1}" "${CONFIG_backup_dir}"
- else
- cp -al "${1}" "${CONFIG_backup_dir}"/latest/
- fi
- fi
- }
- # <- CONFIG_mysql_dump_latest
- return $flags
- }
复制代码 扫描上面二维码关注我如果你真心觉得文章写得不错,而且对你有所帮助,那就不妨帮忙“推荐"一下,您的“推荐”和”打赏“将是我最大的写作动力!本文版权归作者所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接.
来源:https://www.cnblogs.com/kerrycode/p/18191044
免责声明:由于采集信息均来自互联网,如果侵犯了您的权益,请联系我们【E-Mail:cb@itdo.tech】 我们会及时删除侵权内容,谢谢合作! |
|
|
|
发表于 2024-5-15 00:09:52
举报
回复
分享
|
|
|
|