changeset 734617cd5463 in /home/hg/repos/gajim
author: Yann Leboulanger asterix@lagaule.org branches: gajim_0.16 details:http://hg.gajim.org/gajim?cmd=changeset;node=734617cd5463 description: Correctly check and handle the case when we don't trust our own key. Fixes #8122
diffstat:
src/common/connection.py | 5 +++-- src/common/gpg.py | 6 +++++- 2 files changed, 8 insertions(+), 3 deletions(-)
diffs (45 lines):
diff -r ef4172ee5b5a -r 734617cd5463 src/common/connection.py --- a/src/common/connection.py Sun Nov 01 14:01:45 2015 +0100 +++ b/src/common/connection.py Sun Nov 01 16:30:27 2015 +0100 @@ -320,7 +320,7 @@ always_trust) def _on_encrypted(output): msgenc, error = output - if error == 'NOT_TRUSTED': + if error.startswith( 'NOT_TRUSTED'): def _on_always_trust(answer): if answer: gajim.thread_interface(encrypt_thread, [msg, keyID, @@ -333,7 +333,8 @@ form_node, user_nick, keyID, attention, correction_msg, callback) gajim.nec.push_incoming_event(GPGTrustKeyEvent(None, - conn=self, keyID=keyID, callback=_on_always_trust)) + conn=self, keyID=error.split(' ')[-1], + callback=_on_always_trust)) else: self._message_encrypted_cb(output, type_, msg, msgtxt, original_message, fjid, resource, jid, xhtml, diff -r ef4172ee5b5a -r 734617cd5463 src/common/gpg.py --- a/src/common/gpg.py Sun Nov 01 14:01:45 2015 +0100 +++ b/src/common/gpg.py Sun Nov 01 16:30:27 2015 +0100 @@ -50,6 +50,7 @@ def encrypt(self, str_, recipients, always_trust=False): trust = always_trust if not trust: + # check if we trust all keys trust = True for key in recipients: if key not in self.always_trust: @@ -59,7 +60,10 @@ result = super(GnuPG, self).list_keys(keys=recipients) for key in result: if key['trust'] not in ('f', 'u'): - return '', 'NOT_TRUSTED' + if key['keyid'][-8:] not in self.always_trust: + return '', 'NOT_TRUSTED ' + key['keyid'][-8:] + else: + trust = True result = super(GnuPG, self).encrypt(str_, recipients, always_trust=trust, passphrase=self.passphrase)