Message Body Encryption

Component: NServiceBus
This page targets a pre-release version. Pre-releases are subject to change and samples are not guaranteed to be fully functional.

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 Task MutateIncoming(MutateIncomingTransportMessageContext context)
        context.Body = context.Body.ToArray().Reverse().ToArray();
        return Task.CompletedTask;

    public Task MutateOutgoing(MutateOutgoingTransportMessageContext context)
        context.OutgoingBody = context.OutgoingBody.ToArray().Reverse().ToArray();
        return Task.CompletedTask;

The encrypting mutator must be injected via dependency injection:

endpointConfiguration.RegisterMessageMutator(new MessageEncryptor());


Related Articles

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

Last modified