Work around a race condition between server join and auth validation.

This commit is contained in:
Paul Chote
2018-10-29 21:52:05 +00:00
committed by abcdefg30
parent e42094625d
commit 4ea3e8382d

View File

@@ -168,7 +168,11 @@ namespace OpenRA
public string Sign(params string[] data) public string Sign(params string[] data)
{ {
if (State != LinkState.Linked) // If we don't have any keys, or we know for sure that they haven't been linked to the forum
// then we can't do much here. If we have keys but don't yet know if they have been linked to the
// forum (LinkState.CheckingLink or ConnectionFailed) then we sign to avoid blocking the main thread
// but accept that - if the cert is invalid - the server will reject the result.
if (State <= LinkState.Unlinked)
return null; return null;
return CryptoUtil.Sign(parameters, data.Where(x => !string.IsNullOrEmpty(x)).JoinWith(string.Empty)); return CryptoUtil.Sign(parameters, data.Where(x => !string.IsNullOrEmpty(x)).JoinWith(string.Empty));
@@ -176,7 +180,7 @@ namespace OpenRA
public string DecryptString(string data) public string DecryptString(string data)
{ {
if (State != LinkState.Linked) if (State <= LinkState.Unlinked)
return null; return null;
return CryptoUtil.DecryptString(parameters, data); return CryptoUtil.DecryptString(parameters, data);