From: Jean-Philippe Lang Date: Thu, 2 Mar 2017 22:48:11 +0000 (+0000) Subject: Ruby 2.4: Fixed "key must be 32 bytes" error of OpenSSL::Cipher (#25048). X-Git-Tag: 3.4.0~285 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=eaf8fb9885e17e8f7755a2a3ac8d3d897c7f5469;p=redmine.git 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 --- 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