diff options
author | Konstantin Ryabitsev <konstantin.ryabitsev@linux.dev> | 2021-06-07 09:03:09 -0400 |
---|---|---|
committer | Konstantin Ryabitsev <konstantin.ryabitsev@linux.dev> | 2021-06-07 09:03:09 -0400 |
commit | 7b8d2354c2d4fcd9b769f75d7a1f76040949e7c4 (patch) | |
tree | afac5296d4f098dd32cba8d61810cc5ff529d261 | |
parent | 94280ffd71aa5e1da0c36a95e3ea0fac08bca839 (diff) | |
download | patatt-7b8d2354c2d4fcd9b769f75d7a1f76040949e7c4.tar.gz |
Catch NoKeyError before ValidationError
This was supposed to be fixed in d37d358c9ddd, but one of the last
things I did was to make NoKeyError overload ValidationError instead of
being its own exception. As a result, we stopped catching it properly,
unless we look for NoKeyError before everything else.
Signed-off-by: Konstantin Ryabitsev <konstantin.ryabitsev@linux.dev>
-rw-r--r-- | patatt/__init__.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/patatt/__init__.py b/patatt/__init__.py index 4a3c7bd..365ac5e 100644 --- a/patatt/__init__.py +++ b/patatt/__init__.py @@ -958,16 +958,16 @@ def validate_message(msgdata: bytes, sources: list, trim_body: bool = False) -> # Default keyring used keysrc = '(default keyring)/%s' % signkey attestations.append((RES_VALID, i, signtime, keysrc, algo, errors)) + except NoKeyError: + # Not in default keyring + errors.append('%s/%s no matching openpgp key found' % (i, s)) + attestations.append((RES_NOKEY, i, t, None, algo, errors)) except ValidationError: if keysrc is None: errors.append('failed to validate using default keyring') else: errors.append('failed to validate using %s' % keysrc) attestations.append((RES_BADSIG, i, t, keysrc, algo, errors)) - except NoKeyError: - # Not in default keyring - errors.append('%s/%s no matching openpgp key found' % (i, s)) - attestations.append((RES_NOKEY, i, t, None, algo, errors)) return attestations |