public async Task <bool> Execute() { var jsonWebKeys = await _jsonWebKeyRepository.GetAllAsync(); if (jsonWebKeys == null || !jsonWebKeys.Any()) { return(false); } foreach (var jsonWebKey in jsonWebKeys) { var serializedRsa = string.Empty; if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { using (var provider = new RSACryptoServiceProvider()) { serializedRsa = provider.ToXmlStringNetCore(true); } } else { using (var rsa = new RSAOpenSsl()) { serializedRsa = rsa.ToXmlStringNetCore(true); } } jsonWebKey.SerializedKey = serializedRsa; await _jsonWebKeyRepository.UpdateAsync(jsonWebKey); } await _tokenStore.Clean().ConfigureAwait(false); return(true); }