[FIX] account_ebics - Report passphrase mismatch when checking keys

The keyring was built outside the try block, and fintech raises the
passphrase error from the EbicsKeyRing constructor: a wrong passphrase
showed a raw ValueError traceback instead of "Passphrase mismatch.".
When another keyring instance on the same file is still open in the
worker, fintech raises RuntimeError instead, which is now caught too.
This commit is contained in:
Jérémy Didderen authored and Didderen Jérémy committed 2026-11-08 23:46:00 +01:00
1 parent f4f40a6fe2
commit 07eb7b4e9b
1 file changed
+6 -4
+6 -4
View File
@@ -281,15 +281,17 @@ class EbicsUserID(models.Model):
"keys": self.ebics_keys_fn, "keys": self.ebics_keys_fn,
"passphrase": self.ebics_passphrase, "passphrase": self.ebics_passphrase,
} }
keyring = EbicsKeyRing(**keyring_params)
try: try:
keyring = EbicsKeyRing(**keyring_params)
# fintech <= 7.4.3 does not have a call to check if a # fintech <= 7.4.3 does not have a call to check if a
# passphrase matches with the value stored in the keyfile. # passphrase matches with the value stored in the keyfile.
# We get around this limitation as follows: # We get around this limitation as follows:
# Get user keys to check for valid passphrases # Get user keys to check for valid passphrases
# It will raise a ValueError on invalid passphrases # It will raise a ValueError on invalid passphrases,
keyring["#USER"] # or a RuntimeError when the keyring is already open
except ValueError as err: # noqa: F841 # in this process with another passphrase.
keyring["#USER"] # pylint: disable=pointless-statement
except (ValueError, RuntimeError) as err: # noqa: F841
raise UserError(self.env._("Passphrase mismatch.")) # noqa: B904 raise UserError(self.env._("Passphrase mismatch.")) # noqa: B904
elif self.state != "draft": elif self.state != "draft":
self.ebics_passphrase = False self.ebics_passphrase = False