crypto: Improve the logging for deserialization failures

master
Damir Jelić 2021-02-17 15:23:26 +01:00
parent 544881f11c
commit 6cc03d1c19
2 changed files with 15 additions and 8 deletions

View File

@ -809,12 +809,16 @@ impl OlmMachine {
let mut events = Vec::new(); let mut events = Vec::new();
for event_result in &to_device_events.events { for event_result in &to_device_events.events {
let mut event = if let Ok(e) = event_result.deserialize() { let mut event = match event_result.deserialize() {
e Ok(e) => e,
} else { Err(e) => {
// Skip invalid events. // Skip invalid events.
warn!("Received an invalid to-device event {:?}", event_result); warn!(
"Received an invalid to-device event {:?} {:?}",
e, event_result
);
continue; continue;
}
}; };
info!("Received a to-device event {:?}", event); info!("Received a to-device event {:?}", event);
@ -931,7 +935,10 @@ impl OlmMachine {
// TODO check if this is from a verified device. // TODO check if this is from a verified device.
let (decrypted_event, _) = session.decrypt(event).await?; let (decrypted_event, _) = session.decrypt(event).await?;
trace!("Successfully decrypted Megolm event {:?}", decrypted_event); trace!(
"Successfully decrypted a Megolm event {:?}",
decrypted_event
);
// TODO set the encryption info on the event (is it verified, was it // TODO set the encryption info on the event (is it verified, was it
// decrypted, sender key...) // decrypted, sender key...)

View File

@ -349,7 +349,7 @@ impl Account {
(SessionType::New(session), plaintext) (SessionType::New(session), plaintext)
}; };
trace!("Successfully decrypted a Olm message: {}", plaintext); trace!("Successfully decrypted an Olm message: {}", plaintext);
let (event, signing_key) = match self.parse_decrypted_to_device_event(sender, &plaintext) { let (event, signing_key) = match self.parse_decrypted_to_device_event(sender, &plaintext) {
Ok(r) => r, Ok(r) => r,