aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2008-11-25 23:36:33 -0800
committerJeremy Kemper <jeremy@bitsweat.net>2008-11-25 23:36:33 -0800
commitd1213fa4024143edaa060ee0ed326d9d2fcbe919 (patch)
tree5fdd7fc3eb1e04db4c84e154db99eec684e02179 /activesupport
parent4073a6d0a2f5926e10f06fe1702db7b1b7a20751 (diff)
downloadrails-d1213fa4024143edaa060ee0ed326d9d2fcbe919.tar.gz
rails-d1213fa4024143edaa060ee0ed326d9d2fcbe919.tar.bz2
rails-d1213fa4024143edaa060ee0ed326d9d2fcbe919.zip
Rescue OpenSSL::Cipher::CipherError or OpenSSL::CipherError depending on which is present
Diffstat (limited to 'activesupport')
-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