mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-28 23:32:41 +00:00
Secrets: On startup, request again private keys we are missing locally
This will mitigate unexpected state of cross-signing and backup.
This commit is contained in:
parent
1228675f74
commit
bc4c7b2488
2 changed files with 29 additions and 0 deletions
|
@ -4,6 +4,7 @@ Changes in 0.11.3 (2020-05-xx)
|
|||
Improvements:
|
||||
* Cross-signing: Display "Verify your other sessions" modal at every startup if needed (#3180).
|
||||
* Cross-signing: The "Complete Security" button now triggers a verification request to all user devices.
|
||||
* Secrets: On startup, request again private keys we are missing locally.
|
||||
|
||||
Bug fix:
|
||||
* KeyVerificationSelfVerifyStartViewController has no navigation (#3195).
|
||||
|
|
|
@ -2769,6 +2769,8 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
|
|||
|
||||
// Register to new key verification request
|
||||
[self registerNewRequestNotificationForSession:mxSession];
|
||||
|
||||
[self checkLocalPrivateKeysInSession:mxSession];
|
||||
}
|
||||
else if (mxSession.state == MXSessionStateClosed)
|
||||
{
|
||||
|
@ -3523,6 +3525,32 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
|
|||
[eventsToNotify removeObjectForKey:@(mxSession.hash)];
|
||||
}
|
||||
|
||||
- (void)checkLocalPrivateKeysInSession:(MXSession*)mxSession
|
||||
{
|
||||
id<MXCryptoStore> cryptoStore = mxSession.crypto.store;
|
||||
NSUInteger keysCount = 0;
|
||||
if ([cryptoStore secretWithSecretId:MXSecretId.keyBackup])
|
||||
{
|
||||
keysCount++;
|
||||
}
|
||||
if ([cryptoStore secretWithSecretId:MXSecretId.crossSigningUserSigning])
|
||||
{
|
||||
keysCount++;
|
||||
}
|
||||
if ([cryptoStore secretWithSecretId:MXSecretId.crossSigningSelfSigning])
|
||||
{
|
||||
keysCount++;
|
||||
}
|
||||
|
||||
if (keysCount > 0 && keysCount < 3)
|
||||
{
|
||||
// We should have 3 of them. If not, request them again as mitigation
|
||||
NSLog(@"[AppDelegate] checkLocalPrivateKeysInSession: request keys because keysCount = %@", @(keysCount));
|
||||
[mxSession.crypto requestAllPrivateKeys];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue