{"record":{"id":"a4d9ecbe4bd1bdfe","repo":"nats-io/nats-server","slug":"expected-cert-match-to-be-a-valid-non-empty-stri","errorCode":null,"errorMessage":"expected 'cert_match' to be a valid non-empty string","messagePattern":"expected 'cert_match' to be a valid non-empty string","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/certstore/errors.go","lineNumber":69,"sourceCode":"\tErrFailedX509Extract = errors.New(\"unable to extract x509 from certificate\")\n\n\t// ErrBadMatchByType represents unknown CERT_MATCH_BY passed\n\tErrBadMatchByType = errors.New(\"cert match by type not implemented\")\n\n\t// ErrBadCertStore represents unknown CERT_STORE passed\n\tErrBadCertStore = errors.New(\"cert store type not implemented\")\n\n\t// ErrConflictCertFileAndStore represents ambiguous configuration of both file and store\n\tErrConflictCertFileAndStore = errors.New(\"'cert_file' and 'cert_store' may not both be configured\")\n\n\t// ErrBadCertStoreField represents malformed cert_store option\n\tErrBadCertStoreField = errors.New(\"expected 'cert_store' to be a valid non-empty string\")\n\n\t// ErrBadCertMatchByField represents malformed cert_match_by option\n\tErrBadCertMatchByField = errors.New(\"expected 'cert_match_by' to be a valid non-empty string\")\n\n\t// ErrBadCertMatchField represents malformed cert_match option\n\tErrBadCertMatchField = errors.New(\"expected 'cert_match' to be a valid non-empty string\")\n\n\t// ErrBadCaCertMatchField represents malformed cert_match option\n\tErrBadCaCertMatchField = errors.New(\"expected 'ca_certs_match' to be a valid non-empty string array\")\n\n\t// ErrBadCertMatchSkipInvalidField represents malformed cert_match_skip_invalid option\n\tErrBadCertMatchSkipInvalidField = errors.New(\"expected 'cert_match_skip_invalid' to be a boolean\")\n\n\t// ErrOSNotCompatCertStore represents cert_store passed that exists but is not valid on current OS\n\tErrOSNotCompatCertStore = errors.New(\"cert_store not compatible with current operating system\")\n)\n","sourceCodeStart":51,"sourceCodeEnd":80,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/certstore/errors.go#L51-L80","documentation":"ErrBadCertMatchField is a config-validation error raised when the cert_match option is not a string or is empty. cert_match holds the actual value (thumbprint, subject, etc.) used to find the certificate in the store, so it must be present and non-empty.","triggerScenarios":"server/opts.go:5294 — TLS config parsing: the cert_match value fails the string/non-empty check, returning &configErr{tk, certstore.ErrBadCertMatchField.Error()}; tc.CertMatch is only set once validation passes.","commonSituations":"Thumbprint pasted with surrounding whitespace removed wrongly, env var not set leaving an empty value, or config template rendering dropping the field.","solutions":["Provide the actual match value, e.g. cert_match: \"AB12CD34...\" (thumbprint without spaces, correct case per the matcher).","Verify any env substitution ($CERT_MATCH) resolves to a non-empty value in the server environment.","Quote the value in YAML/JSON to keep it a string.","Cross-check the value against `certutil -store My` output so it exactly matches an existing certificate."],"exampleFix":"// before\ncert_match: ${CERT_MATCH}   # unset\n// after\ncert_match: \"AB12CD34EF56...\"","handlingStrategy":"validation","validationCode":"if s, ok := cfg.TLS.CertMatch.(string); !ok || s == \"\" {\n    return errors.New(\"cert_match must be a non-empty string\")\n}","typeGuard":"func isBadCertMatchField(err error) bool { return errors.Is(err, certstore.ErrBadCertMatchField) }","tryCatchPattern":"if ce, ok := err.(*server.configErr); ok && strings.Contains(ce.Error(), \"cert_match\") {\n    // supply the thumbprint/subject value\n}","preventionTips":["Copy thumbprints exactly from certutil output, stripping spaces per matcher rules","Fail deployment when template/env substitution leaves cert_match empty","Re-check cert_match after every certificate renewal"],"tags":["configuration","tls","validation","certstore"],"backgroundTag":"invalid-config-value","analyzedSha":"3a66a489d262bf89b71a71c955c94920394532f3","analyzedAt":"2026-09-02T04:41:54.247Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}