fix: move setting of field so that it's correctly passed to DS

This commit is contained in:
Jahziel Villasana-Espinoza 2024-05-29 11:02:40 -04:00
parent 5d40c4c352
commit 3da2f095c7

View file

@ -163,6 +163,14 @@ the way that the Fleet server works.
}
}
if len([]byte(config.Server.PrivateKey)) < 32 {
initFatal(errors.New("private key must be at least 32 bytes long"), "validate private key")
}
// We truncate to 32 bytes because AES-256 requires a 32 byte (256 bit) PK, but some
// infra setups generate keys that are longer than 32 bytes.
config.Server.PrivateKey = config.Server.PrivateKey[:32]
var ds fleet.Datastore
var carveStore fleet.CarveStore
var installerStore fleet.InstallerStore
@ -508,14 +516,6 @@ the way that the Fleet server works.
cancel()
}
if len([]byte(config.Server.PrivateKey)) < 32 {
initFatal(errors.New("private key must be at least 32 bytes long"), "validate private key")
}
// We truncate to 32 bytes because AES-256 requires a 32 byte (256 bit) PK, but some
// infra setups generate keys that are longer than 32 bytes.
config.Server.PrivateKey = config.Server.PrivateKey[:32]
appCfg, err := ds.AppConfig(context.Background())
if err != nil {
initFatal(err, "loading app config")