signal-golang / textsecure

TextSecure(signal) client package for Go
GNU General Public License v3.0
57 stars 26 forks source link

404 when sending messages #45

Closed morph027 closed 2 years ago

morph027 commented 3 years ago

Somehow it suddenly stopped sending messages and receives a mix of 401 and 404 on requests.

time="2021/08/29 09:42:55" level=info msg="Registration done."
time="2021/08/29 09:42:55" level=debug msg="[textsecure] GetRegisteredContacts"
time="2021/08/29 09:42:56" level=debug msg="[textsecure] GET /v1/directory/auth 401\n"
time="2021/08/29 09:42:56" level=debug msg="[textsecure] getCredentials "
time="2021/08/29 09:42:56" level=debug msg="[textsecure] GetAndVerifyMultiRemoteAttestation"
time="2021/08/29 09:42:56" level=debug msg="[textsecure] PUT with auth /v1/attestation/<uuid> 401\n"
time="2021/08/29 09:42:56" level=debug msg="[textsecure] GetRegisteredContacts assestations"
time="2021/08/29 09:42:56" level=debug msg="[textsecure] GetRegisteredContacts contactDiscoveryRequest"
time="2021/08/29 09:42:56" level=debug msg="[textsecure] getContactDiscoveryRegisteredUser"
time="2021/08/29 09:42:57" level=debug msg="[textsecure] PUT with auth & cookoie /v1/discovery/<uuid> 401 \n"
time="2021/08/29 09:42:57" level=debug msg="[textsecure] GetAndVerifyMultiRemoteAttestation resp"
time="2021/08/29 09:42:57" level=info msg="Could not get contacts: Could not get get ContactDiscovery invalid character 'C' looking for beginning of value"
time="2021/08/29 09:42:57" level=debug msg="[textsecure] Websocket Connecting to signal-server"
time="2021/08/29 09:42:57" level=debug msg="[textsecure] Websocket Connected successfully"
time="2021/08/29 09:42:57" level=debug msg="[textsecure] Ask for new messages"
time="2021/08/29 09:42:57" level=info msg="[textsecure] No new messages"
time="2021/08/29 09:42:57" level=debug msg="[textsecure] Websocket sending message"
time="2021/08/29 09:43:48" level=debug msg="[textsecure] Websocket sending message"
time="2021/08/29 09:43:48" level=debug msg="[textsecure] Websocket sending message"
time="2021/08/29 09:43:48" level=debug msg="[textsecure] Websocket sending message"
time="2021/08/29 09:43:48" level=debug msg="[textsecure] Websocket sending message"
time="2021/08/29 09:43:48" level=debug msg="[textsecure] Websocket sending message"
time="2021/08/29 09:43:49" level=debug msg="[textsecure] Websocket sending message"
time="2021/08/29 09:43:49" level=debug msg="[textsecure] Websocket sending message"
time="2021/08/29 09:43:49" level=debug msg="[textsecure] Websocket sending message"
time="2021/08/29 09:43:49" level=debug msg="[textsecure] Websocket sending message"
time="2021/08/29 09:43:51" level=debug msg="[textsecure] Sending websocket ping message"
time="2021/08/29 09:43:51" level=debug msg="[textsecure] Received websocket pong message"
time="2021/08/29 09:43:54" level=debug msg="[textsecure] PUT /v1/messages/<mobile> 404\n"
time="2021/08/29 09:43:54" level=error msg="Error: status code 404"
morph027 commented 3 years ago

Not sure if the Signal API recently changed. Looks like as it just stoppey working yesterday.

nanu-c commented 3 years ago

Hey @morph027 signal changed that messages can only send with unidentified senders. I am on it, but it's quite a lot of work.

nanu-c commented 3 years ago

It's like that now, when you register you get an id + PW to make API calls. But now you can only use this for downloading a certificate.

With that certificate, your private and some crypto magic you can create new credentials to access the API. That means, you use your credentials including your uuid only once for login. That way, signal can ensure, they don't know who is knocking on their doors. Axolotl hasn't implemented that yet, we only used always the credentials from the registration. And that was turned off now.

nanu-c commented 3 years ago

I am on it, but it still needs 2 or 3 days

morph027 commented 3 years ago

No pressure, glad you found the reason.

morph027 commented 3 years ago

Build a new binary and created a new registration.

Registration done.                           
Get new uidentified sender certificate       
[textsecure] Getting SenderCertificate       
[textsecure] GET /v1/certificate/delivery 401 
[textsecure] Sender certificate: &{}         
[textsecure] GetRegisteredContacts           
[textsecure] GET /v1/directory/auth 401      
[textsecure] getCredentials                  
[textsecure] GetAndVerifyMultiRemoteAttestation 
[textsecure] PUT with auth /v1/attestation/xxx 401 
[textsecure] GetRegisteredContacts assestations 
[textsecure] GetRegisteredContacts contactDiscoveryRequest 
[textsecure] getContactDiscoveryRegisteredUser 
[textsecure] PUT with auth & cookie /v1/discovery/xxx 401  
[textsecure] GetAndVerifyMultiRemoteAttestation resp 
Could not get contacts: Could not get get ContactDiscovery invalid character 'C' looking for beginning of value 
[textsecure] Websocket Connecting to signal-server 
websocket: bad handshake                     
websocket: bad handshake
nanu-c commented 3 years ago

