[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 committed 2026-10-27 23:02:51 +01:00
1 parent 8c7484acbf
commit ed0bf5d6ae
1 file changed
+6 -4
+6 -4
View File
@@ -281,15 +281,17 @@ class EbicsUserID(models.Model):
"keys": self.ebics_keys_fn,
"passphrase": self.ebics_passphrase,
}
keyring = EbicsKeyRing(**keyring_params)
try:
keyring = EbicsKeyRing(**keyring_params)
# fintech <= 7.4.3 does not have a call to check if a
# passphrase matches with the value stored in the keyfile.
# We get around this limitation as follows:
# Get user keys to check for valid passphrases
# It will raise a ValueError on invalid passphrases
keyring["#USER"]
except ValueError as err: # noqa: F841
# It will raise a ValueError on invalid passphrases,
# or a RuntimeError when the keyring is already open
# 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
elif self.state != "draft":
self.ebics_passphrase = False