[openpgp] Bugfixes

- Parse datetime correctly and convert to int
- Query contact keys on openpgp activation
This commit is contained in:
Philipp Hörist
2018-09-09 19:51:58 +02:00
parent 37105a881d
commit 820cec8cee
4 changed files with 15 additions and 1 deletions

View File

@@ -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)

View File

@@ -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):

View File

@@ -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