Skip to content

Commit 633ff25

Browse files
author
Kyle Baley
authored
Switch key headers (#381)
1 parent 5d0dbd3 commit 633ff25

4 files changed

Lines changed: 6 additions & 12 deletions

File tree

src/AcceptanceTests/When_using_Aes_without_incoming_key_identifier.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class RemoveKeyIdentifierHeaderMutator : IMutateIncomingTransportMessages
9191
{
9292
public Task MutateIncoming(MutateIncomingTransportMessageContext context)
9393
{
94-
context.Headers.Remove(EncryptionHeaders.AesKeyIdentifier);
94+
context.Headers.Remove(EncryptionHeaders.EncryptionKeyIdentifier);
9595
return Task.FromResult(0);
9696
}
9797
}

src/MessageProperty/AesEncryptionService.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public string Decrypt(EncryptedValue encryptedValue, IIncomingLogicalMessageCont
111111
{
112112
return DecryptUsingKeyIdentifier(encryptedValue, keyIdentifier);
113113
}
114-
Log.Warn($"Encrypted message has no '{EncryptionHeaders.AesKeyIdentifier}' header. Possibility of data corruption. Upgrade endpoints that send message with encrypted properties.");
114+
Log.Warn($"Encrypted message has no '{EncryptionHeaders.EncryptionKeyIdentifier}' header. Possibility of data corruption. Upgrade endpoints that send message with encrypted properties.");
115115
return DecryptUsingAllKeys(encryptedValue);
116116
}
117117

@@ -252,16 +252,15 @@ static bool IsValidKey(byte[] key)
252252
/// </summary>
253253
protected internal virtual void AddKeyIdentifierHeader(IOutgoingLogicalMessageContext context)
254254
{
255-
context.Headers[EncryptionHeaders.AesKeyIdentifier] = encryptionKeyIdentifier;
256-
context.Headers[EncryptionHeaders.RijndaelKeyIdentifier] = encryptionKeyIdentifier;
255+
context.Headers[EncryptionHeaders.EncryptionKeyIdentifier] = encryptionKeyIdentifier;
257256
}
258257

259258
/// <summary>
260259
/// Tries to locate an encryption key identifier from an incoming message.
261260
/// </summary>
262261
protected internal virtual bool TryGetKeyIdentifierHeader(out string keyIdentifier, IIncomingLogicalMessageContext context)
263262
{
264-
return context.Headers.TryGetValue(EncryptionHeaders.AesKeyIdentifier, out keyIdentifier);
263+
return context.Headers.TryGetValue(EncryptionHeaders.EncryptionKeyIdentifier, out keyIdentifier);
265264
}
266265

267266
/// <summary>

src/MessageProperty/EncryptionHeaders.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ public static class EncryptionHeaders
88
/// <summary>
99
/// The identifier to lookup the key to decrypt the encrypted data.
1010
/// </summary>
11-
public const string RijndaelKeyIdentifier = "NServiceBus.RijndaelKeyIdentifier";
12-
/// <summary>
13-
/// The AES identifier to lookup the key to decrypt the encrypted data.
14-
/// </summary>
15-
public const string AesKeyIdentifier = "NServiceBus.AesKeyIdentifier";
11+
public const string EncryptionKeyIdentifier = "NServiceBus.RijndaelKeyIdentifier";
1612
}
1713
}

src/Tests/ApprovalFiles/APIApprovals.Approve.approved.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ namespace NServiceBus.Encryption.MessageProperty
3939
}
4040
public static class EncryptionHeaders
4141
{
42-
public const string AesKeyIdentifier = "NServiceBus.AesKeyIdentifier";
43-
public const string RijndaelKeyIdentifier = "NServiceBus.RijndaelKeyIdentifier";
42+
public const string EncryptionKeyIdentifier = "NServiceBus.RijndaelKeyIdentifier";
4443
}
4544
public interface IEncryptionService
4645
{

0 commit comments

Comments
 (0)