diff --git a/src/client.js b/src/client.js index ed5987770..aebf18ec6 100644 --- a/src/client.js +++ b/src/client.js @@ -1506,11 +1506,15 @@ MatrixClient.prototype.createKeyBackupVersion = async function(info) { undefined, "POST", "/room_keys/version", undefined, data, {prefix: httpApi.PREFIX_UNSTABLE}, ); - this.enableKeyBackup({ - algorithm: info.algorithm, - auth_data: info.auth_data, - version: res.version, - }); + + // We could assume everything's okay and enable directly, but this ensures + // we run the same signature verification that will be used for future + // sessions. + await this.checkKeyBackup(); + if (!this.getKeyBackupEnabled()) { + throw new Error("Key backup not usable even though we just created it"); + } + return res; }; diff --git a/src/crypto/index.js b/src/crypto/index.js index 33fda2895..e38af407b 100644 --- a/src/crypto/index.js +++ b/src/crypto/index.js @@ -952,8 +952,7 @@ Crypto.prototype.setTrustedBackupPubKey = async function(trustedPubKey) { */ Crypto.prototype.checkKeyBackup = async function() { this._checkedForBackup = false; - const returnInfo = await this._checkAndStartKeyBackup(); - return returnInfo; + return this._checkAndStartKeyBackup(); }; /**