Merge pull request #790 from vector-im/enabled_e2e_by_default

Crypto: Enable e2e by default
This commit is contained in:
manuroe 2016-11-16 15:04:33 +01:00 committed by GitHub
commit 1a9c93bd74
2 changed files with 10 additions and 6 deletions

View file

@ -1262,6 +1262,9 @@ NSString *const kAppDelegateNetworkStatusDidChangeNotification = @"kAppDelegateN
- (void)initMatrixSessions - (void)initMatrixSessions
{ {
// Enable e2e encryption for newly created MXSession
[MXSDKOptions sharedInstance].enableCryptoWhenStartingMXSession = YES;
// Disable identicon use // Disable identicon use
[MXSDKOptions sharedInstance].disableIdenticonUseForUserAvatar = YES; [MXSDKOptions sharedInstance].disableIdenticonUseForUserAvatar = YES;

View file

@ -1404,9 +1404,6 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)();
UISwitch *switchButton = (UISwitch*)sender; UISwitch *switchButton = (UISwitch*)sender;
MXKAccount* account = [MXKAccountManager sharedManager].activeAccounts.firstObject; MXKAccount* account = [MXKAccountManager sharedManager].activeAccounts.firstObject;
// Turn off by default the flag which is used to enable automatically the encryption on new sessions.
[MXSDKOptions sharedInstance].enableCryptoWhenStartingMXSession = NO;
if (switchButton.isOn && !account.mxCredentials.deviceId.length) if (switchButton.isOn && !account.mxCredentials.deviceId.length)
{ {
// Prompt the user to log in again when no device id is available. // Prompt the user to log in again when no device id is available.
@ -1438,9 +1435,6 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)();
__strong __typeof(weakSelf)strongSelf = weakSelf; __strong __typeof(weakSelf)strongSelf = weakSelf;
strongSelf->currentAlert = nil; strongSelf->currentAlert = nil;
// Turn on encryption on new sessions after signing off
[MXSDKOptions sharedInstance].enableCryptoWhenStartingMXSession = YES;
switchButton.enabled = NO; switchButton.enabled = NO;
[strongSelf startActivityIndicator]; [strongSelf startActivityIndicator];
@ -1463,6 +1457,13 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)();
MXSession* session = [[AppDelegate theDelegate].mxSessions objectAtIndex:0]; MXSession* session = [[AppDelegate theDelegate].mxSessions objectAtIndex:0];
[session enableCrypto:switchButton.isOn success:^{ [session enableCrypto:switchButton.isOn success:^{
// When disabling crypto, reset the current device id as it cannot be reused.
// This means that the user will need to log in again if he wants to re-enable e2e.
if (!switchButton.isOn)
{
[account resetDeviceId];
}
// Reload all data source of encrypted rooms // Reload all data source of encrypted rooms
MXKRoomDataSourceManager *roomDataSourceManager = [MXKRoomDataSourceManager sharedManagerForMatrixSession:session]; MXKRoomDataSourceManager *roomDataSourceManager = [MXKRoomDataSourceManager sharedManagerForMatrixSession:session];