-
-
Notifications
You must be signed in to change notification settings - Fork 590
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rust-crypto: fix bootstrapCrossSigning
on second call
#3912
Conversation
@@ -66,18 +66,25 @@ export class CrossSigningIdentity { | |||
}); | |||
|
|||
if (olmDeviceHasKeys) { | |||
if (!privateKeysInSecretStorage) { | |||
if (!(await this.secretStorage.hasKey())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the real fix in this PR: we need to check that secretStorage is set up before we try to export to it.
this.secretStorage.store("m.cross_signing.master", exported.masterKey); | ||
await this.secretStorage.store("m.cross_signing.master", exported.masterKey); | ||
} else { | ||
logger.error(`Cannot export MSK to secret storage, private key unknown`); | ||
} | ||
if (exported?.self_signing_key) { | ||
this.secretStorage.store("m.cross_signing.self_signing", exported.self_signing_key); | ||
await this.secretStorage.store("m.cross_signing.self_signing", exported.self_signing_key); | ||
} else { | ||
logger.error(`Cannot export SSK to secret storage, private key unknown`); | ||
} | ||
if (exported?.userSigningKey) { | ||
this.secretStorage.store("m.cross_signing.user_signing", exported.userSigningKey); | ||
await this.secretStorage.store("m.cross_signing.user_signing", exported.userSigningKey); | ||
} else { | ||
logger.error(`Cannot export USK to secret storage, private key unknown`); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these things were missing their await
keywords, which meant that when they failed they were shouting into the void.
Currently, `bootstrapCrossSigning` raises an exception if it is called a second time before secret storage is set up. It is easily fixed by checking that 4S is set up before trying to export to 4S. Also a few logging fixes while we're in the area.
0ef8201
to
4e5915e
Compare
will add some more tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch
const authDict = { type: "test" }; | ||
await bootstrapCrossSigning(authDict); | ||
|
||
// a second call should do nothing except GET requests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What get requests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does GET /user/:user/account_data/:type
requests, because this test is running before the initialsync completes (so it has not cached any account data in memory).
Would you find this useful to include in the comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No maybe not. Was trying to remember why it would do requests.
Looks like it's checking if it's in 4S or not to eventually update 4S or import. There are some comments about it in bootstrapCrossSigning. I guess the naming is not perfect, maybe it's ensureCrossSigning but also fix it :/
Test flake filed as element-hq/element-web#26679 |
Currently,
bootstrapCrossSigning
raises an exception if it is called a second time before secret storage is set up. It is easily fixed by checking that 4S is set up before trying to export to 4S.Also a few logging fixes while we're in the area.
Fixes element-hq/element-web#26393
Here's what your changelog entry will look like:
🐛 Bug Fixes
bootstrapCrossSigning
on second call (#3912). Fixes Element-R: Exceptions when setting up backup/cross-signing/etc on existing account with no 4S element-hq/element-web#26393.