Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/gajim-plugins.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlovetox <philipp@hoerist.com>2022-04-16 21:48:16 +0300
committerlovetox <philipp@hoerist.com>2022-04-16 21:49:01 +0300
commitf6411db90819ed670e83c043c8f83d539319897c (patch)
tree11df367f189ef9e43eab71f816b26bb36a82c9dc /openpgp
parent52bf024ef5076002af0c9fe17f1a2b7fe05801e5 (diff)
[openpgp] Handle keys not suited for xmpp
Diffstat (limited to 'openpgp')
-rw-r--r--openpgp/backend/gpgme.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/openpgp/backend/gpgme.py b/openpgp/backend/gpgme.py
index 6a108eb..c75cc06 100644
--- a/openpgp/backend/gpgme.py
+++ b/openpgp/backend/gpgme.py
@@ -32,6 +32,13 @@ class KeyringItem:
self._key = key
self._uid = self._get_uid()
+ @property
+ def is_xmpp_key(self) -> bool:
+ try:
+ return self.jid is not None
+ except Exception:
+ return False
+
def _get_uid(self):
for uid in self._key.uids:
if uid.uid.startswith('xmpp:'):
@@ -55,7 +62,6 @@ class KeyringItem:
return hash(self.fingerprint)
-
class GPGME:
def __init__(self, jid, gnuhome):
self._jid = jid
@@ -109,7 +115,13 @@ class GPGME:
keys = []
with gpg.Context(**self._context_args) as context:
for key in context.keylist():
- keys.append(KeyringItem(key))
+ keyring_item = KeyringItem(key)
+ if not keyring_item.is_xmpp_key:
+ log.warning('Key not suited for xmpp: %s', key.fpr)
+ continue
+
+ keys.append(keyring_item)
+
return keys
def export_key(self, fingerprint):