Skip to content

Commit

Permalink
Merge pull request #5 from dnstapir/jws_verify_kid
Browse files Browse the repository at this point in the history
Verify JWS with kid
  • Loading branch information
jschlyter authored Jun 14, 2024
2 parents 3b3e914 + 7dff2a2 commit 2a931c9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion evrec/server.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import argparse
import asyncio
import json
import logging
import logging.config
import os
Expand Down Expand Up @@ -144,7 +145,12 @@ async def handle_payload(

def verify_jws_with_keys(jws: JWS, keys: JWKSet) -> JWK:
"""Verify JWS using keys and return key (or raise JWKeyNotFound)"""
for key in keys:
protected_header = json.loads(jws.objects["protected"])
if kid := protected_header.get("kid"):
logger.debug("Signature by kid=%s", kid)
else:
logger.debug("Signature by unknown key")
for key in keys.get_keys(kid) or keys:
try:
jws.verify(key=key)
return key
Expand Down

0 comments on commit 2a931c9

Please sign in to comment.