nyusti / MassTransit-Encryption

Transparent encryption support for MassTransit built on Azure Key Vault
0 stars 0 forks source link

Deserialization failure due to missing encryptiondata header #4

Open wokket opened 7 years ago

wokket commented 7 years ago

G'day mate,

I've just tried to use your library and it's working great for serialization 👍.

I wired up deserialization and received JSON errors due to the encryptiondata header not making it onto the bus:

image

Before I start chasing up the MassTransit team about why the header isn't making it from the SendContext onto the message would you mind confirming that this library is meant to be production ready. and that you're using it in anger?

Thanks, Tim

wokket commented 7 years ago

@nyusti Sorry to chase mate but I'm keen to get this sorted! Do you expect this library to be production ready or is it work in progress?

nyusti commented 7 years ago

Hi,

Sorry for the late answer. Yes it should be production ready, but I only used it with Azure Service Bus yet. Yes, looks like the encryption metadata is missing. Let me check this today.

nyusti commented 7 years ago

Made some tests with Azure Service Bus and it looks okay to me. Are you using RabbitMQ?

wokket commented 7 years ago

Yes, we're using RabbitMQ.

nyusti commented 7 years ago

Yes, looks like this is a limitation or an issue in the MassTransit. The InMemoryBus implementation won't work as well. I assumed that if it's working for Azure Service Bus it should work for the others as well. I'll report this issue to the MassTransit guys.

nyusti commented 7 years ago

I've tried to contact the MassTransit guys, but did not get any usable reply so I opened an issue on their side. Until this is solved, this code will only work for Azure Service Bus. Sorry for that.

phatboyg commented 7 years ago

So from what I can see, the headers are actually present if it's a string:

RabbitMQ: https://github.com/MassTransit/MassTransit/blob/develop/src/MassTransit.RabbitMqTransport/Transport/RabbitMqSendTransport.cs#L75

ServiceBus: https://github.com/MassTransit/MassTransit/blob/develop/src/MassTransit.AzureServiceBusTransport/Transport/ServiceBusSendTransport.cs#L102

In memory doesn't really have a transport, so there are no transport headers, so it isn't a surprise they don't work there. Your in-memory unit tests shouldn't use your serializer, or I can try to add transport header support to the in-memory fabric that is in the develop branch.

nyusti commented 7 years ago

The value is a JSON string. I've added a test around it using RabbitMQ and could reproduce the problem.

https://github.com/nyusti/MassTransit-Encryption/blob/master/src/Nyusti.MassTransitEncryption.Test.Unit/KeyVaultEncryptionOnRabbitMqBusTest.cs#L29

I've set up a local RabbitMQ instance, and published a sample message, like in the other tests. In the receive context six headers were visible but not mine.

I saw a test, where the header is set when publishing. Is this working? https://github.com/MassTransit/MassTransit/blob/develop/src/MassTransit.RabbitMqTransport.Tests/Encrypted_Specs.cs#L46