Where do you put an encryption key on a public facing server?
I am using NServiceBus with MSMQ between my web application and service and I need to be able to encrypt the message payload so that i开发者_开发知识库f a message gets queued locally on the web server (service host is down) that sensitive data can't be viewed.
Because the web server is public facing, I am not only required to encrypt data that may be serialized to disk in anyway, but I also cannot store the encryption key on the web server.
I've considered using DPAPI to store the key, but since the key would be stored on the host I don't know yet if that runs afoul of the requirement or not. The other option I have considered is that when the web application starts it could request the key from a service and hold it in memory for the life of the application pool.
I haven't had to work with this level of requirement on encryption before and would like to find out what others are doing and get some feedback on the ideas mentioned above.
Can you use public/private key encryption? Then you only need to public key on the server, and the data is decrypted using the private key elsewhere.
"Because the web server is public facing, I am not only required to encrypt data that may be serialized to disk in anyway, but I also cannot store the encryption key on the web server."
Seems like this is the only constraint to focus on - validate that it is true for starters. It'll rule out DPAPI + local key-store approaches.
It's plausible to deliver the key by service, but that service still has to authenticate the caller. If your server is compromised masquerading as a legitimate caller, observing the call etc. are all possible. In addition if you stored the key only in-memory, that memory is still discoverable in a debugger or memory dump, elevated privilage process etc.
Hardware encryption cards are the only way to overcome the latter scenarios.
You can override the source from which NServiceBus pulls its encryption key - this is described in the docs here: http://docs.particular.net/nservicebus/security/encryption
This way, you can avoid having this sensitive information reside out on the DMZ.
The best place to encrypt is at the queue level. You do this by sending private messages and creating queues that only accept private messages. While you can set the queue privacy level when you create the queue at creation time, I'm not sure if you can configure NServiceBus to send private messages.
精彩评论