Commit 820cec8c authored by Philipp Hörist's avatar Philipp Hörist

[openpgp] Bugfixes

- Parse datetime correctly and convert to int
- Query contact keys on openpgp activation
parent 37105a88
......@@ -382,6 +382,8 @@ class OpenPGP:
else:
from_jid = from_jid.getStripped()
log.info('Key list query received from %s', from_jid)
keylist = util.unpack_public_key_list(stanza, from_jid)
self.key_list_received(keylist, from_jid)
......
......@@ -98,6 +98,7 @@ class PGPKeylist(AbstractPEPModule):
raise StanzaMalformed('Invalid date timestamp: %s', date)
keylist.append(Key(attrs['v4-fingerprint'], int(timestamp)))
return keylist
def _notification_received(self, jid, keylist):
......
......@@ -27,6 +27,8 @@ from base64 import b64decode, b64encode
import nbxmpp
from nbxmpp import Node
from gajim.common.modules.date_and_time import parse_datetime
NS_OPENPGP = 'urn:xmpp:openpgp:0'
NS_OPENPGP_PUBLIC_KEYS = 'urn:xmpp:openpgp:0:public-keys'
NS_NOTIFY = NS_OPENPGP_PUBLIC_KEYS + '+notify'
......@@ -89,9 +91,17 @@ def unpack_public_key_list(stanza, from_jid):
return
date = attrs.get('date', None)
if date is None:
log.warning('No date in metadata')
return
timestamp = parse_datetime(date, epoch=True)
if timestamp is None:
log.warning('Invalid date timestamp: %s', date)
return
fingerprints.append(
Key(attrs['v4-fingerprint'], date))
Key(attrs['v4-fingerprint'], int(timestamp)))
return fingerprints
......
......@@ -145,6 +145,7 @@ class OpenPGPPlugin(GajimPlugin):
keys = app.connections[account].get_module('OpenPGP').get_keys(
jid, only_trusted=False)
if not keys:
con.get_module('OpenPGP').query_key_list(jid)
ErrorDialog(
_('No OpenPGP key'),
_('We didnt receive a OpenPGP key from this contact.'))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment