Download the PHP package jewei/app-attest-php without Composer

On this page you can find all versions of the php package jewei/app-attest-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package app-attest-php

App Attest PHP

Verify Apple App Attest attestations and assertions on a PHP server. 64-bit PHP ^8.3 with ext-openssl, and no other dependencies.

The package follows Apple's server validation steps. It passes Apple's sample attestations of 2026 (iOS 27) and 2024 (iOS 18.0) against the pinned Apple App Attestation Root CA, a real iOS 27.0.1 attestation and two assertions, and a real iOS 27 assertion from another app.

Install

Create a verifier

The Validation categories.

For an App Clip, use the full app's bundle ID: Apple builds the App Clip's RP ID from it. Write the bundle ID in the exact case of the app's entitlement: the RP ID hash is case-sensitive.

Verify an attestation

The app creates a key with DCAppAttestService.generateKey() and attests it with attestKey(_:clientDataHash:). Give the app a one-time challenge first, and have it pass SHA256(challenge) as clientDataHash.

The credential certificate is valid for 3 days (in Apple's samples and in the real iOS 27.0.1 attestation, from 24 hours before the time in its serial number). Verify the attestation when the app sends it, and keep the server clock in sync (NTP).

Verify an assertion

The app signs each request with generateAssertion(_:clientDataHash:), where clientDataHash is SHA256(clientData). Rebuild clientData on the server from the request and your one-time challenge.

What your server still does

The package checks the cryptography and the data. Your server must also:

Checks

verifyAttestation():

  1. The object is CBOR with exactly fmt, attStmt (x5c, receipt), and authData; fmt is apple-appattest.
  2. x5c is an array of the credential certificate and one intermediate. The intermediate has neither the anchor's key nor the same issuer and subject. The credential key is EC P-256 and the intermediate key EC P-256 or P-384, checked before OpenSSL reads any key. The issuer and subject names match byte for byte. The anchor signed the intermediate, and the intermediate signed the credential certificate. All three are valid at the check time. The intermediate is a CA with keyCertSign; the credential certificate is not a CA. A critical extension other than basic constraints or key usage is refused. Flags, names, and times are read from DER that is strict for the fields that the package reads (version 3, the outer signature algorithm equal to the signed one, no written DEFAULT values, minimal keyUsage bits), and times must have the RFC 5280 forms: UTCTime through 2049, GeneralizedTime from 2050.
  3. The nonce extension (OID 1.2.840.113635.100.8.2) equals SHA256(authData || clientDataHash). A platform field in extension 1.2.840.113635.100.8.7 other than iphoneos is refused. Apple's documented macOS key access-control blob in extension 1.2.840.113635.100.8.6 is refused too: a Mac with full security mode and System Integrity Protection writes it (WWDC26 session 201). A Mac with System Integrity Protection off writes another blob, which the package cannot recognise, so a certificate with an access-control blob must also have the platform field. iOS 27 writes both, iOS 18 writes the platform field iphoneos and no blob, and the 2021 layout has neither; a certificate without a blob is accepted when its platform field is iphoneos or absent.
  4. SHA256 of the credential key as an X9.62 uncompressed point equals the key ID. The key is EC P-256.
  5. The RP ID hash equals SHA256 of the App ID.
  6. The counter is 0.
  7. The AAGUID is appattest followed by seven zero bytes (production) or appattestdevelop (development).
  8. The credential ID equals the key ID.
  9. The validation category passes the policy.

verifyAssertion():

  1. The stored key's environment is the verifier's environment. The object is CBOR with exactly signature and authenticatorData. The ED flag must match the bytes after the counter: with it, an extensions map; without it, nothing.
  2. The signature is ECDSA with SHA-256 over nonce = SHA256(authenticatorData || SHA256(clientData)), with the stored key.
  3. The RP ID hash equals SHA256 of the App ID.
  4. The counter is above the stored counter.
  5. The validation category passes the policy.

Validation categories

Apple's current documentation adds apple_validation_category_01 (how the app's code is signed) and apple_bundle_version_01 to the authenticator data. (Its assertion steps call them validationCategory and bundleVersion; the real assertion in spec/ uses the _01 keys, so the package reads those.) Devices write them from iOS 27 (Apple, WWDC26 session 201); iOS 26 and earlier write neither. Apple's sample attestation (iOS 27), the real iOS 27.0.1 attestation and assertions, and the real iOS 27 assertion in spec/ have both. Both results expose them as validationCategory (a ValidationCategory, or null) and bundleVersion (a string, or null).

