on master help sign in
Simplify federation signature verification: remove re-fetch retry, assume persistent keys
765edfeiko
server.knot+1−9
@@ -3985,8 +3985,6 @@ fetchAndCachePeerKey = \server t -> do
3985-- Verify an inbound Ed25519 signed federation request.
3985-- Verify an inbound Ed25519 signed federation request.
3986-- Reconstructs the signed message from (scope, requestTimestamp, fromServer),
3986-- Reconstructs the signed message from (scope, requestTimestamp, fromServer),
3987-- fetches the peer's public key (cached), and verifies the signature.
3987-- fetches the peer's public key (cached), and verifies the signature.
3988−-- On verification failure, re-fetches the key once (handles peer key rotation
3989−-- or restart with new key) and retries before rejecting.
3990verifyFederationSignature : Text -> Text -> Text -> Timestamp -> IO {network} Bool
3988verifyFederationSignature : Text -> Text -> Text -> Timestamp -> IO {network} Bool
3991verifyFederationSignature = \fromServer signatureHex scope requestTimestamp -> do
3989verifyFederationSignature = \fromServer signatureHex scope requestTimestamp -> do
3992 t <- now
3990 t <- now
@@ -3994,13 +3992,7 @@ verifyFederationSignature = \fromServer signatureHex scope requestTimestamp -> d
3994 if pubkeyHex == "" then yield (False {})
3992 if pubkeyHex == "" then yield (False {})
3995 else do
3993 else do
3996 let message = textToBytes (scope ++ "|" ++ show requestTimestamp ++ "|" ++ fromServer)
3994 let message = textToBytes (scope ++ "|" ++ show requestTimestamp ++ "|" ++ fromServer)
3997− let sigValid = verify (bytesFromHex pubkeyHex) message (bytesFromHex signatureHex)
3998− if sigValid then yield (True {})
3999− else do
4000− -- Key may be stale (peer restarted with new key). Re-fetch once and retry.
4001− refetched <- fetchAndCachePeerKey fromServer t
4002− if refetched == "" || refetched == pubkeyHex then yield (False {})
4003− else yield (verify (bytesFromHex refetched) message (bytesFromHex signatureHex))
3995+ yield (verify (bytesFromHex pubkeyHex) message (bytesFromHex signatureHex))
4004
3996
4005-- Federation auth wrapper. Intentionally does NOT call checkPreAuth because:
3997-- Federation auth wrapper. Intentionally does NOT call checkPreAuth because:
4006-- (a) Soft drain (phase 1) blocks new client auth but must not block federation —
3998-- (a) Soft drain (phase 1) blocks new client auth but must not block federation —