Fixed: Error when reading ciphered text from the database without cipher key configured (#9552).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7780 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2011-11-11 14:04:33 +00:00
parent 981a6223e4
commit e9f9927534
2 changed files with 22 additions and 0 deletions
+8
View File
@@ -39,6 +39,10 @@ module Redmine
def decrypt_text(text)
if text && match = text.match(/\Aaes-256-cbc:(.+)\Z/)
if cipher_key.blank?
logger.error "Attempt to decrypt a ciphered text with no cipher key configured in config/configuration.yml" if logger
return text
end
text = match[1]
c = OpenSSL::Cipher::Cipher.new("aes-256-cbc")
e, iv = text.split("--").map {|s| Base64.decode64(s)}
@@ -56,6 +60,10 @@ module Redmine
key = Redmine::Configuration['database_cipher_key'].to_s
key.blank? ? nil : Digest::SHA256.hexdigest(key)
end
def logger
RAILS_DEFAULT_LOGGER
end
end
module ClassMethods