Virtual host server name workaround

This commit is contained in:
Neil Alexander 2022-11-16 09:34:09 +00:00
parent deddf686b9
commit d558da1c87
No known key found for this signature in database
GPG Key ID: A02A2019A2BB0944

View File

@ -16,6 +16,7 @@ package routing
import (
"encoding/json"
"net"
"net/http"
"time"
@ -189,9 +190,18 @@ func localKeys(cfg *config.FederationAPI, serverName gomatrixserverlib.ServerNam
}
identity, err := cfg.Matrix.SigningIdentityFor(serverName)
if err != nil {
// 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(
string(identity.ServerName), identity.KeyID, identity.PrivateKey, toSign,