diff --git a/app/hkp/views.py b/app/hkp/views.py index 5436322697c129eff0f8f998f8989dc2da7528c9..304f032c3844fb2a5034e34b6b9c393e46ba71f1 100644 --- a/app/hkp/views.py +++ b/app/hkp/views.py @@ -18,11 +18,14 @@ def lookup(request): if search.startswith("0x"): search = search[2:] - key = get_object_or_404(models.PublicKey, keyid__endswith=search) - if not request.user.has_perm("pgp.view_publickey", key): + keys = models.PublicKey.objects.filter(keyid__endswith=search) + keys = [key for key in keys + if request.user.has_perm("pgp.view_publickey", key)] + if not keys: raise Http404() - response = HttpResponse(key.armor, content_type="application/pgp-keys") + response = HttpResponse("\n".join(k.armor for k in keys), + content_type="application/pgp-keys") response["Access-Control-Allow-Origin"] = "*" response["Access-Control-Allow-Methods"] = "GET, OPTIONS, HEAD" return response