Provisioning profiles
Every iOS app that isn't from the App Store carries embedded.mobileprovision: Apple's permission for that app to run, listing who may sign it, on which devices, with which entitlements, until when. The tool reads it in your browser; the code is two libraries you can reuse.
Contents
- The format
- What to look at
- The ProvisioningProfile library
- The CMS library
2What to look at
- get-task-allow = true: a development build; debuggers can attach.
- ProvisionsAllDevices: enterprise distribution, installable on any device.
- Expiry: an expired profile stops the app from launching.
- Developer certificates identify the signing team; the profile's own signing chain is Apple's.
3The ProvisioningProfile library
lib/mobileprovision.js is a JavaScript module with no user interface. It exports ProvisioningProfile, a class whose instances are opened profiles; it imports lib/cms.js and lib/plist.js itself. Use lib/x509.js (X509Certificate) to read the certificates it returns. Reading the plist inside needs the browser's DOMParser (a page, not a worker).
import { ProvisioningProfile } from "../lib/mobileprovision.js";
import { X509Certificate } from "../lib/x509.js";
const info = ProvisioningProfile.read(bytes);
console.log(info.profile.Name, info.profile.ExpirationDate, info.distribution, info.debuggable);
const developer = new X509Certificate(info.developerCertificates[0]);
| Method / property | What it is |
| ProvisioningProfile.read(bytes), new ProvisioningProfile(bytes) | Opens a profile (a Uint8Array or an ArrayBuffer); throws when it isn't a signed plist. |
| profile | The plist as plain values (Plist.decode): dates are Dates, data is Uint8Array. |
| xml | The plist's text. |
| appIdentifier | Entitlements["application-identifier"], or null. |
| developerCertificates | DER certificates allowed to sign apps with the profile. |
| signingCertificates | DER certificates of the chain that signed the profile. |
| distribution | "enterprise", "ad hoc or development" (it lists devices) or "App Store". |
| debuggable | get-task-allow is true. |
4The CMS library
lib/cms.js exports SignedData, which reads CMS / PKCS#7 SignedData, also used by APK v1 signatures (META-INF/*.RSA), Mach-O code signatures and .p7b bundles. It reads the structure; it doesn't verify signatures.
import { SignedData } from "../lib/cms.js";
const signed = SignedData.read(bytes);
console.log(signed.certificates.length, signed.content && signed.content.length);
| Method / property | What it is |
| SignedData.read(bytes), new SignedData(bytes) | Reads a ContentInfo holding SignedData (a Uint8Array or an ArrayBuffer); throws for anything else. |
| SignedData.OID | { data, signedData }: the two content type OIDs. |
| contentType | The signed content's OID (1.2.840.113549.1.7.1 is plain data). |
| content | The signed bytes, or null for a detached signature. |
| certificates | The included certificates (DER), in file order. |
| digestAlgorithms | OIDs. |
| signers | [{ version, issuer, serial, subjectKeyId, digestAlgorithm, signatureAlgorithm, signedAttributes, signedAttributesDer, signature }]. issuer is the DER of the issuer's name; signedAttributes are [{ type, values }] and signedAttributesDer the bytes the signature covers. |