]> nmode's Git Repositories - signal-cli/blobdiff - src/main/java/org/asamk/signal/manager/Manager.java
Use legacy sender certificate, until uuid support is complete
[signal-cli] / src / main / java / org / asamk / signal / manager / Manager.java
index c928ec17ce14c2ceb6bc96558fd3debb280dc1f1..b418d310e1a3e8acb1e6c2d6a2f828a22eeb8b2c 100644 (file)
@@ -99,7 +99,6 @@ import org.whispersystems.signalservice.api.messages.multidevice.VerifiedMessage
 import org.whispersystems.signalservice.api.profiles.SignalServiceProfile;
 import org.whispersystems.signalservice.api.push.ContactTokenDetails;
 import org.whispersystems.signalservice.api.push.SignalServiceAddress;
-import org.whispersystems.signalservice.api.push.exceptions.AuthorizationFailedException;
 import org.whispersystems.signalservice.api.push.exceptions.EncapsulatedExceptions;
 import org.whispersystems.signalservice.api.push.exceptions.NetworkFailureException;
 import org.whispersystems.signalservice.api.push.exceptions.UnregisteredUserException;
@@ -215,20 +214,15 @@ public class Manager implements Signal {
         migrateLegacyConfigs();
 
         accountManager = getSignalServiceAccountManager();
-        try {
-            if (account.isRegistered()) {
-                if (accountManager.getPreKeysCount() < BaseConfig.PREKEY_MINIMUM_COUNT) {
-                    refreshPreKeys();
-                    account.save();
-                }
-                if (account.getUuid() == null) {
-                    account.setUuid(accountManager.getOwnUuid());
-                    account.save();
-                }
+        if (account.isRegistered()) {
+            if (accountManager.getPreKeysCount() < BaseConfig.PREKEY_MINIMUM_COUNT) {
+                refreshPreKeys();
+                account.save();
+            }
+            if (account.getUuid() == null) {
+                account.setUuid(accountManager.getOwnUuid());
+                account.save();
             }
-        } catch (AuthorizationFailedException e) {
-            System.err.println("Authorization failed, was the number registered elsewhere?");
-            throw e;
         }
     }
 
@@ -264,6 +258,8 @@ public class Manager implements Signal {
         if (username == null) {
             account = SignalAccount.createTemporaryAccount(identityKey, registrationId);
         } else {
+            account.getSignalProtocolStore().saveIdentity(username, identityKey.getPublicKey(), TrustLevel.TRUSTED_VERIFIED);
+
             ProfileKey profileKey = KeyUtils.createProfileKey();
             account = SignalAccount.create(dataPath, username, identityKey, registrationId, profileKey);
             account.save();
@@ -279,6 +275,7 @@ public class Manager implements Signal {
             createNewIdentity();
         }
         account.setPassword(KeyUtils.createPassword());
+        account.setUuid(null);
         accountManager = getSignalServiceAccountManager();
 
         if (voiceVerification) {
@@ -1000,7 +997,9 @@ public class Manager implements Signal {
     }
 
     private byte[] getSenderCertificate() throws IOException {
-        byte[] certificate = accountManager.getSenderCertificate();
+        // TODO support UUID capable sender certificates
+        // byte[] certificate = accountManager.getSenderCertificate();
+        byte[] certificate = accountManager.getSenderCertificateLegacy();
         // TODO cache for a day
         return certificate;
     }