Allow multiple keys to be used for decrypting messages#11
Allow multiple keys to be used for decrypting messages#11armon merged 25 commits intohashicorp:masterfrom
Conversation
…. Added more tests.
|
This looks great! The only suggestion I have is to add an "internal" version of |
|
@armon Thanks, and good point. Maybe something like the updates I just pushed? Now whenever keys get modified using |
|
@ryanuber I think this is going in the right approach, but there are some questionable thread safety issues in here. I think there should honestly be a private member |
|
Sorry to nitpick on this! |
|
@armon no problem! You're right, I'll take another look tonight when I have more time. Thanks! |
…inside the keyring.
|
@armon, I added a mutex to the operations that read/write key data. I overhauled it a little and broke all of this stuff out into a I also added an |
|
Ok, I think I've got a decent amount of tests. @armon Maybe let's let this soak over the weekend. Let me know your thoughts whenever you have a few minutes. Thanks! |
|
Sorry things have been busy! This is definitely the right direction. I think we can kill |
|
@armon no problem, how often are things not busy? No rush at all, just let me know what you think whenever you have time to do a code review on this. I killed
|
|
Awesome work! LGTM! Thanks @ryanuber |
Allow multiple keys to be used for decrypting messages
For reliable key rotation to work, we need to support adding in encryption keys and then switching to them without removing the origin key. This would allow some time for all members to perform their key cut-over, and then remove the old key later on.
Here I have added a
config.SecretKeyslist, which tracks all keys memberlist currently knows about. We still have the originalconfig.SecretKey, which is the key that is used for encrypting messages.When a new key is installed, it is not immediately activated. This is to allow time for the new key to be distributed to all members. Once it is safe to start encrypting messages with the new key, a call to
UseSecretKeycan be made, passing in the key which should become the "active" key.When a message is received, we first try to decode it using the "active" key. Failing that, we iterate through each of our
config.SecretKeys(excluding the active key), and attempt to decrypt with each one until we get a success. If no keys work, then an error message is returned.The original interfaces are all still intact.