Zum Inhalt springen

iOS Setup & Backend-Verifizierung

GitHub

Auf iOS verwendet dieses Plugin Apple App Attest vom DeviceCheck Framework.

  • iOS 14+
  • Für echte Validierungsabläufe wird ein physisches Gerät empfohlen
  • Xcode-Ziel mit aktivierter App-Attest-Funktion
  1. Öffnen Sie Ihr iOS-App-Target in Xcode.
  2. Gehe zu Signierung & Capabilities.
  3. Klicken + Capability und hinzufügen App Attest.

Es sind keine benutzerdefinierten iOS-Berechtigungen in Info.plist für App Attest selbst erforderlich.

import { AppAttest } from '@capgo/capacitor-app-attest';
const { keyId } = await AppAttest.prepare();
const attestation = await AppAttest.createAttestation({
keyId,
challenge: 'backend-registration-challenge',
});
const assertion = await AppAttest.createAssertion({
keyId,
payload: 'backend-request-payload',
});

Senden attestation.token und assertion.token an Ihr Backend senden. Validieren Sie sie nicht in der App.

  1. Backend erstellt einmalig challenge.
  2. App ruft auf createAttestation({ keyId, challenge }).
  3. Backend validiert die App Attest-Attestation:
    • Zertifikatskette ist gültig und an Apple App Attest verankert
    • App-Identität entspricht Ihrer App (bundleId, Team)
    • clientDataHash entspricht SHA256(challenge)
  4. Geräteschlüsselstatus speichern (keyId, öffentlicher Schlüssel und Verifier-Metadaten).
  1. Backend erstellt einmalig payload (oder kanonischer Request-Hash-Input).
  2. App ruft auf createAssertion({ keyId, payload }).
  3. Backend verifiziert die Assertion-Signatur mit zuvor gespeichertem Schlüsselmaterial.
  4. Replay-Schutz und Nonce-TTL-Prüfungen erzwingen.
sequenceDiagram
participant App as iOS App
participant Plugin as AppAttest plugin
participant Apple as Apple App Attest
participant BE as Backend
BE->>App: one-time challenge
App->>Plugin: prepare()
Plugin->>Apple: generateKey()
Apple-->>Plugin: keyId
App->>Plugin: createAttestation(keyId, challenge)
Plugin->>Apple: attestKey(keyId, SHA256(challenge))
Apple-->>Plugin: attestation token
Plugin-->>App: token + platform + format + keyId
App->>BE: token + challenge + keyId
BE->>BE: verify Apple attestation rules
BE->>App: one-time payload
App->>Plugin: createAssertion(keyId, payload)
Plugin->>Apple: generateAssertion(keyId, SHA256(payload))
Apple-->>Plugin: assertion token
Plugin-->>App: token + platform + format + keyId
App->>BE: token + payload + keyId
BE->>BE: verify signature + replay policy

Registrierung:

{
"platform": "ios",
"format": "apple-app-attest",
"keyId": "string",
"challenge": "string",
"token": "string"
}

Assertion:

{
"platform": "ios",
"format": "apple-app-attest",
"keyId": "string",
"payload": "string",
"token": "string"
}

Wenn du es nutzt iOS-Setup & Backend-Verifizierung um Sicherheit und Compliance zu planen, verbinden Sie es mit @capgo/capacitor-app-attest verwenden für die native Funktion in „@capgo/capacitor-app-attest verwenden“, Verschlüsselung für die Implementierungsdetails in Encryption, Compliance für das Implementierungsdetail in Compliance, Capgo Security-Scanner für den Produkt-Workflow im Capgo Security Scanner, und Capgo Sicherheit für den Produkt-Workflow in Capgo Security.