Commit Graph

506 Commits (50c470e53d91e4e0ecb075a0086b409d9acbce95)

Author SHA1 Message Date
Lilia 50c470e53d
Certificate pinning via node XMLHttpRequest implementation (#1394)
* Add certificate pinning on https service requests

Make https requests to the server using node apis instead of browser apis, so we
can specify our own CA list, which contains only our own CA.

This protects us from MITM by a rogue CA.

As a bonus, this let's us drop the use of non-standard ports and just use good
ol' default 443 all the time, at least for http requests.

// FREEBIE

* Make certificateAuthorities an option on requests

Modify node-based xhr implementation based on driverdan/node-XMLHttpRequest,
adding support for setting certificate authorities on each request.

This allows us to pin our master CA for requests to the server and cdn but not
to the s3 attachment server, for instance. Also fix an exception when sending
binary data in a request: it is submitted as an array buffer, and must be
converted to a node Buffer since we are now using a node based request api.

// FREEBIE

* Import node-based xhr implementation

Add a copy of https://github.com/driverdan/node-XMLHttpRequest@86ff70e, and
expose it to the renderer in the preload script.

In later commits this module will be extended to support custom certificate
authorities.

// FREEBIE

* Support "arraybuffer" responseType on requests

When fetching attachments, we want the result as binary data rather than a utf8
string. This lets our node-based XMLHttpRequest honor the responseType property
if it is set on the xhr.

Note that naively using the raw `.buffer` from a node Buffer won't work, since
it is a reuseable backing buffer that is often much larger than the actual
content defined by the Buffer's offset and length.

Instead, we'll prepare a return buffer based on the response's content length
header, and incrementally write chunks of data into it as they arrive.

// FREEBIE

* Switch to self-signed server endpoint

* Log more error info on failed requests

With the node-based xhr, relevant error info are stored in statusText and
responseText when a request fails.

// FREEBIE

* Add node-based websocket w/ support for custom CA

// FREEBIE

* Support handling array buffers instead of blobs

Our node-based websocket calls onmessage with an arraybuffer instead of a blob.
For robustness (on the off chance we switch or update the socket implementation
agian) I've kept the machinery for converting blobs to array buffers.

// FREEBIE

* Destroy all wacky server ports

// FREEBIE
8 years ago
Scott Nonnenberg 0fbe43c2dc
Protobufs: More logging on failure to load protobufs, fix tests
FREEBIE
8 years ago
Scott Nonnenberg 3a3aa3efb6
Remove test/protos symlink, use window.PROTO_ROOT for config 8 years ago
Scott Nonnenberg c8013d930c
Proto-loading: Throw if we get an error 8 years ago
lilia 859d49b3f4
Use relative paths
// FREEBIE
8 years ago
Scott Nonnenberg 1e694fe8d7 Log entry max to 2k, remove logging in hot codepaths (#1459)
On a recent trip through a CPU profile taken while Signal Desktop
churned through a large backlog of messages, it was clear that
console.log was a major source of time spent, primarily the sort
operation required after every new entry is added to the Backbone
collection. So, three different techniques to combat this:

1) Reduce the maximum number of entries in the collection from 5k to 2k
2) No more logging of add/update/remove queue in MessageReceiver
3) No more log entries in Message.handleDataMessage main codepath

