{"record":{"id":"a8eb911a2b601c57","repo":"txthinking/brook","slug":"cert-must-be-with-absolute-path","errorCode":null,"errorMessage":"--cert must be with absolute path","messagePattern":"--cert must be with absolute path","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/brook/main.go","lineNumber":862,"sourceCode":"\t\t\tAction: func(c *cli.Context) error {\n\t\t\t\tif c.Bool(\"example\") {\n\t\t\t\t\tfmt.Println(\"brook wssserver --domainaddress domain.com:9999 --password hello\")\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t\tif c.String(\"domainaddress\") == \"\" || c.String(\"password\") == \"\" {\n\t\t\t\t\treturn cli.ShowSubcommandHelp(c)\n\t\t\t\t}\n\t\t\t\tif c.String(\"blockDomainList\") != \"\" && !strings.HasPrefix(c.String(\"blockDomainList\"), \"http://\") && !strings.HasPrefix(c.String(\"blockDomainList\"), \"https://\") && !filepath.IsAbs(c.String(\"blockDomainList\")) {\n\t\t\t\t\treturn errors.New(\"--blockDomainList must be with absolute path\")\n\t\t\t\t}\n\t\t\t\tif c.String(\"blockCIDR4List\") != \"\" && !strings.HasPrefix(c.String(\"blockCIDR4List\"), \"http://\") && !strings.HasPrefix(c.String(\"blockCIDR4List\"), \"https://\") && !filepath.IsAbs(c.String(\"blockCIDR4List\")) {\n\t\t\t\t\treturn errors.New(\"--blockCIDR4List must be with absolute path\")\n\t\t\t\t}\n\t\t\t\tif c.String(\"blockCIDR6List\") != \"\" && !strings.HasPrefix(c.String(\"blockCIDR6List\"), \"http://\") && !strings.HasPrefix(c.String(\"blockCIDR6List\"), \"https://\") && !filepath.IsAbs(c.String(\"blockCIDR6List\")) {\n\t\t\t\t\treturn errors.New(\"--blockCIDR6List must be with absolute path\")\n\t\t\t\t}\n\t\t\t\tif c.String(\"cert\") != \"\" && !filepath.IsAbs(c.String(\"cert\")) {\n\t\t\t\t\treturn errors.New(\"--cert must be with absolute path\")\n\t\t\t\t}\n\t\t\t\tif c.String(\"certkey\") != \"\" && !filepath.IsAbs(c.String(\"certkey\")) {\n\t\t\t\t\treturn errors.New(\"--certkey must be with absolute path\")\n\t\t\t\t}\n\t\t\t\tif c.String(\"blockDomainList\") != \"\" || c.String(\"blockCIDR4List\") != \"\" || c.String(\"blockCIDR6List\") != \"\" || len(c.StringSlice(\"blockGeoIP\")) != 0 {\n\t\t\t\t\tp, err := block.NewBlock(c.String(\"blockDomainList\"), c.String(\"blockCIDR4List\"), c.String(\"blockCIDR6List\"), c.StringSlice(\"blockGeoIP\"), c.Int(\"updateListInterval\"))\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\t\t\t\t\tp.TouchBrook()\n\t\t\t\t\tif c.Int(\"updateListInterval\") != 0 {\n\t\t\t\t\t\tg.Add(&runnergroup.Runner{\n\t\t\t\t\t\t\tStart: func() error {\n\t\t\t\t\t\t\t\tp.Update()\n\t\t\t\t\t\t\t\treturn nil\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tStop: func() error {\n\t\t\t\t\t\t\t\tp.Stop()","sourceCodeStart":844,"sourceCodeEnd":880,"githubUrl":"https://github.com/txthinking/brook/blob/5cd13ef3b1fb574e88ebf2c1b5d95f2ebe1342c8/cli/brook/main.go#L844-L880","documentation":"When --cert is provided to the brook server subcommand it must be an absolute path, because the TLS certificate file may be re-read by the running process and relative paths are cwd-dependent. If the flag is non-empty and filepath.IsAbs() returns false, validation returns this error immediately.","triggerScenarios":"Running `brook server` with --cert set to a relative path, e.g. --cert ./server.crt or --cert server.crt, together with --certkey.","commonSituations":"Setting up TLS for the server with certificate files in the launch directory; works when testing manually from that directory's parent assumptions but fails because brook demands absolute paths by design.","solutions":["Pass an absolute path: --cert /etc/brook/server.crt","Generate/locate with absolute paths: --cert \"$(realpath server.crt)\"","Ensure --certkey is also absolute, since it has the same requirement"],"exampleFix":"// before\nbrook server --cert server.crt --certkey server.key\n// after\nbrook server --cert /etc/brook/server.crt --certkey /etc/brook/server.key","handlingStrategy":"validation","validationCode":"if cert := flagValue; cert != \"\" && !filepath.IsAbs(cert) {\n    return fmt.Errorf(\"--cert must be an absolute path, got %q\", cert)\n}","typeGuard":"func isAbsPath(p string) bool { return filepath.IsAbs(p) }","tryCatchPattern":null,"preventionTips":["Always pass --cert and --certkey as absolute paths together","Generate certificates directly into an absolute directory","Run `brook server ... --help` review of path flags before scripting them"],"tags":["cli","go","tls","path-validation","brook"],"backgroundTag":"invalid-flag-value","analyzedSha":"5cd13ef3b1fb574e88ebf2c1b5d95f2ebe1342c8","analyzedAt":"2026-09-06T04:35:00.432Z","contentChangedAt":"2026-09-06T04:35:00.432Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}