aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/message_encryptor.rb7
1 files changed, 4 insertions, 3 deletions
diff --git a/activesupport/lib/active_support/message_encryptor.rb b/activesupport/lib/active_support/message_encryptor.rb
index de2b4bee76..347af9dc76 100644
--- a/activesupport/lib/active_support/message_encryptor.rb
+++ b/activesupport/lib/active_support/message_encryptor.rb
@@ -10,7 +10,8 @@ module ActiveSupport
# want users to be able to determine the value of the payload.
class MessageEncryptor
class InvalidMessage < StandardError; end
-
+ OpenSSLCipherError = OpenSSL::Cipher.const_defined?(:CipherError) ? OpenSSL::Cipher::CipherError : OpenSSL::CipherError
+
def initialize(secret, cipher = 'aes-256-cbc')
@secret = secret
@cipher = cipher
@@ -43,7 +44,7 @@ module ActiveSupport
decrypted_data << cipher.final
Marshal.load(decrypted_data)
- rescue OpenSSL::CipherError, TypeError
+ rescue OpenSSLCipherError, TypeError
raise InvalidMessage
end
@@ -66,4 +67,4 @@ module ActiveSupport
MessageVerifier.new(@secret)
end
end
-end \ No newline at end of file
+end