{"id":"5619492f779ee8cb","repo":"docker/cli","slug":"unable-to-read-public-key-from-file-w","errorCode":null,"errorMessage":"unable to read public key from file: %w","messagePattern":"unable to read public key from file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/docker-trust/trust/signer_add.go","lineNumber":121,"sourceCode":"\t\t}\n\t}\n\n\tnewSignerRoleName := data.RoleName(path.Join(data.CanonicalTargetsRole.String(), signerName))\n\n\tif err := addStagedSigner(notaryRepo, newSignerRoleName, signerPubKeys); err != nil {\n\t\treturn fmt.Errorf(\"could not add signer to repo: %s: %w\", strings.TrimPrefix(newSignerRoleName.String(), \"targets/\"), err)\n\t}\n\n\treturn notaryRepo.Publish()\n}\n\nfunc ingestPublicKeys(pubKeyPaths []string) ([]data.PublicKey, error) {\n\tpubKeys := []data.PublicKey{}\n\tfor _, pubKeyPath := range pubKeyPaths {\n\t\t// Read public key bytes from PEM file, limit to 1 KiB\n\t\tpubKeyFile, err := os.OpenFile(pubKeyPath, os.O_RDONLY, 0o666)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"unable to read public key from file: %w\", err)\n\t\t}\n\t\tdefer pubKeyFile.Close()\n\t\t// limit to\n\t\tl := io.LimitReader(pubKeyFile, 1<<20)\n\t\tpubKeyBytes, err := io.ReadAll(l)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"unable to read public key from file: %w\", err)\n\t\t}\n\n\t\t// Parse PEM bytes into type PublicKey\n\t\tpubKey, err := tufutils.ParsePEMPublicKey(pubKeyBytes)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"could not parse public key from file: %s: %w\", pubKeyPath, err)\n\t\t}\n\t\tpubKeys = append(pubKeys, pubKey)\n\t}\n\treturn pubKeys, nil\n}","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/cmd/docker-trust/trust/signer_add.go#L103-L139","documentation":"Error \"unable to read public key from file: %w\" thrown in docker/cli.","triggerScenarios":"Thrown at cmd/docker-trust/trust/signer_add.go:121 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"e9452d6e785f6e365712b9d71bd7517591773c86","analyzedAt":"2026-08-01T07:09:22.474Z","schemaVersion":2}