Policy Result
CategoryPolicy::only(...) Only the listed categories. A missing category fails, so devices on iOS 26 and earlier are refused. For apps that need iOS 27 or later.
CategoryPolicy::onlyOrMissing(...) The listed categories, or none (devices on iOS 26 and earlier).
CategoryPolicy::any() Every category that ValidationCategory names, and a missing one: also OperatingSystem (1) and Other (10), which point to a jailbroken device (1) or a re-signed or sideloaded app (10). (Apple's own 2026 sample reports 1, because it comes from an Apple-internal build.) For tests and diagnostics, not production.

A third-party app that Apple distributes reports AppStore or TestFlight, and a build that Xcode runs with a development profile reports Development. The verifier always refuses 0 (invalid), 7 to 9 (Apple: binaries that the system generates in restricted situations, not appropriate), and values that ValidationCategory does not name yet.

The app chooses the client data hash, and nothing in the signed bytes marks where the authenticator data ends. In an assertion the ED flag closes that gap. Apple's 2026 sample attestation writes extensions without the ED flag (0x40), while a real iOS 27.0.1 attestation (in spec/) and a real macOS 27 attestation (in spec/third-party/) set it (0xC0), as real assertions do, so the package cannot require the flag in attestations: it reads an attestation's extensions whenever bytes remain. So on a device that writes no extensions, a modified app can make an attestation carry any category. The verifier checks the policy again on every assertion, where the app cannot change it, so base your decisions on assertions; treat the attestation's category and bundle version as a hint.

Apple says that the extensions follow the WebAuthn authenticator data format (WWDC26 session 201), where the ED flag marks them; the rule above follows that and a real iOS 27 assertion (flags 0xC0 with extensions). If every assertion from one OS version fails with malformed_input, that version writes extensions without the flag: please open an issue with a sample. Remove user and session values from the client data first, or send the sample privately (see SECURITY.md).

Failures

A failed check throws AppAttest\Exception\VerificationException. Its failure property tells which check failed, with a stable string value for logs:

Failure Value
MalformedInput malformed_input
UnsupportedFormat unsupported_format
UnsupportedPlatform unsupported_platform
InvalidCertificate invalid_certificate
NonceMismatch nonce_mismatch
KeyIdMismatch key_id_mismatch
AppIdMismatch app_id_mismatch
NonZeroCounter non_zero_counter
EnvironmentMismatch environment_mismatch
CredentialIdMismatch credential_id_mismatch
CategoryNotAllowed category_not_allowed
InvalidSignature invalid_signature
CounterNotIncreased counter_not_increased

New Failure and ValidationCategory cases can come in minor versions, so give a match on them a default arm. An upgrade that names a new category widens CategoryPolicy::any().

Do not show the failure or the message to the client. A wrong argument from your own server, such as a stored public key that is not an EC P-256 PEM, throws InvalidArgumentException.

The package empties OpenSSL's error queue (openssl_error_string()) after its calls. OpenSSL cannot keep earlier entries, so read the queue before you call the verifier if you need it.

Limits

Test your integration

AppAttest\Testing makes real attestations and assertions without a device, so your own tests can run the whole flow. For tests only: never pass its root to a production verifier.

The test root and intermediate are valid for 10 years from TestAuthority::create(); each credential certificate is valid for 3 days from attest(). A test that freezes the clock must keep it inside that window, or pass the time to verifyAttestation().

Trust anchor

resources/apple-app-attestation-root-ca.pem is Apple's App Attestation Root CA, valid until 2045-03-15. spec/provenance.json records its source and hashes. The trustAnchor constructor argument is for tests with AppAttest\Testing or your own test CA; do not set it in production.

Development

License

MIT. See spec/third-party has test fixtures under the Apache License 2.0 and the BSD 2-Clause License.


All versions of app-attest-php with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3.0
php-64bit Version *
ext-openssl Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package jewei/app-attest-php contains the following files

Loading the files please wait ...