{"record":{"id":"4956a7b724305cd3","repo":"JuliusBrussee/caveman","slug":"s-load-system-certificate-pool-w","errorCode":null,"errorMessage":"%s: load system certificate pool: %w","messagePattern":"(.+?): load system certificate pool: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shared/platform/chhttp/chhttp.go","lineNumber":167,"sourceCode":"// Appending (rather than replacing) keeps a public managed endpoint verifiable\n// while a private CA is trusted for the internal one.\n//\n// The bundle is parsed block by block instead of via CertPool.AppendCertsFromPEM,\n// which reports success as soon as ONE certificate parses and silently drops the\n// rest. A secret mount that is truncated mid-bundle, or corrupt after the first\n// entry, would then be half-trusted: the endpoints whose issuer survived keep\n// verifying and the ones whose issuer was dropped fail later, at the first\n// telemetry flush, looking like a network fault. Any unusable certificate block —\n// or a trailing PEM header with no complete block behind it — fails the whole\n// bundle CLOSED at boot instead.\nfunc rootsWithCAFile(path string) (*x509.CertPool, error) {\n\tbundle, err := os.ReadFile(path)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"%s: %w\", caFileEnv, err)\n\t}\n\troots, err := x509.SystemCertPool()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"%s: load system certificate pool: %w\", caFileEnv, err)\n\t}\n\tadded := 0\n\trest := bundle\n\tfor {\n\t\tvar block *pem.Block\n\t\tblock, rest = pem.Decode(rest)\n\t\tif block == nil {\n\t\t\tbreak\n\t\t}\n\t\tif block.Type != \"CERTIFICATE\" {\n\t\t\tcontinue\n\t\t}\n\t\tcert, err := x509.ParseCertificate(block.Bytes)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"%s (%s): certificate %d is unparseable, so the bundle is incomplete and must not be half-trusted: %w\", caFileEnv, path, added+1, err)\n\t\t}\n\t\troots.AddCert(cert)\n\t\tadded++","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/766dce6b1394ebb56a3090748d5a0240a5aefb36/shared/platform/chhttp/chhttp.go#L149-L185","documentation":"rootsWithCAFile could not load the system certificate pool (x509.SystemCertPool failed) while building the combined trust roots for ClickHouse TLS. The CA bundle is appended to the system pool, so without the system half no valid configuration can be produced and the error fails closed.","triggerScenarios":"Thrown at shared/platform/chhttp/chhttp.go:167 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check OS certificate store availability and integrity on the host","Rebuild the container/base image if the system CA store is corrupted or missing"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"766dce6b1394ebb56a3090748d5a0240a5aefb36","analyzedAt":"2026-08-18T03:14:35.516Z","contentChangedAt":"2026-08-18T03:14:35.516Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}