mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-16 10:33:11 -06:00
Change order of checks
This commit is contained in:
parent
9b48180fb5
commit
2c0284fff5
|
|
@ -233,19 +233,7 @@ func loadConfig(
|
||||||
|
|
||||||
for _, key := range c.Global.OldVerifyKeys {
|
for _, key := range c.Global.OldVerifyKeys {
|
||||||
switch {
|
switch {
|
||||||
case key.KeyID == "":
|
case key.PrivateKeyPath != "":
|
||||||
return nil, fmt.Errorf("key ID must be specified if public_key is specified")
|
|
||||||
|
|
||||||
case len(key.PublicKey) == ed25519.PublicKeySize:
|
|
||||||
continue
|
|
||||||
|
|
||||||
case len(key.PublicKey) > 0:
|
|
||||||
return nil, fmt.Errorf("the public_key is the wrong length")
|
|
||||||
|
|
||||||
case key.PrivateKeyPath == "":
|
|
||||||
return nil, fmt.Errorf("a private_key path must be specified if public_key isn't")
|
|
||||||
|
|
||||||
default:
|
|
||||||
var oldPrivateKeyData []byte
|
var oldPrivateKeyData []byte
|
||||||
oldPrivateKeyPath := absPath(basePath, key.PrivateKeyPath)
|
oldPrivateKeyPath := absPath(basePath, key.PrivateKeyPath)
|
||||||
oldPrivateKeyData, err = readFile(oldPrivateKeyPath)
|
oldPrivateKeyData, err = readFile(oldPrivateKeyPath)
|
||||||
|
|
@ -264,6 +252,18 @@ func loadConfig(
|
||||||
key.KeyID = keyID
|
key.KeyID = keyID
|
||||||
key.PrivateKey = privateKey
|
key.PrivateKey = privateKey
|
||||||
key.PublicKey = privateKey.Public().(gomatrixserverlib.Base64Bytes)
|
key.PublicKey = privateKey.Public().(gomatrixserverlib.Base64Bytes)
|
||||||
|
|
||||||
|
case len(key.PublicKey) == ed25519.PublicKeySize:
|
||||||
|
continue
|
||||||
|
|
||||||
|
case len(key.PublicKey) > 0:
|
||||||
|
return nil, fmt.Errorf("the supplied 'public_key' is the wrong length")
|
||||||
|
|
||||||
|
case key.KeyID == "":
|
||||||
|
return nil, fmt.Errorf("'key_id' must be specified if 'public_key' is specified")
|
||||||
|
|
||||||
|
default:
|
||||||
|
return nil, fmt.Errorf("either specify a 'private_key' path or supply both 'public_key' and 'key_id'")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue