Commit ba141df5 authored by jplang's avatar jplang

Ruby 2.4: Fixed "key must be 32 bytes" error of OpenSSL::Cipher (#25048).

Patch by Go MAEDA.

git-svn-id: https://svn.redmine.org/redmine/trunk@16354 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 994e7ff4
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment