summaryrefslogtreecommitdiff
path: root/alot/db
diff options
context:
space:
mode:
authorPatrick Totzke <patricktotzke@gmail.com>2016-12-06 14:42:55 +0000
committerPatrick Totzke <patricktotzke@gmail.com>2016-12-06 14:42:55 +0000
commitca60765745907b827229d73acb4e637511c046ca (patch)
tree394c3d0622c67b56e454118c35ff48256946c620 /alot/db
parent30dfab46509ac54a918a056bcc890b45df9c2b6a (diff)
parent4228a904908a7acc2731ac543cc37c521fbe1f32 (diff)
Merge branch '0.3.8-feature-untrusted-signatures-858'
Diffstat (limited to 'alot/db')
-rw-r--r--alot/db/utils.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/alot/db/utils.py b/alot/db/utils.py
index 286e652e..373f96b1 100644
--- a/alot/db/utils.py
+++ b/alot/db/utils.py
@@ -42,9 +42,20 @@ def add_signature_headers(mail, sigs, error_msg):
error_msg = error_msg or 'no signature found'
else:
try:
- sig_from = crypto.get_key(sigs[0].fpr).uids[0].uid
+ key = crypto.get_key(sigs[0].fpr)
+ for uid in key.uids:
+ if crypto.check_uid_validity(key, uid.email):
+ sig_from = uid.uid
+ uid_trusted = True
+ break
+ else:
+ # No trusted uid found, we did not break but drop from the
+ # for loop.
+ uid_trusted = False
+ sig_from = key.uids[0].uid
except:
sig_from = sigs[0].fpr
+ uid_trusted = False
mail.add_header(
X_SIGNATURE_VALID_HEADER,
@@ -54,7 +65,9 @@ def add_signature_headers(mail, sigs, error_msg):
X_SIGNATURE_MESSAGE_HEADER,
u'Invalid: {0}'.format(error_msg)
if error_msg else
- u'Valid: {0}'.format(sig_from),
+ u'Valid: {0}'.format(sig_from)
+ if uid_trusted else
+ u'Untrusted: {0}'.format(sig_from)
)