From fbdb541bfc0fcbf2d9c92c785f0d8ff1fe98f68a Mon Sep 17 00:00:00 2001 From: Tulio Casagrande Date: Fri, 21 Apr 2017 17:20:03 -0300 Subject: [feat] send public key as attachment on every email Previously, we were sending the key attached as long as the contact hasn't replied back. But with new key replace scenarios, we need to updated the contact keyring with the new key. We can implement autocrypt or similar in the future, but for now, let's send the key attached on every email. --- src/leap/bitmask/mail/outgoing/service.py | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'src/leap') diff --git a/src/leap/bitmask/mail/outgoing/service.py b/src/leap/bitmask/mail/outgoing/service.py index 18d266ef..4f39691b 100644 --- a/src/leap/bitmask/mail/outgoing/service.py +++ b/src/leap/bitmask/mail/outgoing/service.py @@ -315,23 +315,14 @@ class OutgoingMail(object): emit_async(catalog.SMTP_START_ENCRYPT_AND_SIGN, self._from_address, "%s,%s" % (self._from_address, to_address)) - d = self._maybe_attach_key(origmsg, from_address, to_address) + d = self._attach_key(origmsg, from_address) d.addCallback(maybe_encrypt_and_sign) return d - def _maybe_attach_key(self, origmsg, from_address, to_address): + def _attach_key(self, origmsg, from_address): filename = "%s-email-key.asc" % (from_address,) - def attach_if_address_hasnt_encrypted(to_key): - # if the sign_used flag is true that means that we got an encrypted - # email from this address, because we conly check signatures on - # encrypted emails. In this case we don't attach. - # XXX: this might not be true some time in the future - if to_key.sign_used: - return origmsg - return get_key_and_attach(None) - - def get_key_and_attach(_): + def get_key_and_attach(): d = self._keymanager.get_key(from_address, fetch_remote=False) d.addCallback(attach_key) return d @@ -352,8 +343,9 @@ class OutgoingMail(object): msg.attach(keymsg) return msg - d = self._keymanager.get_key(to_address, fetch_remote=False) - d.addCallbacks(attach_if_address_hasnt_encrypted, get_key_and_attach) + self.log.info("Will send %s public key as an attachment." + % (from_address)) + d = get_key_and_attach() d.addErrback(lambda _: origmsg) return d -- cgit v1.2.3