diff options
author | Dylan Baker <baker.dylan.c@gmail.com> | 2018-03-05 14:38:01 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-05 14:38:01 -0800 |
commit | d863facd24edd03de19027895b21ced6e6fb9e8e (patch) | |
tree | a4f29ec460cafd3bab8ee6faef73d50f3349a12e /alot/crypto.py | |
parent | 2a8f3413038a79130e75564bcce8f226b8823e1a (diff) | |
parent | a8a4b7904f4f1b18a32665193d9dea98395af2ac (diff) |
Merge pull request #1158 from dcbaker/wip/fix-bad-signature-encrypted
crypto: Handle message that is encrypted, but the signature is invalid
Diffstat (limited to 'alot/crypto.py')
-rw-r--r-- | alot/crypto.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/alot/crypto.py b/alot/crypto.py index 4ebb72f7..34bdccb5 100644 --- a/alot/crypto.py +++ b/alot/crypto.py @@ -219,12 +219,15 @@ def decrypt_verify(encrypted): """ ctx = gpg.core.Context() try: - (plaintext, _, verify_result) = ctx.decrypt(encrypted, verify=True) + plaintext, _, verify_result = ctx.decrypt(encrypted, verify=True) + sigs = verify_result.signatures except gpg.errors.GPGMEError as e: raise GPGProblem(str(e), code=e.getcode()) - # what if the signature is bad? + except gpg.errors.BadSignatures as e: + plaintext, _, _ = ctx.decrypt(encrypted, verify=False) + sigs = e.result.signatures - return verify_result.signatures, plaintext + return sigs, plaintext def validate_key(key, sign=False, encrypt=False): |