Skip to content

Commit

Permalink
Merge pull request #7699 from vector-im/bugfix/hughns/qr-device-race
Browse files Browse the repository at this point in the history
  • Loading branch information
hughns authored Dec 9, 2022
2 parents be7b49b + 7bbd91f commit a762179
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.d/7699.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix E2EE set up failure whilst signing in using QR code
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ import org.matrix.android.sdk.api.session.crypto.crosssigning.KEYBACKUP_SECRET_S
import org.matrix.android.sdk.api.session.crypto.crosssigning.MASTER_KEY_SSSS_NAME
import org.matrix.android.sdk.api.session.crypto.crosssigning.SELF_SIGNING_KEY_SSSS_NAME
import org.matrix.android.sdk.api.session.crypto.crosssigning.USER_SIGNING_KEY_SSSS_NAME
import org.matrix.android.sdk.api.session.crypto.model.CryptoDeviceInfo
import org.matrix.android.sdk.api.session.crypto.model.MXUsersDevicesMap
import org.matrix.android.sdk.api.util.MatrixJsonParser
import org.matrix.android.sdk.api.util.awaitCallback
import timber.log.Timber

/**
Expand Down Expand Up @@ -147,6 +150,14 @@ class Rendezvous(
val deviceKey = crypto.getMyDevice().fingerprint()
send(Payload(PayloadType.PROGRESS, outcome = Outcome.SUCCESS, deviceId = deviceId, deviceKey = deviceKey))

try {
// explicitly download keys for ourself rather than racing with initial sync which might not complete in time
awaitCallback<MXUsersDevicesMap<CryptoDeviceInfo>> { crypto.downloadKeys(listOf(userId), false, it) }
} catch (e: Throwable) {
// log as warning and continue as initial sync might still complete
Timber.tag(TAG).w(e, "Failed to download keys for self")
}

// await confirmation of verification
val verificationResponse = receive()
if (verificationResponse?.outcome == Outcome.VERIFIED) {
Expand Down

0 comments on commit a762179

Please sign in to comment.