FREEBIE
8 years ago
Lilia 51cd28bb4a Fix race handling contact sync with verified info (#1419)
When processing a contact sync with embedded identity key verification info, we
were running overlapping async fetch/save operations on the same conversation
model, causing a race that tends to clobber updates to the contact info.

In this change we extend the application-level contact info handler to block on
a subsequent call to the verification handler, which effectively serializes the
fetch/save calls, and relieves the need for the message receiver to trigger a
seperate event concerning the verification info on contact sync messages.

Fixes #1408

// FREEBIE
8 years ago
Scott Nonnenberg 36e8b82b5f Remove unknown group messages from cache - no need to retry! (#1414)
FREEBIE
8 years ago
Scott Nonnenberg 46b64e306f createTaskWithTimeout: Don't log expiration if task threw (#1412)
FREEBIE
8 years ago
Scott Nonnenberg 4011e26b50 Fix handling of sync message with blocked numbers (#1411)
FREEBIE
8 years ago
Scott Nonnenberg c0cd733139 Full export, migration banner, and full migration workflow - behind flag (#1342)
* Add support for backup and restore

This first pass works for all stores except messages, pending some scaling
improvements.

// FREEBIE

* Import of messages and attachments

Properly sanitize filenames. Logging information that will help with
debugging but won't threaten privacy (no contact or group names),
where the on-disk directories have this information to make things
human-readable

FREEBIE

* First fully operational single-action export and import!

FREEBIE

* Add migration export flow

A banner alert leads to a blocking ui for the migration. We close the socket and
wait for incoming messages to drain before starting the export.

FREEBIE

* A number of updates for the export flow

1. We don't immediately pop the directory selection dialog box, instead
  showing an explicit 'choose directory' button after explaining what is
  about to happen
2. We show a 'submit debug log' button on most steps of the process
3. We handle export errors and encourage the user to double-check their
  filesystem then submit their log
4. We are resilient to restarts during the process
5. We handle the user cancelling out of the directory selection dialog
  differently from other errors.
6. The export process is now serialized: non-messages, then messages.
7. After successful export, show where the data is on disk

FREEBUE

* Put migration behind a flag

FREEBIE

* Shut down websocket before proceeding with export

FREEBIE

* Add MigrationView to test/index.html to fix test

FREEBIE

* Remove 'Submit Debug Log' button when the export process is complete

FREEBIE

* Create a 'Signal Export' directory below user-chosen dir

This cleans things up a bit so we don't litter the user's target
directory with lots of stuff.

FREEBIE

* Clarify MessageReceiver.drain() method comments

FREEBIE

* A couple updates for clarity - event names, else handling

Also the removal of wait(), which wasn't used anywhere.

FREEBIE

* A number of wording updates for the export flow

FREEBIE

* Export complete: put dir on its own line, make text selectable

FREEBIE
8 years ago
Scott Nonnenberg 9fb079253c Remove errors from the cache when they are shown to the user (#1392)
There's really no reason to retry encryption errors again if they've
already been made user-visible in a conversation.

Also, refactor e->error in background.js onError(), since both e and ev
in this method made it too easy to make a mistake.
8 years ago
Scott Nonnenberg 84fd605ad3 MessageReceiver cache: Don't convert to string for save
Because IndexedDB supports ArrayBuffer natively.

FREEBIE
8 years ago
Scott Nonnenberg 4ef36cc95c Add logging to help track down problems with Sync
Seems like we're running into errors sending the message to kick off the
sync, so positive logging as well as error logging is included.

FREEBIE
8 years ago
Scott Nonnenberg 7e9ed1481b Set receivedAt after decrypt, sort by received then sent
FREEBIE
8 years ago
Scott Nonnenberg 620b71a649 Maintain original received time when processing queued/error msgs
FREEBIE
8 years ago
Scott Nonnenberg 8700112f6d Decrypt any IncomingIdentityKeyError still sticking around
FREEBIE
8 years ago
Scott Nonnenberg b33c5c4c07 MessageReceiver: Wait for all code paths in handleSyncMessage
Without this, the recent changes to wait for read receipts and delivery
receipts don't have much of an effect.

FREEBIE
8 years ago
Scott Nonnenberg 2130795708 Fix 'retry message' scenario: they are now content messages
FREEBIE
8 years ago
Scott Nonnenberg e0c1f0d27a MessageReceiver: Process cached before dismissing loading screen
FREEBIE
8 years ago
Scott Nonnenberg fa00f08c95 MessageReceiver: Fix envelope id logging and make it consistent
FREEBIE
8 years ago
Scott Nonnenberg 7e8f3ab5e7
Fix for "Can't find record for undefined.1"
Also, we didn't need to recalculate the number here anyway!

FREEBIE
8 years ago
Scott Nonnenberg e223db56d9 Set messageKeysLimit to unlimited if communicating with our devices (#1348)
Set messageKeysLimit to unlimited if communicating with our devices

FREEBIE
8 years ago
Scott Nonnenberg 7d4ae63501 MessageReceiver: Log empty event, flow promise properly
FREEBIE
8 years ago
Scott Nonnenberg 92ba295d52 Better logging for sync sent messages, and new (disappeared) msgs
FREEBIE
8 years ago
Scott Nonnenberg 0b4d14e5ac MessageReceiver: Ensure that we queue all cached first
FREEBIE
8 years ago
Scott Nonnenberg 73a77c7b97 Consistent returns, no more eventTarget, comments for tricky bits
FREEBIE
8 years ago
Scott Nonnenberg 8c231d9830 MessageReceiver: Flow promises back properly in decrypt error case
FREEBIE
8 years ago
Scott Nonnenberg af2ce56c8d Reset MessageReciever queue whenever possible
(like we do with the conversation queue already)

FREEBIE
8 years ago
Scott Nonnenberg 305bd6b3b8 App loading screen: show messages processed so far
Also, show the same loading screen on index.js before we've bootstrapped
the app.

FREEBIE
8 years ago
Scott Nonnenberg 53f2bfbb57 Animated loading screens on startup and first conversation load
FREEBIE
8 years ago
Scott Nonnenberg f38d715250 Read receipts: Log sender and timestamp when related msg not found
FREEBIE
8 years ago
Scott Nonnenberg 9db0a58260 Whenever adding something to a queue, include a timeout
No more wedged queues!

FREEBIE
8 years ago
Scott Nonnenberg bd0050b6c6 Cache messages on receipt, remove from cache when processed
FREEBIE
8 years ago
Scott Nonnenberg 20451cc827 Show verified/keychange notifications when actually relevant
FREEBIE
8 years ago
lilia 982e7f962c Update libsignal-protocol
// FREEBIE
8 years ago
Scott Nonnenberg 224140c911 OutgoingMessage: Provide proper timestamp for replayability
FREEBIE
8 years ago
Scott Nonnenberg 5d1150e5bc Fix call to reloadDevicesAndSend - it returns a function
FREEBIE
8 years ago
Scott Nonnenberg f414c13220 Protos: Update to optional verified in sync (was: repeated)
This means that we no longer need to iterate.

FREEBIE
8 years ago
lilia fdce4cfc7c Fix failed identity key sync from contact sync
These were failing because ByteBuffers from the protobufs need to be converted
to ArrayBuffers. Fixed by useing the existing handler in MessageReceiver to
process verified messages from contact sync messages and dispatch them as their
own events, reducing some complexity on the application side.

// FREEBIE
8 years ago
Scott Nonnenberg 4ee4ad80c3 Message.send - check for missing identityKey, also add logging
FREEBIE
8 years ago
Scott Nonnenberg 551aa24e9a OutgoingMessage: A few code style tweaks to make things readable
FREEBIE
8 years ago
Scott Nonnenberg 116e4d2eeb OutgoingMessage: Reduce the calls to registerError
In some cases, due to promise chaining and error propagation, we were
calling registerError more than once for a given error. This would then
cause the overall callback for the send operation to be called with a
partial set of errors, as well as duplicates.

Note: we do need to find a way to attach identityKey to the
OutgoingIdentityKeyError in the case where it comes directly from the
encrypt() instead of our pre-key operations.

FREEBIE
8 years ago
lilia 9f4fcc5afa Send null messages to mask verified syncs
First construct a null message of random size and contents and send it to the
destination. Then include that same padding in the verification sync.

Note that the sync message is additionally randomly padded like all other sync
messages.

This lets Verified sync messages appear the same as normal sync message traffic.

// FREEBIE
8 years ago
lilia bb9c97b960 Support for receiving null messages
Just log em for debugging. Also update the error messge thrown when we get a
content message with no supported properties. It may be empty or may just have
an unrecognized field.

// FREEBIE
8 years ago
lilia 1e93b12b90 Update protos with support for null messages
// FREEBIE
8 years ago
lilia 6e758fc1ea Randomly pad all sync messages
WhisperSystems/libsignal-service-java@c46cdc0aa5

// FREEBIE
8 years ago
Scott Nonnenberg 20f4d48991 Protos: Move to latest iteration of verification protos
FREEBIE
8 years ago
lilia 4232f5711c Handle identity key change errors on encrypt
We need to capture key change errors from the protocol library when we call
encrypt. Previously we would only see these on session init.

// FREEBIE
8 years ago
Scott Nonnenberg 4a1dc46ab3 Fixes to get local verification and sync messages working
FREEBIE
8 years ago