fix(agent): fix agent host validatation and improve file path handling

This commit is contained in:
yusing
2025-03-29 16:44:16 +08:00
parent 392946fe33
commit be85633c32
3 changed files with 18 additions and 5 deletions

View File

@@ -131,7 +131,12 @@ func (cfg *AgentConfig) StartWithCerts(parent task.Parent, ca, crt, key []byte)
}
func (cfg *AgentConfig) Start(parent task.Parent) gperr.Error {
certData, err := os.ReadFile(certs.AgentCertsFilename(cfg.Addr))
filepath, ok := certs.AgentCertsFilepath(cfg.Addr)
if !ok {
return gperr.New("invalid agent host").Subject(cfg.Addr)
}
certData, err := os.ReadFile(filepath)
if err != nil {
return gperr.Wrap(err, "failed to read agent certs")
}