From d53357f4e7905993ef13ebab75008eee779b76ab Mon Sep 17 00:00:00 2001 From: Kenneth Skovhede Date: Tue, 20 Aug 2024 21:10:15 +0200 Subject: [PATCH] Fixed decrypt/re-encrypt toggling --- Duplicati.Library.RestAPI/Database/Connection.cs | 10 ++-------- Duplicati.Library.RestAPI/Database/ServerSettings.cs | 8 ++++---- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/Duplicati.Library.RestAPI/Database/Connection.cs b/Duplicati.Library.RestAPI/Database/Connection.cs index 7a2dfc791..70e00be87 100644 --- a/Duplicati.Library.RestAPI/Database/Connection.cs +++ b/Duplicati.Library.RestAPI/Database/Connection.cs @@ -69,14 +69,10 @@ namespace Duplicati.Server.Database public void ReWriteAllFieldsIfEncryptionChanged() { - var activeToken = m_encryptSensitiveFields - ? "enc-v1-canary" - : "no-encryption"; - // The token is automatically decrypted when the settings are loaded // In case the password has changed, this will fail and return the encrypted // hex-string, but will crash before reaching this point - if (this.ApplicationSettings.EncryptionCanaryToken != activeToken) + if (this.ApplicationSettings.EncryptedFields != m_encryptSensitiveFields) { var backups = this.Backups; foreach (var b in backups) @@ -86,9 +82,7 @@ namespace Duplicati.Server.Database } this.SetSettings(this.GetSettings(ANY_BACKUP_ID), ANY_BACKUP_ID); - this.ApplicationSettings.EncryptionCanaryToken = m_encryptSensitiveFields - ? EncryptedFieldHelper.Encrypt(activeToken) - : activeToken; + this.ApplicationSettings.EncryptedFields = m_encryptSensitiveFields; } } diff --git a/Duplicati.Library.RestAPI/Database/ServerSettings.cs b/Duplicati.Library.RestAPI/Database/ServerSettings.cs index 60706af06..ef545760d 100644 --- a/Duplicati.Library.RestAPI/Database/ServerSettings.cs +++ b/Duplicati.Library.RestAPI/Database/ServerSettings.cs @@ -59,7 +59,7 @@ namespace Duplicati.Server.Database public const string PBKDF_CONFIG = "pbkdf-config"; public const string AUTOGENERATED_PASSPHRASE = "autogenerated-passphrase"; public const string DISABLE_VISUAL_CAPTCHA = "disable-visual-captcha"; - public const string ENCRYPTION_CANARY_TOKEN = "encryption-canary-token"; + public const string ENCRYPTED_FIELDS = "encrypted-fields"; } private readonly Dictionary settings; @@ -653,16 +653,16 @@ namespace Duplicati.Server.Database } } - public string EncryptionCanaryToken + public bool EncryptedFields { get { - return settings[CONST.ENCRYPTION_CANARY_TOKEN]; + return Duplicati.Library.Utility.Utility.ParseBool(settings[CONST.ENCRYPTED_FIELDS], false); } set { lock (databaseConnection.m_lock) - settings[CONST.ENCRYPTION_CANARY_TOKEN] = value; + settings[CONST.ENCRYPTED_FIELDS] = value.ToString(); SaveSettings(); } }