AsamK / signal-cli

signal-cli provides an unofficial commandline, JSON-RPC and dbus interface for the Signal messenger.
GNU General Public License v3.0
3.23k stars 306 forks source link

Problems receiving messages #853

Open maristieuvelonde opened 2 years ago

maristieuvelonde commented 2 years ago

I had a perfectly working setup (behind signal-cli-rest-api), and suddenly it stopped receiving or sending messages. Everything else (group management, contacts, etc) still works, and if I link a desktop app "device" everything is fine with this account.

When I try to receive a message though I get the following:

Envelope from: unknown source
Timestamp: 1641147881303 (2022-01-02T18:24:41.303Z)
Sent by unidentified/sealed sender
Exception: org.whispersystems.libsignal.InvalidKeyException: bad key type <0xc5> (InvalidMetadataMessageException)
No message content
AsamK commented 2 years ago

Might be caused by corrupted account files, but then device linking also wouldn't work ... Which signal-cli version are you using and do you use a self-compiled libsignal-client version? Also please try to run signal-cli with --verbose flag when sending a message and post the log here.

maristieuvelonde commented 2 years ago

I'm currently using 0.9.2 as it is the current release in signal-cli-rest-api. I've tried unregistering, deleting the data, registering again, etc, no dice. Again, if I link a desktop app it works fine.

Here are some additional logs:

Receive:

