JuliusBrussee/caveman · critical

production refuses =true: it disables chain and hostname…

Error message

production refuses %s=true: it disables chain and hostname verification, so any in-path party can read or forge telemetry — use %s instead

What it means

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.

Solutions

  1. Remove the skip-verify=true setting from the production environment.
  2. Set the server-name env var (e.g. CLICKHOUSE_TLS_SERVER_NAME) to match the server certificate's hostname.
  3. Or provide a CA bundle via the CA-file env var (CLICKHOUSE_CA_FILE) that signs the server's certificate.
  4. Fix the underlying cert problem (expired/mismatched/self-signed) rather than disabling verification.

Example fix

// before
CLICKHOUSE_TLS_SKIP_VERIFY=true
// after
CLICKHOUSE_TLS_SERVER_NAME=clickhouse.internal.example.com
CLICKHOUSE_CA_FILE=/etc/certs/internal-ca.pem
Defensive patterns

Strategy: validation

Validate before calling

if os.Getenv("CAVE_ENV") == "production" && envBool("CLICKHOUSE_TLS_SKIP_VERIFY") {
    return errors.New("remove skip-verify in production; set CLICKHOUSE_TLS_SERVER_NAME or CLICKHOUSE_CA_FILE instead")
}

Try / catch

if err := chhttp.ValidateProduction(logger); err != nil {
    if strings.Contains(err.Error(), "refuses") && strings.Contains(err.Error(), "skip") {
        logger.Error("insecure TLS setting in production", "err", err)
        os.Exit(1)
    }
    return err
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20). Data as JSON: /api/errors/a73c0b2a0e1666e6. Report an issue: GitHub.

Appendix: source

Thrown at shared/platform/chhttp/chhttp.go:123

// definitions of "prod" would let one gate fire while the other stayed asleep.
func production() bool {
	return env.IsProduction()
}

// tlsClientConfig builds the ClickHouse TLS configuration from the environment,
// or (nil, nil) when no CLICKHOUSE_TLS_* knob is set — in which case callers keep
// the stock transport (system roots, hostname verified against the URL host).
//
// It fails CLOSED: a prod skip-verify request, an unreadable CA file, or a CA
// file with no parseable certificate all return an error rather than quietly
// downgrading to the ambient trust store.
func tlsClientConfig() (*tls.Config, error) {
	serverName := strings.TrimSpace(env.String(serverNameEnv, ""))
	caFile := strings.TrimSpace(env.String(caFileEnv, ""))
	skipVerify := env.Bool(skipVerifyEnv, false)

	if skipVerify && production() {
		return 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)
	}
	if serverName == "" && caFile == "" && !skipVerify {
		return nil, nil
	}

	cfg := &tls.Config{
		MinVersion: tls.VersionTLS12,
		ServerName: serverName,
		// #nosec G402 -- refused in production above; non-prod only, and loudly
		// warned about by ValidateProduction at startup.
		InsecureSkipVerify: skipVerify,
	}
	if caFile != "" {
		roots, err := rootsWithCAFile(caFile)
		if err != nil {
			return nil, err
		}
		cfg.RootCAs = roots

View on GitHub (pinned to 3ee70a1026)