From 803f23e45740c702ebc66f9741c0af564b54f3b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Touceda?= Date: Wed, 31 Jul 2013 15:07:24 -0300 Subject: Use the new API to import ascii armored key --- changes/bug_importascii | 3 +++ src/leap/mx/mail_receiver.py | 10 ++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 changes/bug_importascii diff --git a/changes/bug_importascii b/changes/bug_importascii new file mode 100644 index 0000000..902df95 --- /dev/null +++ b/changes/bug_importascii @@ -0,0 +1,3 @@ + o Use the new API to import a new ascii armored public key. Fixes + #3352. + o Add "incoming" index for ease of listing new email. \ No newline at end of file diff --git a/src/leap/mx/mail_receiver.py b/src/leap/mx/mail_receiver.py index b4e0d18..43925df 100644 --- a/src/leap/mx/mail_receiver.py +++ b/src/leap/mx/mail_receiver.py @@ -116,18 +116,20 @@ class MailReceiver(Service): if pubkey is None or len(pubkey) == 0: doc.content = { + "incoming": True, "_enc_scheme": EncryptionSchemes.NONE, "_enc_json": json.dumps(data) } return uuid, doc - def _ascii_to_openpgp_cb(gpg): + openpgp_key = None + with openpgp.temporary_gpgwrapper() as gpg: + gpg.import_keys(pubkey) key = gpg.list_keys().pop() - return openpgp._build_key_from_gpg(address, key, pubkey) - - openpgp_key = openpgp._safe_call(_ascii_to_openpgp_cb, pubkey) + openpgp_key = openpgp._build_key_from_gpg(address, key, pubkey) doc.content = { + "incoming": True, "_enc_scheme": EncryptionSchemes.PUBKEY, "_enc_json": openpgp.encrypt_asym(json.dumps(data), openpgp_key) -- cgit v1.2.3