]> source.dussan.org Git - redmine.git/commitdiff
Ruby 2.4: Fixed "key must be 32 bytes" error of OpenSSL::Cipher (#25048).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Thu, 2 Mar 2017 22:48:11 +0000 (22:48 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Thu, 2 Mar 2017 22:48:11 +0000 (22:48 +0000)
Patch by Go MAEDA.

git-svn-id: http://svn.redmine.org/redmine/trunk@16354 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/redmine/ciphering.rb

index 9257336a6272d66b39f86dba8e37b5c6a93540d7..3d9f9eeb7c1898a3656a4de5e722f7e2e9af2378 100644 (file)
@@ -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