{"record":{"id":"e432f16658fc6952","repo":"kubernetes/kops","slug":"error-parsing-key-from-q-w","errorCode":null,"errorMessage":"error parsing key from %q: %w","messagePattern":"error parsing key from %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/bootstrap/pkibootstrap/pkisigner.go","lineNumber":98,"sourceCode":"\tif err := pem.Encode(&b, &pem.Block{Type: \"PUBLIC KEY\", Bytes: pkData}); err != nil {\n\t\treturn \"\", fmt.Errorf(\"error encoding public key: %w\", err)\n\t}\n\treturn b.String(), nil\n}\n\nfunc NewAuthenticatorFromFile(p string) (bootstrap.Authenticator, error) {\n\thostname, err := os.Hostname()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"couldn't determine hostname: %w\", err)\n\t}\n\n\tkeyBytes, err := os.ReadFile(p)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error reading %q: %w\", p, err)\n\t}\n\tkey, err := pki.ParsePEMPrivateKey(keyBytes)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error parsing key from %q: %w\", p, err)\n\t}\n\n\treturn NewAuthenticator(hostname, key.Key)\n}\n\nfunc (a *pkiAuthenticator) CreateToken(body []byte) (string, error) {\n\trequestHash := sha256.Sum256(body)\n\n\tdata := AuthTokenData{\n\t\tTimestamp:   time.Now().Unix(),\n\t\tAudience:    AudienceNodeAuthentication,\n\t\tRequestHash: requestHash[:],\n\n\t\tKeyID:    a.keyID,\n\t\tInstance: a.hostname,\n\t}\n\n\tpayload, err := json.Marshal(&data)","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/bootstrap/pkibootstrap/pkisigner.go#L80-L116","documentation":"The key file at the quoted path was read successfully but its contents are not a PEM-encoded private key recognized by pki.ParsePEMPrivateKey — wrong file, a certificate/public key instead of a private key, or an unexpected PEM block type.","triggerScenarios":"Thrown at pkg/bootstrap/pkibootstrap/pkisigner.go:98 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Confirm the file is a PEM private key (e.g. an 'EC PRIVATE KEY' or 'RSA PRIVATE KEY' block)","Regenerate the keypair and update the referenced file","Ensure the file was not truncated or otherwise corrupted"],"exampleFix":null,"handlingStrategy":"try-catch","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"}