From ca9650452863be07afd7a1227797be598f1ab2d7 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 27 Aug 2022 20:10:38 +0100 Subject: [PATCH] Alternatives to #main-key See https://datatracker.ietf.org/doc/html/rfc6901#section-6 --- cache.py | 5 ++++- daemon.py | 2 +- person.py | 4 +++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/cache.py b/cache.py index e2bbe3c24..449fae5b2 100644 --- a/cache.py +++ b/cache.py @@ -147,7 +147,10 @@ def get_person_pub_key(base_dir: str, session, person_url: str, """ if not person_url: return None - person_url = person_url.replace('#main-key', '') + if '#/publicKey' in person_url: + person_url = person_url.replace('#/publicKey', '') + else: + person_url = person_url.replace('#main-key', '') users_paths = get_user_paths() for possible_users_path in users_paths: if person_url.endswith(possible_users_path + 'inbox'): diff --git a/daemon.py b/daemon.py index 5cf58f836..fdb5e5267 100644 --- a/daemon.py +++ b/daemon.py @@ -709,7 +709,7 @@ class PubServer(BaseHTTPRequestHandler): if signature_item.startswith('keyId='): if '"' in signature_item: key_id = signature_item.split('"')[1] - # remove #main-key + # remove #/main-key or #main-key if '#' in key_id: key_id = key_id.split('#')[0] return key_id diff --git a/person.py b/person.py index faeeef400..f39ee795a 100644 --- a/person.py +++ b/person.py @@ -921,7 +921,9 @@ def add_alternate_domains(actor_json: {}, domain: str, def person_lookup(domain: str, path: str, base_dir: str) -> {}: """Lookup the person for an given nickname """ - if path.endswith('#main-key'): + if path.endswith('#/publicKey'): + path = path.replace('#/publicKey', '') + elif path.endswith('#main-key'): path = path.replace('#main-key', '') # is this a shared inbox lookup? is_shared_inbox = False