Message Body Encryption

Component: NServiceBus
NuGet Package: NServiceBus (5.x)
Standard support for version 5.x of NServiceBus has expired. For more information see our Support Policy.

Message encryption leverages the pipeline to encrypt the entire serialized message body.

Data in the message headers is not encrypted.

One way of achieving this is by using a transport message mutator.

public class MessageEncryptor :
    public void MutateIncoming(TransportMessage transportMessage)
        transportMessage.Body = transportMessage.Body.Reverse().ToArray();

    public void MutateOutgoing(LogicalMessage logicalMessage, TransportMessage transportMessage)
        transportMessage.Body = transportMessage.Body.Reverse().ToArray();

The encrypting mutator must be injected via dependency injection:

    registration: components =>


Related Articles

  • Security
    Security features for messages, transports, and persisters.

Last modified