diff --git a/activesupport/lib/active_support/message_encryptor.rb b/activesupport/lib/active_support/message_encryptor.rb index de2b4bee76e9c7a3eb2162882e99da4888b09593..347af9dc76110fba6d255452d4b69ba704315bc7 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 @@ def decrypt(encrypted_message) decrypted_data << cipher.final Marshal.load(decrypted_data) - rescue OpenSSL::CipherError, TypeError + rescue OpenSSLCipherError, TypeError raise InvalidMessage end @@ -66,4 +67,4 @@ def verifier MessageVerifier.new(@secret) end end -end \ No newline at end of file +end