2022-01-02T17:16:11.262-0500 [main] INFO LibSignal - [libsignal-client]: rust/bridge/jni/src/logging.rs:173: Initializing libsignal-client version:0.9.7
2022-01-02T17:16:14.562-0500 [main] DEBUG org.asamk.signal.manager.ManagerImpl - Handling message actions
2022-01-02T17:16:14.626-0500 [main] INFO LibSignal - [WebSocketConnection]: [normal:1840194359] connect()
2022-01-02T17:16:14.654-0500 [main] INFO LibSignal - [WebSocketConnection]: [unidentified:1629759610] connect()
2022-01-02T17:16:14.705-0500 [main] DEBUG org.asamk.signal.manager.ManagerImpl - Checking for new message from server
2022-01-02T17:16:14.828-0500 [OkHttp https://chat.signal.org/...] INFO LibSignal - [WebSocketConnection]: [normal:1840194359] onOpen() connected
2022-01-02T17:16:14.829-0500 [OkHttp https://chat.signal.org/...] INFO LibSignal - [WebSocketConnection]: [unidentified:1629759610] onOpen() connected
2022-01-02T17:16:14.829-0500 [RxComputationThreadPool-3] DEBUG org.asamk.signal.manager.SignalWebSocketHealthMonitor - WebSocket is now connected
2022-01-02T17:16:14.832-0500 [RxComputationThreadPool-4] DEBUG org.asamk.signal.manager.SignalWebSocketHealthMonitor - WebSocket is now connected
2022-01-02T17:16:14.924-0500 [main] DEBUG org.asamk.signal.manager.ManagerImpl - New message received from server
Envelope from: “user” +11235551234 (device: 1)
Timestamp: 1641161772720 (2022-01-02T22:16:12.720Z)
Sent by unidentified/sealed sender
Exception: org.whispersystems.libsignal.InvalidKeyException: bad key type <0x1b> (InvalidMetadataMessageException)
No message content

2022-01-02T17:16:14.953-0500 [main] DEBUG org.asamk.signal.manager.ManagerImpl - Checking for new message from server
2022-01-02T17:16:14.954-0500 [main] DEBUG org.asamk.signal.manager.ManagerImpl - Received indicator that server queue is empty
2022-01-02T17:16:14.954-0500 [main] DEBUG org.asamk.signal.manager.ManagerImpl - Handling message actions
2022-01-02T17:16:14.958-0500 [main] DEBUG org.asamk.signal.manager.ManagerImpl - Checking for new message from server
2022-01-02T17:16:17.962-0500 [main] INFO LibSignal - [WebSocketConnection]: [normal:1840194359] disconnect()
2022-01-02T17:16:17.963-0500 [main] INFO LibSignal - [WebSocketConnection]: [unidentified:1629759610] disconnect()

Send:

2022-01-02T17:18:08.061-0500 [main] INFO LibSignal - [libsignal-client]: rust/bridge/jni/src/logging.rs:173: Initializing libsignal-client version:0.9.7
2022-01-02T17:18:09.669-0500 [main] WARN LibSignal - [PhoneNumberFormatter]: Got local CC: US
2022-01-02T17:18:09.702-0500 [main] DEBUG LibSignal - [SignalServiceMessageSender]: [1641161889681] Sending a data message.
2022-01-02T17:18:09.704-0500 [main] INFO LibSignal - [libsignal-client]: rust/protocol/src/session_cipher.rs:51: Building PreKeyWhisperMessage for: 1b2f0b37-f42d-4779-831f-db9106873e86.1 with preKeyId: 3967289
2022-01-02T17:18:09.706-0500 [main] INFO LibSignal - [SignalServiceMessageSender]: [sendMessage][1641161889681] Unidentified pipe unavailable, falling back... (WebSocketUnavailableException: WebSocket not currently available.)
2022-01-02T17:18:09.835-0500 [main] DEBUG LibSignal - [SignalServiceMessageSender]: [sendMessage][1641161889681] Sending a sent sync message to devices: [2]
2022-01-02T17:18:09.836-0500 [main] INFO LibSignal - [SignalServiceMessageSender]: [sendMessage][1641161889681] Pipe unavailable, falling back... (WebSocketUnavailableException: WebSocket not currently available.)
1641161889681

I tried resetting the session as well. I suspect that Signal on the other end is not sending a new profile approval with a sealed sender key.

AsamK commented 2 years ago

Looks like sending worked successfully ... can you get logs from the other device as well? The bad key type exception originates from within libsignal-client (https://github.com/signalapp/libsignal-client/blob/600b9070c12fa0e6983c567acc0e0306a75c34c1/rust/protocol/src/curve.rs#L43). A stack trace would be helpful here. I've added some additional log output on the master branch for decryption errors.

maristieuvelonde commented 2 years ago

I was unable to build signal-cli under debian with openjdk-17. After a lot of trial and error leading nowhere, I'm almost convinced the problem is that signal isn't sharing the sealed sender/profile with this contact again. Try as I might I never get the "allow sharing profile" prompt. I unregister the account, make sure Signal on the other end sees it as disabled (SMS only), delete the contact from signal, delete the contact from the phone's contacts, delete the signal "account", clear the cache. And start all over again... No dice, signal just refuses to acknowledge that it should prompt to allow sharing the profile (and thus sealed sender key).

0e141 commented 2 years ago

Hi, is there an update on this? I have a slightly different setup (Matrix - Signal bridge via Mautrix). Also worked perfectly untill recently. I tracked it down to the same error mentioned by @maristieuvelonde and can't get it to work again. For me neither sending nor receiving seems to work. I can see send messages in my own signal app however it isnt sent to the other party.

CarlKuhligk commented 1 year ago

I have the same problem. Using the app, desktop or web works fine. So if I send something using the mautrix-bridge it's only sent to my desktop and smartphone client (with one tick) but is not sent to the desired person. The signald container throws the follwoing error:

Log ``` WARN io.finn.signald.MessageReceiver - Received invalid metadata in incoming message org.signal.libsignal.metadata.InvalidMetadataMessageException: org.signal.libsignal.protocol.InvalidKeyException: bad key type <0xfb> at org.signal.libsignal.metadata.SealedSessionCipher.decrypt(SealedSessionCipher.java:160) ~[libsignal-client-x86_64-unknown-linux-gnu-0.21.1.jar:?] at org.whispersystems.signalservice.api.crypto.SignalSealedSessionCipher.decrypt(SignalSealedSessionCipher.java:57) ~[signal-service-java-x86_64-unknown-linux-gnu-2.15.3_unofficial_65.jar:?] at org.whispersystems.signalservice.api.crypto.SignalServiceCipher.decrypt(SignalServiceCipher.java:201) ~[signal-service-java-x86_64-unknown-linux-gnu-2.15.3_unofficial_65.jar:?] at org.whispersystems.signalservice.api.crypto.SignalServiceCipher.decrypt(SignalServiceCipher.java:147) ~[signal-service-java-x86_64-unknown-linux-gnu-2.15.3_unofficial_65.jar:?] at io.finn.signald.Manager.decryptMessage(Manager.java:439) ~[signald.jar:?] at io.finn.signald.Manager.receiveMessages(Manager.java:695) ~[signald.jar:?] at io.finn.signald.MessageReceiver.run(MessageReceiver.java:174) ~[signald.jar:?] at java.lang.Thread.run(Unknown Source) ~[?:?] Caused by: org.signal.libsignal.protocol.InvalidKeyException: bad key type <0xfb> at org.signal.libsignal.internal.Native.SealedSessionCipher_DecryptToUsmc(Native Method) ~[libsignal-client-x86_64-unknown-linux-gnu-0.21.1.jar:?] at org.signal.libsignal.metadata.SealedSessionCipher.decrypt(SealedSessionCipher.java:157) ~[libsignal-client-x86_64-unknown-linux-gnu-0.21.1.jar:?] ... 7 more 13:10:45.931 [[redacted 33]fa3-receiver] ERROR io.finn.signald.clientprotocol.v1.exceptions.InternalError - unexpected error while receiving org.signal.libsignal.metadata.InvalidMetadataMessageException: org.signal.libsignal.protocol.InvalidKeyException: bad key type <0xfb> at org.signal.libsignal.metadata.SealedSessionCipher.decrypt(SealedSessionCipher.java:160) ~[libsignal-client-x86_64-unknown-linux-gnu-0.21.1.jar:?] at org.whispersystems.signalservice.api.crypto.SignalSealedSessionCipher.decrypt(SignalSealedSessionCipher.java:57) ~[signal-service-java-x86_64-unknown-linux-gnu-2.15.3_unofficial_65.jar:?] at org.whispersystems.signalservice.api.crypto.SignalServiceCipher.decrypt(SignalServiceCipher.java:201) ~[signal-service-java-x86_64-unknown-linux-gnu-2.15.3_unofficial_65.jar:?] at org.whispersystems.signalservice.api.crypto.SignalServiceCipher.decrypt(SignalServiceCipher.java:147) ~[signal-service-java-x86_64-unknown-linux-gnu-2.15.3_unofficial_65.jar:?] at io.finn.signald.Manager.decryptMessage(Manager.java:439) ~[signald.jar:?] at io.finn.signald.Manager.receiveMessages(Manager.java:695) ~[signald.jar:?] at io.finn.signald.MessageReceiver.run(MessageReceiver.java:174) ~[signald.jar:?] at java.lang.Thread.run(Unknown Source) ~[?:?] Caused by: org.signal.libsignal.protocol.InvalidKeyException: bad key type <0xfb> at org.signal.libsignal.internal.Native.SealedSessionCipher_DecryptToUsmc(Native Method) ~[libsignal-client-x86_64-unknown-linux-gnu-0.21.1.jar:?] at org.signal.libsignal.metadata.SealedSessionCipher.decrypt(SealedSessionCipher.java:157) ~[libsignal-client-x86_64-unknown-linux-gnu-0.21.1.jar:?] ... 7 more ```
AsamK commented 1 year ago

@CarlKuhligk you seem to be running signald, not signal-cli (io.finn.signald)

I don't know where the bad key error comes from, but you could try resetting the session. (signal-cli send -e NUMBER)

Koushal-123 commented 9 months ago

@AsamK this error are got while receive the message by signal-cli => exception: { message: 'org.signal.libsignal.protocol.InvalidKeyIdException: No such signed pre key record: 9064553', type: 'ProtocolInvalidKeyIdException' },

Note : this error are only got when i send to user those have andorid signal account, this is not got any error when users have ios signal account