From f86278aebd8129c3c01c38377589837a7e825ceb Mon Sep 17 00:00:00 2001 From: Matthias Valvekens Date: Sat, 23 Mar 2024 21:39:37 +0100 Subject: [PATCH] Increase resilience against oscrypto issues Guarding against ImportError is not good enough on systems with ossl3 only (which causes oscrypto to crash) --- pyhanko/pdf_utils/crypt/pubkey.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyhanko/pdf_utils/crypt/pubkey.py b/pyhanko/pdf_utils/crypt/pubkey.py index ba3afdec..ca1d9cf7 100644 --- a/pyhanko/pdf_utils/crypt/pubkey.py +++ b/pyhanko/pdf_utils/crypt/pubkey.py @@ -1102,11 +1102,11 @@ def read_seed_from_recipient_cms( 'rc2': symmetric.rc2_cbc_pkcs5_decrypt, } ) - except ImportError: # pragma: nocover + except Exception as e: # pragma: nocover if cipher_name in ('des', 'tripledes', 'rc2'): raise NotImplementedError( "DES, 3DES and RC2 require oscrypto to be present" - ) + ) from e if cipher_name in with_iv: decryption_fun = with_iv[cipher_name]