From d558da1c875704b101dbb26d56e08cd0f6369d35 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Wed, 16 Nov 2022 09:34:09 +0000 Subject: Virtual host server name workaround --- federationapi/routing/keys.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'federationapi/routing') diff --git a/federationapi/routing/keys.go b/federationapi/routing/keys.go index 693f5b9f..8194c990 100644 --- a/federationapi/routing/keys.go +++ b/federationapi/routing/keys.go @@ -16,6 +16,7 @@ package routing import ( "encoding/json" + "net" "net/http" "time" @@ -190,7 +191,16 @@ func localKeys(cfg *config.FederationAPI, serverName gomatrixserverlib.ServerNam identity, err := cfg.Matrix.SigningIdentityFor(serverName) if err != nil { - return nil, err + // TODO: This is a bit of a hack because the Host header can contain a port + // number if it's specified in the well-known file. Try getting a signing + // identity without it to see if that helps. + var h string + if h, _, err = net.SplitHostPort(string(serverName)); err == nil { + identity, err = cfg.Matrix.SigningIdentityFor(gomatrixserverlib.ServerName(h)) + } + if err != nil { + return nil, err + } } keys.Raw, err = gomatrixserverlib.SignJSON( -- cgit v1.2.3