test-pem

command
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 14, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

README

test-pem

Verify a GitHub App PEM private key by generating a JWT and calling the GitHub /app endpoint.

Purpose

Quickly confirm that:

  • The PEM file is valid and correctly formatted (PKCS#1 or PKCS#8)
  • The App ID matches the key
  • GitHub accepts the resulting JWT

Build

go build -o test-pem ./cmd/test-pem

Usage

./test-pem <pem-file> <app-id>

Arguments:

Argument Description
pem-file Path to the .pem private key
app-id GitHub App ID (numeric)

Example

$ ./test-pem github-app.pem 123456
✓ Read PEM file: github-app.pem (1674 bytes)
✓ Parsed RSA private key (size: 2048 bits)
✓ Generated JWT for App ID 123456

Contacting GitHub API...
Status: 200
✅ Authentication successful!

App info:
{"id":123456,"slug":"my-app","name":"My App",...}

Troubleshooting

Error Cause Fix
Failed to read PEM file File not found or unreadable Check path and permissions
Failed to parse RSA private key Not a valid PEM key Re-download from GitHub App settings
HTTP 401 App ID doesn't match key, or key is revoked Verify App ID; regenerate key if needed

Exit Codes

Code Meaning
0 Authentication succeeded
1 Any error (file, parse, network, auth)

Documentation

Overview

test-pem verifies a GitHub App PEM private key by generating a JWT and calling the GitHub API's /app endpoint. This confirms the key is valid, correctly formatted, and matches the App ID.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL