From 282839ec0941684a01db239f854538150e3d2fd0 Mon Sep 17 00:00:00 2001 From: ydah Date: Thu, 29 Jan 2026 22:58:17 +0900 Subject: [PATCH] Fix: Rescue OpenSSL::Cipher::CipherError for unsupported cipher algorithms ## 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. --- lib/jwe/enc/cipher.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jwe/enc/cipher.rb b/lib/jwe/enc/cipher.rb index 5c35e4f..0fced31 100644 --- a/lib/jwe/enc/cipher.rb +++ b/lib/jwe/enc/cipher.rb @@ -7,7 +7,7 @@ module Cipher class << self def for(cipher_name) OpenSSL::Cipher.new(cipher_name) - rescue RuntimeError + rescue RuntimeError, OpenSSL::Cipher::CipherError raise JWE::NotImplementedError.new("The version of OpenSSL linked to your Ruby does not support the cipher #{cipher_name}.") end end