diff options
| author | Andrej Mihajlov <and@mullvad.net> | 2022-02-02 13:32:08 +0100 |
|---|---|---|
| committer | Andrej Mihajlov <and@mullvad.net> | 2022-02-02 17:37:00 +0100 |
| commit | 9b56d566d06126991fe3ad9ca5eb37cfcf12da58 (patch) | |
| tree | 82794c3923df37b236163fb2f3317887b572616e | |
| parent | 45fc06dbc4f9f2275fad59c0df14d40cfb1d76ce (diff) | |
| download | mullvadvpn-9b56d566d06126991fe3ad9ca5eb37cfcf12da58.tar.xz mullvadvpn-9b56d566d06126991fe3ad9ca5eb37cfcf12da58.zip | |
SetAccountOperation: always replace keys if next key is found
| -rw-r--r-- | ios/MullvadVPN/TunnelManager/SetAccountOperation.swift | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/ios/MullvadVPN/TunnelManager/SetAccountOperation.swift b/ios/MullvadVPN/TunnelManager/SetAccountOperation.swift index ee302f9f38..f20986d118 100644 --- a/ios/MullvadVPN/TunnelManager/SetAccountOperation.swift +++ b/ios/MullvadVPN/TunnelManager/SetAccountOperation.swift @@ -79,22 +79,21 @@ class SetAccountOperation: AsyncOperation { case .success(let tunnelSettings): let interfaceSettings = tunnelSettings.interface - // Push key if interface addresses were not received yet - if interfaceSettings.addresses.isEmpty { - if let newPrivateKey = interfaceSettings.nextPrivateKey { - replaceOldAccountKey( - accountToken: accountToken, - oldPrivateKey: interfaceSettings.privateKey, - newPrivateKey: newPrivateKey, - completionHandler: completionHandler - ) - } else { - pushNewAccountKey( - accountToken: accountToken, - publicKey: interfaceSettings.publicKey, - completionHandler: completionHandler - ) - } + if let newPrivateKey = interfaceSettings.nextPrivateKey { + // Replace key if key rotation had failed. + replaceOldAccountKey( + accountToken: accountToken, + oldPrivateKey: interfaceSettings.privateKey, + newPrivateKey: newPrivateKey, + completionHandler: completionHandler + ) + } else if interfaceSettings.addresses.isEmpty { + // Push key if interface addresses were not received yet + pushNewAccountKey( + accountToken: accountToken, + publicKey: interfaceSettings.publicKey, + completionHandler: completionHandler + ) } else { state.tunnelInfo = TunnelInfo( token: accountToken, |
