2020-08-10 15:18:04 +02:00
|
|
|
package config
|
|
|
|
|
2020-08-11 14:21:26 +02:00
|
|
|
import "github.com/matrix-org/gomatrixserverlib"
|
|
|
|
|
2020-10-07 17:23:18 +02:00
|
|
|
type SigningKeyServer struct {
|
2020-08-10 15:18:04 +02:00
|
|
|
Matrix *Global `yaml:"-"`
|
|
|
|
|
2020-08-13 13:16:37 +02:00
|
|
|
InternalAPI InternalAPIOptions `yaml:"internal_api"`
|
2020-08-10 15:18:04 +02:00
|
|
|
|
2020-10-07 17:23:18 +02:00
|
|
|
// The SigningKeyServer database caches the public keys of remote servers.
|
2020-08-10 15:18:04 +02:00
|
|
|
// It may be accessed by the FederationAPI, the ClientAPI, and the MediaAPI.
|
|
|
|
Database DatabaseOptions `yaml:"database"`
|
|
|
|
|
|
|
|
// Perspective keyservers, to use as a backup when direct key fetch
|
|
|
|
// requests don't succeed
|
|
|
|
KeyPerspectives KeyPerspectives `yaml:"key_perspectives"`
|
2020-09-29 18:08:18 +02:00
|
|
|
|
|
|
|
// Should we prefer direct key fetches over perspective ones?
|
|
|
|
PreferDirectFetch bool `yaml:"prefer_direct_fetch"`
|
2020-08-10 15:18:04 +02:00
|
|
|
}
|
|
|
|
|
2020-10-07 17:23:18 +02:00
|
|
|
func (c *SigningKeyServer) Defaults() {
|
2020-08-13 13:16:37 +02:00
|
|
|
c.InternalAPI.Listen = "http://localhost:7780"
|
|
|
|
c.InternalAPI.Connect = "http://localhost:7780"
|
2020-08-10 15:18:04 +02:00
|
|
|
c.Database.Defaults()
|
2020-10-07 17:23:18 +02:00
|
|
|
c.Database.ConnectionString = "file:signingkeyserver.db"
|
2020-08-10 15:18:04 +02:00
|
|
|
}
|
|
|
|
|
2020-10-07 17:23:18 +02:00
|
|
|
func (c *SigningKeyServer) Verify(configErrs *ConfigErrors, isMonolith bool) {
|
|
|
|
checkURL(configErrs, "signing_key_server.internal_api.listen", string(c.InternalAPI.Listen))
|
|
|
|
checkURL(configErrs, "signing_key_server.internal_api.bind", string(c.InternalAPI.Connect))
|
|
|
|
checkNotEmpty(configErrs, "signing_key_server.database.connection_string", string(c.Database.ConnectionString))
|
2020-08-10 15:18:04 +02:00
|
|
|
}
|
2020-08-11 14:21:26 +02:00
|
|
|
|
|
|
|
// KeyPerspectives are used to configure perspective key servers for
|
|
|
|
// retrieving server keys.
|
|
|
|
type KeyPerspectives []KeyPerspective
|
|
|
|
|
|
|
|
type KeyPerspective struct {
|
|
|
|
// The server name of the perspective key server
|
|
|
|
ServerName gomatrixserverlib.ServerName `yaml:"server_name"`
|
|
|
|
// Server keys for the perspective user, used to verify the
|
|
|
|
// keys have been signed by the perspective server
|
|
|
|
Keys []KeyPerspectiveTrustKey `yaml:"keys"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type KeyPerspectiveTrustKey struct {
|
|
|
|
// The key ID, e.g. ed25519:auto
|
|
|
|
KeyID gomatrixserverlib.KeyID `yaml:"key_id"`
|
|
|
|
// The public key in base64 unpadded format
|
|
|
|
PublicKey string `yaml:"public_key"`
|
|
|
|
}
|