I think this finally solved it. https://github.com/signal-golang/textsecure/commit/ec7fe01df1511a659b19e7499ef34c9af7948aab

morph027 commented 3 years ago

Mhm, looks the same with the new build. Should i re-register again?

NiTRoeSE commented 3 years ago

Hi, are there any news about this problem ? I build new image for signal-web-gateway and tried to re-register but get:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x91f817]

goroutine 1 [running]:
github.com/signal-golang/textsecure.requestCode(0xc000026ef0, 0xd, 0xc000026f38, 0x5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
    /go/textsecure/server.go:164 +0x1f7
github.com/signal-golang/textsecure.registerDevice(0xc000022480, 0xc000130480)
    /go/textsecure/textsecure.go:396 +0xdc
github.com/signal-golang/textsecure.Setup(0xc0001f8000, 0xc0001f8000, 0x0)
    /go/textsecure/textsecure.go:285 +0x13a7
main.main()
    /go/textsecure/cmd/textsecure/main.go:507 +0x10a

Thanks in advanced! :)

achaiah commented 3 years ago

Hi @nanu-c, just wondering if you had any more time to look into this. Would love to see it work again!

nanu-c commented 3 years ago

Hey we have it working again but it involves another rust subprocess and i am still undecided how to do it.

nanu-c commented 3 years ago

A fast workaround would be register with axolotl and copy the files around.

achaiah commented 3 years ago

Sadly I know very little of go so I am not of great help here :(

morph027 commented 2 years ago

Got a new build including rust crayfish:

INFO[2021/11/14 09:25:19] [textsecure-crayfish] Starting crayfish-backend 
DEBU[2021/11/14 09:25:19] [texsecure] register Device                  
DEBU[2021/11/14 09:25:19] [textsecure] loading config                  
INFO[2021/11/14 09:25:19] [textsecure] request verification code for  +xxx 
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x94a498]

goroutine 1 [running]:
github.com/signal-golang/textsecure.requestCode(0xc0000a0f00, 0xe, 0xac732f, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
    /home/signal-gateway/textsecure/server.go:125 +0x1f8
github.com/signal-golang/textsecure.registerDevice(0xc0000ea400, 0xc0000f0400)
    /home/signal-gateway/textsecure/textsecure.go:421 +0x12d
github.com/signal-golang/textsecure.Setup(0xc0000ea300, 0xc0000ea300, 0x1)
    /home/signal-gateway/textsecure/textsecure.go:297 +0x13dd
main.main()
    /home/signal-gateway/textsecure/cmd/textsecure/main.go:507 +0x117
NiTRoeSE commented 2 years ago

A fast workaround would be register with axolotl and copy the files around.

...register with axolotl fails in ubuntu 20.04

Hetti commented 2 years ago

So I am not able to send a message because of 404.

ERRO[2021/12/09 xx.xx.xx] [textsecure] invalid recipient id +00000000000 
DEBU[2021/12/09 xx.xx.xx] getPreKeys +00000000000 1                   
DEBU[2021/12/09 xx.xx.xx] [textsecure] GET /v2/keys/+00000000000/1 404 
ERRO[2021/12/09 xx.xx.xx] status code 404    

+0000000000 is the dummy number replacing the real one.

Would reregistering fix it?

And how a example contacts.yml should look like? Do I need to set up contacts there?

thanks a lot for your help :+1:

nanu-c commented 2 years ago

I havn't looked into the cli for a while, best workaround is now to send first a message from the receiver to the cli, extract the uuid and send the message not to the phone number but to the uuid.

Hetti commented 2 years ago

Thanks, getting the right session name from the sessions folder works for sending messages. The group invite still not works, but this is now at least some semi working status now :) thanks

Hetti commented 2 years ago

Group Invite works :)

I don't have a clue how to send messages via JSON to the group. It doesn't work like sending messages to users:

curl -X POST -d '{"message":"hello"}' https://<GWURL>/json/<USER_ID>

when setting the groupid instead of the USER_ID the response is 404 and the client tries to get the PreKeys

getPreKeys <GROUP_ID> 1 
[textsecure] GET /v2/keys/<GROUP_ID>/1 404 
Error: status code 404

Any ideas?

nanu-c commented 2 years ago

actually a group message is like a private message with an group id. It has to be sent individually to each user of the group. In the textsecure backend are functions for triggering a group message. So how do you do your rest api?

Hetti commented 2 years ago

When I skipped through the code I saw the group messaging functions. Because I'm not familiar with rust, I couldn't completly understand the API function parameters. Is there an API Call, where I can specify the group, where the message will be sent or does this needs to be implemented?

My Textsecure Server is running in Gateway Mode. I currently loop through the User-UUIDs and send every user a message.

I want to send messages to a group, where I need just to specify the Group ID. As mentioned I tried to send it via Api with following call: curl -X POST -d '{"message":"hello"}' https://<GATEWAY-URL>/json/<GROUP_ID>

Hetti commented 2 years ago

Thanks to @nanu-c for the Guidance where to look.

I fixed the Regex for the GroupID and made a pull request https://github.com/signal-golang/textsecure/pull/53

Messaging into groups works now with the GroupID ✨

nanu-c commented 2 years ago

In this issue are many issues combined. Feel free to open them again in new issues. @morph027 is it working now for you?