summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/leap/mx/mail_receiver.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/leap/mx/mail_receiver.py b/src/leap/mx/mail_receiver.py
index 7c5a368..b8eb2ae 100644
--- a/src/leap/mx/mail_receiver.py
+++ b/src/leap/mx/mail_receiver.py
@@ -202,14 +202,22 @@ class MailReceiver(Service):
with openpgp.TempGPGWrapper(gpgbinary='/usr/bin/gpg') as gpg:
gpg.import_keys(pubkey)
key = gpg.list_keys().pop()
+
+ encryption_result = gpg.encrypt(
+ json.dumps(data, ensure_ascii=False),
+ key["fingerprint"],
+ symmetric=False)
+
+ if encryption_result.ok == False:
+ log.msg("_encrypt_message: Encryption Failed"
+ "Status: %r" % (encryption_result.status,))
+ return None
+
doc.content = {
self.INCOMING_KEY: True,
self.ERROR_DECRYPTING_KEY: False,
ENC_SCHEME_KEY: EncryptionSchemes.PUBKEY,
- ENC_JSON_KEY: str(gpg.encrypt(
- json.dumps(data, ensure_ascii=False),
- key["fingerprint"],
- symmetric=False))
+ ENC_JSON_KEY: str(encryption_result)
}
return doc