-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
--rotate-keys does nothing if using AWS KMS #145
Comments
I have also tried |
Reviewing the source code, it appears that the bug is here: Because I'm using the AWS keystore, I don't have a key_encrypting_key entry or a private_rsa_key entry in my cipher configuration. That said, I don't have any trouble calling SymmetricEncryption::KeyStore::Aws.generate_data_keys directly. |
To test my theory I added |
We moved to docker containers and found the config file to be too cumbersome. So instead of managing and storing the data encryption key in KMS directly we store it in encrypted form in the AWS System Manager Parameter store. The following code shows how to load the various keys using the Secret Config gem to access the AWS SSM Parameter Store: # Need to set the cipher before the application is loaded and gem files initialized
# to avoid warning about config file not present.
SecretConfig.configure("symmetric_encryption") do |config|
SymmetricEncryption.cipher =
SymmetricEncryption::Cipher.new(
key: config.fetch("key", encoding: :base64),
iv: config.fetch("iv", encoding: :base64),
version: config.fetch("version", type: :integer),
cipher_name: "aes-256-cbc"
)
end
# Older encryption keys
%w[old older oldest].each do |path|
next unless SecretConfig.key?("symmetric_encryption/#{path}/key")
SecretConfig.configure("symmetric_encryption/#{path}") do |config|
SymmetricEncryption.secondary_ciphers <<
SymmetricEncryption::Cipher.new(
key: config.fetch("key", encoding: :base64),
iv: config.fetch("iv", encoding: :base64),
version: config.fetch("version", type: :integer),
cipher_name: "aes-256-cbc"
)
end
end Then the keys can be updated as needed via Secret Config. new_key = SymmetricEncryption::Key.new(cipher_name: 'aes-256-cbc')
h = {
"key" => Base64.strict_encode64(new_key.key),
"iv" => Base64.strict_encode64(new_key.iv),
"version" => 1
}
puts h.to_yaml Update the version as needed, and then new keys and key rotation is simply administered directly via Secret Config. This approach removes the file We have found this approach much simpler, since it no longer requires any config file changes to handle key rotation etc. |
If someone is using KMS and wants the key rotation capability, we can pair on a PR to add that capability. |
Environment
Provide at least:
No stack trace. See output from gem CLI in screenshot.
Expected Behavior
After running
symmetric-encryption --rotate-keys --rolling-deploy --environments staging --app-name hiringthing
I expect to find a new cipher value in my config (config/symmetric-encryption.yml) and a new encrypted data key in my key path (~/.symmetric-encryption)Other than specifying an environment, this is the exact example at Step 1 here: http://encryption.rocketjob.io/key_rotation.html
Actual Behavior
I get a success message from the tool, but there are no new keys on my filesystem and the config file is not updated.
The text was updated successfully, but these errors were encountered: