Setting up apps and the policy
For the console admin, often the mobile lead. At the end of this page, your apps are prepared with Apple and Google, a monitor-mode policy is published on the project’s Attestation page, and, once the verifier runs, its domain is registered and pinned in your TrustPin project.
This page covers stages 1 and 3 of the setup path. Stage 2, deploying the verifier, happens in between.
Before you start
- A TrustPin project with pinning set up. See Project setup.
- The project signs with a cloud key (you need its master password) or with your own key (BYOK, you need the PEM file). Projects signed with FIDO can’t use app attestation in this release; their Attestation page says so.
- The Member role or above in the organization. Viewers can read the attestation settings but not edit or publish them.
- For Apple apps: access to the Apple Developer account and the Xcode project.
- For Android apps: the app’s keystores, and Play Console access for apps distributed on Google Play. For Play Integrity, also a Google Cloud project you can administer.
Apple apps
Repeat for each app. An iOS app and its watchOS app, for example, have different bundle IDs and are two apps.
- Enable App Attest on the App ID. In the Apple Developer portal, Certificates, Identifiers & Profiles, Identifiers, open the app’s App ID and turn on the App Attest capability. With automatic signing, Xcode does this when you add the capability in step 2.
- Add the capability in Xcode. Select the app target, Signing & Capabilities, + Capability, App Attest. This adds the entitlement
com.apple.developer.devicecheck.appattest-environment.- Builds you run from Xcode attest in Apple’s development environment.
- Builds you distribute (TestFlight, App Store, ad hoc) attest in the production environment.
- Note the Team ID and Bundle ID. The Team ID is 10 uppercase letters and digits, shown under Membership details in the Apple Developer portal. The Bundle ID is the target’s
CFBundleIdentifier, for examplecom.example.app. On the console form you can drop the app’sInfo.plist(fills the Bundle ID) or a.mobileprovisionfile (fills both; a wildcard profile fills only the Team ID). A development profile also turns on Accept development builds.
Check: the built app carries the entitlement.
codesign -d --entitlements - /path/to/Example.appThe output lists com.apple.developer.devicecheck.appattest-environment. If it doesn’t, the capability is missing from that target.
On macOS, check which environment a build actually attests in: the token’s tp.env says production or development.
Android apps
Repeat for each app.
-
Package name. The
applicationIdof the build you test or ship, for examplecom.example.app. A build variant with anapplicationIdSuffix, such ascom.example.app.debug, is a different package and needs its own row. -
Signing certificate SHA-256, for every certificate that signs a build you accept. Up to 10 per app.
Build Signed by Where to find the SHA-256 Run from Android Studio The debug keystore keytoolon~/.android/debug.keystore(below)Installed from Google Play, any track Google’s Play app signing key, not your upload key Play Console, your app, Protected with Play, Play Store protection, Manage Play app signing: the SHA-256 fingerprint of the App signing key certificate Release builds you install yourself, or ship through another store Your upload or release key keytoolon that keystore# Debug builds keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android | grep 'SHA256:' # Your upload or release keystore keytool -list -v -keystore <keystore> -alias <alias> | grep 'SHA256:' # Every build variant of the project at once ./gradlew signingReport # The certificate that actually signed an APK you are testing apksigner verify --print-certs app-release.apk | grep 'SHA-256'Paste a digest into the console as printed: colon-separated hex as Play Console and
keytoolshow it, plain hex, or base64url all work. You can also drop a certificate file (.pem,.der,.crt,.cer) onto the form. During a signing-key rotation, list both certificates. -
Evidence, the proof a device must provide:
Console option Device must provide Fails on Either (the default) Every evidence it can: Key Attestation, plus Play Integrity when the app has a Google Cloud project number configured. Passes when at least one passes the policy Devices that can provide neither Both Key Attestation and Play Integrity Devices missing either Play Integrity only Play Integrity Devices without Google Play, and apps without a project number Key Attestation only Key Attestation Devices without hardware-backed key attestation, and emulators To start without any Google setup, choose Key Attestation only, or keep Either and configure no project number in the app: devices then attest with Key Attestation alone. Under Either, an app configured with a project number spends one Play Integrity request on every attestation, not only as a fallback; Google’s default quota is 10,000 requests a day per Cloud project.
-
Play Integrity, only with Either (if you use it), Both or Play Integrity only:
-
Link a Cloud project. In Play Console, open the app, Protected with Play, and next to Play Integrity API choose Get started (or Manage), then Link Cloud project. Linking enables the Play Integrity API in that project. All Android apps in one policy must be linked to the same Cloud project, because a verifier holds one Google credential.
-
Turn on the responses the policy checks. In the same place, Change responses. The console’s In Play Console box lists what your policy needs: Additional device labels for MEETS_BASIC_INTEGRITY or MEETS_STRONG_INTEGRITY, and the App access risk, Play Protect verdict and Recent device activity responses. A check whose response is off never fails: it is reported as
verdict_unavailable. -
Create a service account for the verifier. In the Google Cloud console of that project, IAM & Admin, Service accounts, Create service account. Then, on the account, Keys, Add key, Create new key, JSON. Put the key, base64-encoded, into your secret store for the verifier’s
TRUSTPIN_PLAY_INTEGRITY_CREDENTIALS:base64 < service-account.json | tr -d '\n'Give the verifier this credential before you publish a policy whose evidence is Both or Play Integrity only: a verifier without it refuses that policy and keeps the previous one. See Deploying the verifier.
-
Note the project number: digits, not the project ID. It is on the Google Cloud console dashboard, Project info, and in
google-services.jsonasproject_number. You enter it in the console (below) and in the app’s attestation configuration; see Android.
Configure the project number in the app only when the policy uses Play Integrity: with a number configured, the app contacts Google Play services from setup on, which belongs in its Data safety declaration. Builds not installed from Google Play aren’t recognized by it, so keep Require an app recognized by Google Play off while you test them, or test through a Play testing track.
-
-
Key Attestation, the device checks you want (field table below). With Require verified boot off, devices running a custom operating system with a relocked bootloader, such as GrapheneOS, are accepted; the bootloader must still be locked. In release builds, the pinning SDK also refuses emulators and non-OEM operating system images unless the app’s manifest sets
cloud.trustpin.android.allowNonOemImages.
Creating the policy
- In the project’s sidebar, open Attestation. The page, headed App attestation, shows Set up app attestation; choose Set up.
- Go through the four steps of the wizard: 1. Apple apps, 2. Android apps, 3. Mode and tokens and 4. Review. Turn off Attest Apple apps or Attest Android apps if you ship only one platform; at least one must stay on. Hover the info icon next to a field for its help.
- On 4. Review, fix anything listed under “Fix these first”, check the In Play Console box, and choose Create the policy. Version 1 is saved as a draft: nothing reaches a verifier until you publish it.
A new policy starts with the defaults below, which match the presets marked Recommended. A preset changes the settings only, never the apps you added. Each failed check reports the reason code shown, in tp.reasons of the token and in the verifier’s log.
1. Apple apps
| Field | Default | Start with | What it does |
|---|---|---|---|
| Team ID, Bundle ID | Empty | One row per app, up to 50. Add Apple app adds a row | An attestation from an app not listed gets 403 app_not_allowed, in both modes |
| Accept development builds | Off | On while you test builds run from Xcode | Off refuses the development environment: dev_environment |
Presets: Production (recommended): development builds refused. Production and development: development builds accepted, for testing.
2. Android apps
| Field | Default | Start with | What it does |
|---|---|---|---|
| Package name, Signing certificate SHA-256 | Empty | One row per package, up to 50; up to 10 digests each. Add Android app, Add digest | An unlisted package gets 403 app_not_allowed in both modes. A listed package signed with an unlisted certificate fails app_not_allowed |
| Evidence | Either | Either, or Key Attestation only without Google setup | Which evidence must be present and pass; see the table above. A required evidence that is missing fails evidence_missing |
| Require an app recognized by Google Play | On | Off while you test builds not installed from Play | Requires Play’s PLAY_RECOGNIZED verdict: app_not_recognized |
| Require a licensed app | Off | Off | Requires the user to have installed or bought the app from Play: unlicensed |
| Minimum device integrity | MEETS_DEVICE_INTEGRITY | MEETS_DEVICE_INTEGRITY | The weakest Play device label accepted: device_integrity_insufficient. The other two levels need Additional device labels in Play Console |
| Maximum verdict age (seconds) | 300 | 300 | 30 to 3600. An older Play Integrity verdict is refused in both modes: token_too_old |
| App access risk | Don’t check | Don’t check | Fails when Play reports the chosen kinds of running apps: app_access_risk |
| Play Protect: maximum risk | Not checked | Not checked | Fails above the chosen Play Protect status: play_protect_risk |
| Recent device activity: maximum level | Not checked | Not checked | Fails above the chosen activity level: device_activity_excessive |
| Google Cloud project number | Empty | Your project number, when Play Integrity is used | Shown in the Play Integrity section during setup; later on the Deployment tab. Not part of the signed policy: it fills the deployment bundle and the console’s snippets |
| Require verified boot | On | On for consumer production | Requires a manufacturer-signed operating system: verified_boot_failed |
| Require a locked bootloader | On | On | bootloader_unlocked |
| Minimum security level | TRUSTED_ENVIRONMENT | TRUSTED_ENVIRONMENT | Where the attested key lives. STRONG_BOX refuses most devices: security_level_insufficient. Software keys are never accepted |
| Minimum OS patch level (YYYYMM, optional) | Empty | Empty | Oldest Android security patch accepted, for example 202601: patch_level_too_old |
The Play Integrity fields appear unless Evidence is Key Attestation only; the Key Attestation fields appear unless it is Play Integrity only.
Presets:
- Recommended: the defaults above.
- Strict: Both,
MEETS_STRONG_INTEGRITY, a licensed app, a 120-second verdict age, and the optional verdicts on (apps from outside Google Play that capture the screen, control the device or draw over the app; Play ProtectNO_ISSUES; activity up toLEVEL_3). Turn on the matching responses in Play Console first. - Without Google Play: Key Attestation only, with Require verified boot off.
3. Mode and tokens
| Field | Default | Start with | What it does |
|---|---|---|---|
| Mode | Monitor (recommended to start) | Monitor | Monitor: a device that fails a policy check still gets a token, marked tp.result fail. Enforce: it gets none. See Rolling out |
| Access token lifetime | 1 h | 1 h | Presets 15 min, 1 h, 6 h, 1 day. The SDK renews the token before it expires, without a new attestation |
| Key certificate lifetime | 30 days | 30 days | Presets 1, 7, 30 and 90 days. How long an attested device key is trusted; when it expires, the device attests again with a new key |
| Require token binding | Off | Off until your API checks bind | On: an attestation or renewal without a binding is refused with 400 binding_required, in both modes. See Verifying tokens in your API |
| Allow debug tokens | Off | On if you test on simulators or emulators | Lets simulators and emulators attest with a debug token, where the verifier also has TRUSTPIN_DEBUG_TOKEN_HASHES. Never configure those hashes on a production verifier |
The CLI and the API accept any access-token lifetime from 60 to 86400 seconds and any key-certificate lifetime from 1 to 90 days; the console lists such a value next to its presets.
Signing and publishing
- On the Policy tab, choose Sign and publish.
- Cloud-key project: enter the Master password and choose Sign and publish. The key is decrypted in your browser; the password is never sent.
- BYOK project: download
attestation-payload.json, choose Copy signing command, and run that command with Node.js 16 or later, with your key saved asproject-key.pemnext to the payload. Paste its output into Signed policy (JWS) and choose Publish.
- When the version can refuse something accepted today, the dialog lists it, under “Stricter than the published version” (or “Check before publishing” on a first publish). Tick “I understand that devices, apps or tokens accepted today may be refused once this version is published.” to continue.
The first publish must be made in the console. Until then, verifiers for the project refuse to start, and the page says so. Each publish raises the version; running verifiers pick it up within their refresh interval (5 minutes by default), with no redeploy.
Check: the Policy tab shows the status Active and “published version 1”, and Sign and publish is greyed out because the published policy is up to date. On the Go-live guide tab, “Policy published” is ticked.
Next, deploy the verifier: Deploying the verifier. Then come back for the verifier’s domain.
Registering the verifier’s domain
Do this once the verifier answers on its public URL. The SDKs pin their calls to the verifier, and in strict mode they refuse a host that isn’t registered: the app reports verifierUnavailable and sends no header. In permissive mode they reach it without pinning, which is acceptable in development only.
-
On the Deployment tab, make sure the environment has the verifier’s public URL, for example
https://attest.example.com. It must behttps://on port 443 with a DNS host name. -
Save the certificate the verifier serves:
openssl s_client -connect attest.example.com:443 -servername attest.example.com </dev/null 2>/dev/null \ | openssl x509 -outform pem > attest.example.com.pem -
Compute the SPKI SHA-256 pin of that certificate:
openssl x509 -in attest.example.com.pem -pubkey -noout \ | openssl pkey -pubin -outform der | openssl dgst -sha256 -binary | base64 -
In the same TrustPin project, choose Set up domains, Add domain, and enter the host,
attest.example.com. Choose Edit, then Add Certificate, and paste the pin into SPKI SHA256. Leave the fingerprint fields empty: the SDK checks a fingerprint first, and a fingerprint changes with every renewed certificate, while the SPKI pin survives renewals that keep the key. Dropping the PEM file onto the certificate box instead fills the fingerprints too. See Add a domain and Domain configuration. -
Choose Apply changes, then Publish config and Publish, so apps receive the new pin configuration.
Check: on the Attestation page, Status tab, Verifier checks, choose Check now for the environment. Its Pinned for the SDKs step passes, and the environment’s row reads pinned, with the policy version the verifier applied. host not registered means step 4 is missing; pin mismatch means the pin doesn’t match the certificate the verifier serves now.
Changing the policy later
On the Policy tab, choose Edit. The same four steps open; Save changes (or Save now from any step) stores a new draft version, and an amber dot on the Policy tab marks it as not published. Sign and publish it as above. A change reaches devices on the schedule in When changes take effect: some apply at the next token renewal, device checks only at the next attestation.
After the first publish, the TrustPin CLI can export, change, sign and publish the policy, for example from CI:
| Step | Console | CLI |
|---|---|---|
| Read the policy | Policy tab | trustpin-cli projects attestation get <organization id> <project id> --output json |
| Store a change | Edit | trustpin-cli projects attestation update <organization id> <project id> --file attestation.json |
| Sign and publish | Sign and publish | trustpin-cli projects attestation sign <organization id> <project id> (add -k key.pem for BYOK) |
| Rehearse signing | sign --dry-run | |
| Download the verifier bundle | Deployment tab | trustpin-cli projects attestation bundle <organization id> <project id> --format compose|kubernetes|env |
update stores and validates the change as a new, unpublished version; only sign changes what verifiers enforce. Running update and sign with an unchanged file does nothing. In the file, each signing digest is the unpadded base64url of the SHA-256, not the colon-separated hex keytool prints. To convert one:
echo '<SHA256 value from keytool>' | tr -d ':' | xxd -r -p | base64 | tr '+/' '-_' | tr -d '='The CLI needs a member’s personal access token; viewers can run get, config and bundle only. Setting up attestation, its first publish, disabling, re-enabling and abandoning a setup stay in the console.
The other tabs
| Tab | Use |
|---|---|
| Deployment | Name each environment (up to 10), give its verifier URL, set the Google Cloud project number and the Header the apps bind tokens to, and download the verifier bundle. See Deploying the verifier |
| Go-live guide | The Go-live checklist your organization shares, step-by-step snippets with your values filled in, and debug tokens |
| Status | Live policy, Verifier fleet and Verifier checks. The danger zone, for admins and owners, can disable or re-enable attestation, or abandon a setup that was never published |
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
Attestation fails with app_not_allowed | The Team ID and Bundle ID, or the package name and signing digest, don’t match the build | Compare them with the build that runs. On Android, run apksigner verify --print-certs on it; Play installs are signed with the Play app signing key |
Builds run from Xcode fail with dev_environment | Accept development builds is off | Turn it on for development, and publish |
Android test builds fail with app_not_recognized | Require an app recognized by Google Play is on, and the build wasn’t installed from Play | Turn it off while testing, or install through a Play testing track |
A Play Integrity check never fails, and tokens show verdict_unavailable | The response is off in Play Console | Turn it on under Change responses |
The app reports verifierUnavailable and sends no header | The verifier’s domain isn’t registered or its pin doesn’t match | Register the domain and run Check now |
| The verifier keeps an older policy after a publish | The new policy needs Play Integrity and the verifier has no TRUSTPIN_PLAY_INTEGRITY_CREDENTIALS | Add the credential and restart the verifier. See Operating the verifier |
| The CLI refuses to publish with “The first publish must be done in the TrustPin console.” | The policy was never published | Publish it once from the console |
Next steps
- Stage 2: Deploying the verifier, then return to Registering the verifier’s domain
- Stage 4: iOS and macOS, Android, Flutter or React Native