{"record":{"id":"3861fb8a82e5f800","repo":"kubernetes/kops","slug":"error-encoding-public-key-w","errorCode":null,"errorMessage":"error encoding public key: %w","messagePattern":"error encoding public key: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/bootstrap/pkibootstrap/pkisigner.go","lineNumber":81,"sourceCode":"func NewAuthenticator(hostname string, signer crypto.Signer) (bootstrap.Authenticator, error) {\n\tkeyID, err := computeKeyID(signer)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &pkiAuthenticator{hostname: hostname, signer: signer, keyID: keyID}, nil\n}\n\nfunc computeKeyID(signer crypto.Signer) (string, error) {\n\tpublicKey := signer.Public()\n\tpkData, err := x509.MarshalPKIXPublicKey(publicKey)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"error converting public key to x509: %w\", err)\n\t}\n\n\tvar b bytes.Buffer\n\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}","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/bootstrap/pkibootstrap/pkisigner.go#L63-L99","documentation":"PEM-encoding the marshaled public key into an in-memory buffer failed while computing the signer's key ID. Encoding to a bytes.Buffer cannot realistically fail, so this is a defensive wrap; if observed it points to memory exhaustion or a non-standard key type.","triggerScenarios":"Thrown at pkg/bootstrap/pkibootstrap/pkisigner.go:81 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the wrapped error — an EOF from a bytes.Buffer is effectively impossible and indicates a bug","Verify the crypto.Signer was constructed with a standard key type (RSA, ECDSA, Ed25519)","Report as a bug if reproducible"],"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-12T12:17:11.808Z"}