Skip to content

Commit cf64431

Browse files
authored
Fix: Rescue OpenSSL::Cipher::CipherError for unsupported cipher algorithms (#39)
## Summary Fix error handling in `JWE::Enc::Cipher.for` to properly catch unsupported cipher errors. ## Problem When an unsupported cipher algorithm is used, newer versions of OpenSSL raise `OpenSSL::Cipher::CipherError` instead of `RuntimeError`. This caused 6 test failures because the expected `JWE::NotImplementedError` was not being raised. ## Solution Added `OpenSSL::Cipher::CipherError` to the rescue clause alongside the existing `RuntimeError` to handle both cases.
1 parent f25bc2a commit cf64431

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

lib/jwe/enc/cipher.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module Cipher
77
class << self
88
def for(cipher_name)
99
OpenSSL::Cipher.new(cipher_name)
10-
rescue RuntimeError
10+
rescue RuntimeError, OpenSSL::Cipher::CipherError
1111
raise JWE::NotImplementedError.new("The version of OpenSSL linked to your Ruby does not support the cipher #{cipher_name}.")
1212
end
1313
end

0 commit comments

Comments
 (0)