NServiceBus.RijndaelEncryptionService.DecryptUsingAllKeys C# (CSharp) Method

DecryptUsingAllKeys() private method

private DecryptUsingAllKeys ( NServiceBus.EncryptedValue encryptedValue ) : string
encryptedValue NServiceBus.EncryptedValue
return string
        string DecryptUsingAllKeys(EncryptedValue encryptedValue)
        {
            var cryptographicExceptions = new List<CryptographicException>();

            foreach (var key in decryptionKeys)
            {
                try
                {
                    return Decrypt(encryptedValue, key);
                }
                catch (CryptographicException exception)
                {
                    cryptographicExceptions.Add(exception);
                }
            }
            var message = $"Could not decrypt message. Tried {decryptionKeys.Count} keys.";
            throw new AggregateException(message, cryptographicExceptions);
        }