{"record":{"id":"a73c0b2a0e1666e6","repo":"JuliusBrussee/caveman","slug":"production-refuses-s-true-it-disables-chain-and","errorCode":null,"errorMessage":"production refuses %s=true: it disables chain and hostname verification, so any in-path party can read or forge telemetry — use %s instead","messagePattern":"production refuses (.+?)=true: it disables chain and hostname verification, so any in-path party can read or forge telemetry — use (.+?) instead","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"shared/platform/chhttp/chhttp.go","lineNumber":123,"sourceCode":"// definitions of \"prod\" would let one gate fire while the other stayed asleep.\nfunc production() bool {\n\treturn env.IsProduction()\n}\n\n// tlsClientConfig builds the ClickHouse TLS configuration from the environment,\n// or (nil, nil) when no CLICKHOUSE_TLS_* knob is set — in which case callers keep\n// the stock transport (system roots, hostname verified against the URL host).\n//\n// It fails CLOSED: a prod skip-verify request, an unreadable CA file, or a CA\n// file with no parseable certificate all return an error rather than quietly\n// downgrading to the ambient trust store.\nfunc tlsClientConfig() (*tls.Config, error) {\n\tserverName := strings.TrimSpace(env.String(serverNameEnv, \"\"))\n\tcaFile := strings.TrimSpace(env.String(caFileEnv, \"\"))\n\tskipVerify := env.Bool(skipVerifyEnv, false)\n\n\tif skipVerify && production() {\n\t\treturn nil, fmt.Errorf(\"production refuses %s=true: it disables chain and hostname verification, so any in-path party can read or forge telemetry — use %s instead\", skipVerifyEnv, serverNameEnv)\n\t}\n\tif serverName == \"\" && caFile == \"\" && !skipVerify {\n\t\treturn nil, nil\n\t}\n\n\tcfg := &tls.Config{\n\t\tMinVersion: tls.VersionTLS12,\n\t\tServerName: serverName,\n\t\t// #nosec G402 -- refused in production above; non-prod only, and loudly\n\t\t// warned about by ValidateProduction at startup.\n\t\tInsecureSkipVerify: skipVerify,\n\t}\n\tif caFile != \"\" {\n\t\troots, err := rootsWithCAFile(caFile)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tcfg.RootCAs = roots","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/shared/platform/chhttp/chhttp.go#L105-L141","documentation":"tlsClientConfig refuses to build a TLS config with skip-verify enabled when the process is in production, because disabling chain and hostname verification lets any in-path party read or forge telemetry. Production deployments must instead pin a server name or CA bundle. The error surfaces at boot/validation time.","triggerScenarios":"Setting the skip-verify env var (e.g. CLICKHOUSE_TLS_SKIP_VERIFY=true) while CAVE_ENV indicates production, then constructing a client (newQueryTransport/newInsertTransport) or calling ValidateProduction.","commonSituations":"Copying a dev/docker-compose TLS-loose config into a production deployment; toggling 'insecure: true' to work around a self-signed cert; infrastructure templates reusing staging env files.","solutions":["Remove the skip-verify=true setting from the production environment.","Set the server-name env var (e.g. CLICKHOUSE_TLS_SERVER_NAME) to match the server certificate's hostname.","Or provide a CA bundle via the CA-file env var (CLICKHOUSE_CA_FILE) that signs the server's certificate.","Fix the underlying cert problem (expired/mismatched/self-signed) rather than disabling verification."],"exampleFix":"// before\nCLICKHOUSE_TLS_SKIP_VERIFY=true\n// after\nCLICKHOUSE_TLS_SERVER_NAME=clickhouse.internal.example.com\nCLICKHOUSE_CA_FILE=/etc/certs/internal-ca.pem","handlingStrategy":"validation","validationCode":"if os.Getenv(\"CAVE_ENV\") == \"production\" && envBool(\"CLICKHOUSE_TLS_SKIP_VERIFY\") {\n    return errors.New(\"remove skip-verify in production; set CLICKHOUSE_TLS_SERVER_NAME or CLICKHOUSE_CA_FILE instead\")\n}","typeGuard":null,"tryCatchPattern":"if err := chhttp.ValidateProduction(logger); err != nil {\n    if strings.Contains(err.Error(), \"refuses\") && strings.Contains(err.Error(), \"skip\") {\n        logger.Error(\"insecure TLS setting in production\", \"err\", err)\n        os.Exit(1)\n    }\n    return err\n}","preventionTips":["Never set skip-verify in shared/env templates that reach production.","Ship an internal CA bundle and set the server-name env var as the standard prod TLS setup.","Run ValidateProduction at boot and fail loudly before serving traffic."],"tags":["tls","security","production","clickhouse"],"backgroundTag":"invalid-config-value","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}