From 1c6d91b59c2837ecd6ec3194fce508e7b85a6232 Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Mon, 12 Mar 2018 14:09:08 -0700 Subject: [PATCH] Harden rotateSignedPrekey against nonexistent identity key This is now what happens after Signal Desktop discovers that it is no longer linked with a mobile device, since the identityh key is deleted. --- libtextsecure/account_manager.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libtextsecure/account_manager.js b/libtextsecure/account_manager.js index 0ad7fd0540..f36e650d6c 100644 --- a/libtextsecure/account_manager.js +++ b/libtextsecure/account_manager.js @@ -154,9 +154,16 @@ var server = this.server; var cleanSignedPreKeys = this.cleanSignedPreKeys; + // TODO: harden this against missing identity key? Otherwise, we get + // retries every five seconds. return store.getIdentityKeyPair().then(function(identityKey) { return libsignal.KeyHelper.generateSignedPreKey(identityKey, signedKeyId); + }, function(error) { + console.log('Failed to get identity key. Canceling key rotation.'); }).then(function(res) { + if (!res) { + return; + } console.log('Saving new signed prekey', res.keyId); return Promise.all([ textsecure.storage.put('signedKeyId', signedKeyId + 1),