A script to update encrypted secrets to use improved encryption.
# Download this to your Rails app directory and run with: | |
# bin/rails runner upgrade_encrypted_secrets.rb | |
# Everything below here is private API and not something your app should use. | |
Rails::Secrets.singleton_class.prepend Module.new { | |
def decrypt(data) | |
cipher = OpenSSL::Cipher.new("aes-256-cbc").decrypt | |
cipher.key = key | |
cipher.update(data) << cipher.final | |
end | |
} | |
puts "Generating a new higher entropy encryption key in config/secrets.yml.key." | |
puts "Rotate the encryption key now." | |
decrypted_secrets = Rails::Secrets.read | |
File.binwrite("config/secrets.yml.key", Rails::Secrets.generate_key) | |
Rails::Secrets.write(decrypted_secrets) |
This comment has been minimized.
This comment has been minimized.
Hi All, Thank you, |
This comment has been minimized.
This comment has been minimized.
@freshcandidate Hi there! This file is aimed for advanced users for Rails. If you want to have a shot at Ruby with Rails. I suggest you take this following courses here and here. Good luck! |
This comment has been minimized.
This comment has been minimized.
@mdesantis the script assumes that you've setup encrypted secrets, otherwise there's nothing to upgrade and you don't need to run the script :) |
This comment has been minimized.
This comment has been minimized.
Hi, I got this:
|
This comment has been minimized.
This comment has been minimized.
Hi, I am getting this error regarding RAILS_MASTER_KEY. This is the same issue that I am having when I deploy on heroku.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
I get this error: