Skip to content

Instantly share code, notes, and snippets.

@KunalKumarSwift
Created January 10, 2025 02:31
Show Gist options
  • Save KunalKumarSwift/3020edd26447f31105b52e4af09e8fb6 to your computer and use it in GitHub Desktop.
Save KunalKumarSwift/3020edd26447f31105b52e4af09e8fb6 to your computer and use it in GitHub Desktop.

To get the APPLE_PRIVATE_KEY for app attestation, you'll need to follow these steps in your Apple Developer account:

Go to Apple Developer Portal

Visit https://developer.apple.com Sign in with your Apple Developer account Click on "Certificates, Identifiers & Profiles"

Create a new key:

In the sidebar, click on "Keys" Click the "+" button to add a new key Give your key a name (e.g., "App Attestation Key") Enable "Device Check" capability Click "Continue" and then "Register"

Download the key:

After registration, you'll see a one-time download button Download the .p8 file IMPORTANT: Save this file securely as you can only download it once

Get the key contents:

Open the downloaded .p8 file in a text editor The content will look something like this:

Copy-----BEGIN PRIVATE KEY----- MIGTAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBHkwdwIBAQQg+s07NiAQqfXnXoCE ... (many more lines of code) KwIBBQ== -----END PRIVATE KEY-----

Format for .env file:

Copy the entire content including the BEGIN and END lines Replace actual newlines with "\n" Your .env file should look like:

CopyAPPLE_PRIVATE_KEY=-----BEGIN PRIVATE KEY-----\nMIGTAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBHkwdwIBAQQg+s07NiAQqfXnXoCE...\nKwIBBQ==\n-----END PRIVATE KEY-----

Also note:

The APPLE_TEAM_ID is your Apple Developer Team ID (found in Developer portal) The APPLE_KEY_ID is the key ID shown in the portal when you created the key

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment