{"record":{"id":"6a38c80539ca4d24","repo":"caddyserver/caddy","slug":"not-a-valid-big-integer-s","errorCode":null,"errorMessage":"not a valid big integer: %s","messagePattern":"not a valid big integer: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/caddytls/certselection.go","lineNumber":207,"sourceCode":"// bigInt is a big.Int type that interops with JSON encodings as a string.\ntype bigInt struct{ big.Int }\n\nfunc (bi bigInt) MarshalJSON() ([]byte, error) {\n\treturn json.Marshal(bi.String())\n}\n\nfunc (bi *bigInt) UnmarshalJSON(p []byte) error {\n\tif string(p) == \"null\" {\n\t\treturn nil\n\t}\n\tvar stringRep string\n\terr := json.Unmarshal(p, &stringRep)\n\tif err != nil {\n\t\treturn err\n\t}\n\t_, ok := bi.SetString(stringRep, 10)\n\tif !ok {\n\t\treturn fmt.Errorf(\"not a valid big integer: %s\", p)\n\t}\n\treturn nil\n}\n\n// Interface guard\nvar _ caddyfile.Unmarshaler = (*CustomCertSelectionPolicy)(nil)\n","sourceCodeStart":189,"sourceCodeEnd":214,"githubUrl":"https://github.com/caddyserver/caddy/blob/50e54ee279aa1e504fe218ca49ab6ae16c100410/modules/caddytls/certselection.go#L189-L214","documentation":"Returned by bigInt.UnmarshalJSON when a serial_number value in a cert_selection policy is not parseable as a base-10 big integer. bigInt exists because certificate serial numbers exceed int64, so JSON values must be decimal strings; SetString(s, 10) failing means the string contains non-decimal characters (hex prefixes like 0x, colons, whitespace, or a JSON number that is a float).","triggerScenarios":"Setting \"serial_number\": \"0a:1b:2c...\" (colon-separated hex as printed by openssl), \"0x1234\", \"1234.0\", or an empty string in a CustomCertSelectionPolicy; also any value where json.Unmarshal into a string fails (e.g. a raw JSON object).","commonSituations":"Copying the serial from openssl x509 -text output (colon-separated hex) or from a cert viewer showing hex, into JSON config that expects decimal. Mismatch between how the tool displays serials and how Caddy parses them.","solutions":["Convert the serial to a plain decimal string: openssl x509 -serial -in cert.pem -noout then strip colons and convert hex to decimal, or use 'python3 -c \"print(int('A1B2...', 16))\"'","Ensure the value is a JSON string of digits only, no 0x prefix, colons, spaces, or sign","Validate config with 'caddy validate --config <file>' before deploying to catch this at load time"],"exampleFix":"// before\n{\"serial_number\": [\"6F:04:25:87\"]}\n\n// after (same serial as decimal)\n{\"serial_number\": [\"1866016647\"]}","handlingStrategy":"validation","validationCode":"// Validate serial strings before putting them in config\nfunc validSerialDecimal(s string) bool {\n\tif s == \"\" {\n\t\treturn false\n\t}\n\t_, ok := new(big.Int).SetString(s, 10)\n\treturn ok\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always convert openssl hex serials to decimal before config: python3 -c \"print(int('HEXSERIAL', 16))\"","Store serials in config as JSON strings of digits only — no 0x, colons, or spaces","Run 'caddy validate' on any config containing serial_number"],"tags":["caddy","tls","json","cert-selection","validation"],"backgroundTag":null,"analyzedSha":"50e54ee279aa1e504fe218ca49ab6ae16c100410","analyzedAt":"2026-08-15T09:20:21.641Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}