diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2017-03-02 22:48:11 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2017-03-02 22:48:11 +0000 |
commit | eaf8fb9885e17e8f7755a2a3ac8d3d897c7f5469 (patch) | |
tree | 057fdb3f1f930e801a271084dec9a61073cd5de1 /lib | |
parent | df90907dc7faf76220ab031f4854c4c071b259a2 (diff) | |
download | redmine-eaf8fb9885e17e8f7755a2a3ac8d3d897c7f5469.tar.gz redmine-eaf8fb9885e17e8f7755a2a3ac8d3d897c7f5469.zip |
Ruby 2.4: Fixed "key must be 32 bytes" error of OpenSSL::Cipher (#25048).
Patch by Go MAEDA.
git-svn-id: http://svn.redmine.org/redmine/trunk@16354 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib')
-rw-r--r-- | lib/redmine/ciphering.rb | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/redmine/ciphering.rb b/lib/redmine/ciphering.rb index 9257336a6..3d9f9eeb7 100644 --- a/lib/redmine/ciphering.rb +++ b/lib/redmine/ciphering.rb @@ -26,7 +26,7 @@ module Redmine if cipher_key.blank? || text.blank? text else - c = OpenSSL::Cipher::Cipher.new("aes-256-cbc") + c = OpenSSL::Cipher.new("aes-256-cbc") iv = c.random_iv c.encrypt c.key = cipher_key @@ -44,7 +44,7 @@ module Redmine return text end text = match[1] - c = OpenSSL::Cipher::Cipher.new("aes-256-cbc") + c = OpenSSL::Cipher.new("aes-256-cbc") e, iv = text.split("--").map {|s| Base64.decode64(s)} c.decrypt c.key = cipher_key @@ -58,9 +58,9 @@ module Redmine def cipher_key key = Redmine::Configuration['database_cipher_key'].to_s - key.blank? ? nil : Digest::SHA256.hexdigest(key) + key.blank? ? nil : Digest::SHA256.hexdigest(key)[0..31] end - + def logger Rails.logger end @@ -84,8 +84,8 @@ module Redmine object.send :write_attribute, attribute, clear raise(ActiveRecord::Rollback) unless object.save(:validation => false) end - end - end ? true : false + end ? true : false + end end private |