summary refs log tree commit diff
path: root/synapse/crypto/keyring.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-05-19 11:56:35 +0100
committerErik Johnston <erik@matrix.org>2015-05-19 11:56:35 +0100
commit01858bcbf2b59f3230e942a714f0c181cc8d9a06 (patch)
tree2a768ddf003402fbfc3fba1544325d30501f3da1 /synapse/crypto/keyring.py
parentMerge branch 'develop' of github.com:matrix-org/synapse into erikj/join_perf (diff)
parentSYN-383: Fix parsing of verify_keys and catching of _DefGen_Return (diff)
downloadsynapse-01858bcbf2b59f3230e942a714f0c181cc8d9a06.tar.xz
Merge branch 'develop' of github.com:matrix-org/synapse into erikj/join_perf
Diffstat (limited to 'synapse/crypto/keyring.py')
-rw-r--r--synapse/crypto/keyring.py36
1 files changed, 18 insertions, 18 deletions
diff --git a/synapse/crypto/keyring.py b/synapse/crypto/keyring.py
index c7e47f6bf9..c626f78f4b 100644
--- a/synapse/crypto/keyring.py
+++ b/synapse/crypto/keyring.py
@@ -129,23 +129,24 @@ class Keyring(object):
     def _get_server_verify_key_impl(self, server_name, key_ids):
         keys = None
 
-        perspective_results = []
-        for perspective_name, perspective_keys in self.perspective_servers.items():
-            @defer.inlineCallbacks
-            def get_key():
-                try:
-                    result = yield self.get_server_verify_key_v2_indirect(
-                        server_name, key_ids, perspective_name, perspective_keys
-                    )
-                    defer.returnValue(result)
-                except:
-                    logging.info(
-                        "Unable to getting key %r for %r from %r",
-                        key_ids, server_name, perspective_name,
-                    )
-            perspective_results.append(get_key())
+        @defer.inlineCallbacks
+        def get_key(perspective_name, perspective_keys):
+            try:
+                result = yield self.get_server_verify_key_v2_indirect(
+                    server_name, key_ids, perspective_name, perspective_keys
+                )
+                defer.returnValue(result)
+            except Exception as e:
+                logging.info(
+                    "Unable to getting key %r for %r from %r: %s %s",
+                    key_ids, server_name, perspective_name,
+                    type(e).__name__, str(e.message),
+                )
 
-        perspective_results = yield defer.gatherResults(perspective_results)
+        perspective_results = yield defer.gatherResults([
+            get_key(name, keys)
+            for name, keys in self.perspective_servers.items()
+        ])
 
         for results in perspective_results:
             if results is not None:
@@ -311,9 +312,8 @@ class Keyring(object):
         time_now_ms = self.clock.time_msec()
         response_keys = {}
         verify_keys = {}
-        for key_id, key_data in response_json["verify_keys"].items():
+        for key_id, key_base64 in response_json["verify_keys"].items():
             if is_signing_algorithm_supported(key_id):
-                key_base64 = key_data["key"]
                 key_bytes = decode_base64(key_base64)
                 verify_key = decode_verify_key_bytes(key_id, key_bytes)
                 verify_key.time_added = time_now_ms