Also catch IllegalArgumentException when sending messages during receive

It's necessary to keep receiving messages if a session state is corrupted.
e.g:
Exception in thread "main" java.lang.IllegalArgumentException: Empty key
        at java.base/javax.crypto.spec.SecretKeySpec.<init>(Unknown Source)
        at org.whispersystems.libsignal.ratchet.ChainKey.getBaseMaterial(ChainKey.java:57)
        at org.whispersystems.libsignal.ratchet.ChainKey.getMessageKeys(ChainKey.java:47)
        at org.whispersystems.libsignal.SessionCipher.encrypt(SessionCipher.java:97)
        at org.signal.libsignal.metadata.SealedSessionCipher.encrypt(SealedSessionCipher.java:70)
        at org.whispersystems.signalservice.api.crypto.SignalServiceCipher.encrypt(SignalServiceCipher.java:86)
        at org.whispersystems.signalservice.api.SignalServiceMessageSender.getEncryptedMessage(SignalServiceMessageSender.java:1456)
        at org.whispersystems.signalservice.api.SignalServiceMessageSender.getEncryptedMessages(SignalServiceMessageSender.java:1406)
        at org.whispersystems.signalservice.api.SignalServiceMessageSender.sendMessage(SignalServiceMessageSender.java:1276)
        at org.whispersystems.signalservice.api.SignalServiceMessageSender.sendReceipt(SignalServiceMessageSender.java:206)
        at org.asamk.signal.manager.Manager.sendReceipt(Manager.java:686)
        at org.asamk.signal.manager.Manager.handleMessage(Manager.java:1562)
        at org.asamk.signal.manager.Manager.receiveMessages(Manager.java:1496)
        at org.asamk.signal.commands.ReceiveCommand.handleCommand(ReceiveCommand.java:160)
        at org.asamk.signal.Main.handleCommands(Main.java:137)
        at org.asamk.signal.Main.main(Main.java:60)
This commit is contained in:
AsamK 2020-04-21 20:33:23 +02:00
parent 6ca695b65e
commit 19b01ff2e9

View file

@ -1560,7 +1560,7 @@ public class Manager implements Signal {
if (content.isNeedsReceipt()) {
try {
sendReceipt(sender, message.getTimestamp());
} catch (IOException | UntrustedIdentityException e) {
} catch (IOException | UntrustedIdentityException | IllegalArgumentException e) {
e.printStackTrace();
}
}
@ -1579,21 +1579,21 @@ public class Manager implements Signal {
if (rm.isContactsRequest()) {
try {
sendContacts();
} catch (UntrustedIdentityException | IOException e) {
} catch (UntrustedIdentityException | IOException | IllegalArgumentException e) {
e.printStackTrace();
}
}
if (rm.isGroupsRequest()) {
try {
sendGroups();
} catch (UntrustedIdentityException | IOException e) {
} catch (UntrustedIdentityException | IOException | IllegalArgumentException e) {
e.printStackTrace();
}
}
if (rm.isBlockedListRequest()) {
try {
sendBlockedList();
} catch (UntrustedIdentityException | IOException e) {
} catch (UntrustedIdentityException | IOException | IllegalArgumentException e) {
e.printStackTrace();
}
}