{"record":{"id":"bc2c6c42b05e939d","repo":"kubernetes/kops","slug":"unknown-format-for-certificate-q","errorCode":null,"errorMessage":"unknown format for Certificate: %q","messagePattern":"unknown format for Certificate: %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/pki/certificate.go","lineNumber":67,"sourceCode":"\t\t\td, err2 := base64.StdEncoding.DecodeString(s)\n\t\t\tif err2 == nil {\n\t\t\t\tr2, err2 := ParsePEMCertificate(d)\n\t\t\t\tif err2 == nil {\n\t\t\t\t\tklog.Warningf(\"used base64 decode of certificate\")\n\t\t\t\t\tr = r2\n\t\t\t\t\terr = nil\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif err != nil {\n\t\t\t\tklog.Infof(\"Invalid certificate data: %q\", string(b))\n\t\t\t\treturn fmt.Errorf(\"error parsing certificate: %v\", err)\n\t\t\t}\n\t\t}\n\t\t*c = *r\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown format for Certificate: %q\", string(b))\n}\n\nfunc (c *Certificate) MarshalJSON() ([]byte, error) {\n\tvar data bytes.Buffer\n\t_, err := c.WriteTo(&data)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error writing SSL certificate: %v\", err)\n\t}\n\treturn json.Marshal(data.String())\n}\n\nfunc ParsePEMCertificate(pemData []byte) (*Certificate, error) {\n\tcert, err := parsePEMCertificate(pemData)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tc := &Certificate{","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/pki/certificate.go#L49-L85","documentation":"Fires in Certificate.UnmarshalJSON when the JSON value is neither a PEM string nor base64-encoded PEM data — the unmarshal helper falls through its decode attempts and rejects the raw bytes as an unrecognized certificate encoding.","triggerScenarios":"Thrown at pkg/pki/certificate.go:67 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Store the certificate as a PEM string in the JSON field","If storing base64, ensure it is standard base64 of PEM data","Regenerate/serialize the certificate with kOps pki tooling so it emits PEM"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}