MASTG-TECH-0079: 获取开发者配置文件
Provisioning Profile 是一个由 Apple 签名的 plist 文件,它将你的代码签名证书添加到其在一个或多个设备上接受的证书列表中。换句话说,这代表 Apple 明确允许你的应用程序出于某些原因运行,例如在选定的设备上进行调试(开发 profile)。Provisioning Profile 还包括授予你的应用程序的授权。证书包含你将用于签名的私钥。
有效的 Provisioning Profile 只能从 Apple 获得。这意味着你需要一个有效的 Apple 帐户。
信息
你可以为普通 Apple 帐户和 Apple Developer 帐户获取有效的 Provisioning Profile。这两种类型之间有两个重要的区别
证书到期时间
- Apple 帐户:证书在创建后 7 天过期
- 开发者帐户:证书在创建后 1 年过期
通配符证书
- Apple 帐户:证书仅对一个 Bundle Identifier 有效。此 Bundle Identifier 必须是唯一的。
- 开发者帐户:证书可以是通配符,允许你保留原始的 Bundle Identifier
Apple Developer 帐户每年的费用为 99 美元,由于到期时间较长,因此最好拥有一个,但不是必需的。
以下步骤适用于普通 Apple 帐户和 Apple Developer 帐户,但确实需要 macOS 主机。
创建签名身份¶
安装 Xcode 并使用任何语言和配置创建一个新的 iOS 应用程序。设置项目以使用自动签名并将应用程序部署到你的 iOS 设备。在此过程中,你必须在设备上接受你的开发者证书,并启用开发者模式。
完成这些步骤后,你可以使用 security 命令列出你的签名身份
$ security find-identity -v -p codesigning
1) 50034388646913B117AF1D6E51D9E045B77EA916 "Apple Development: [email protected] (LVGBSLUQB4)"
1 valid identities found
此外,Provisioning Profile 存储在你的主机上的 ~/Library/Developer/Xcode/DerivedData
文件夹中
$ find ~/Library/Developer/Xcode/DerivedData | grep embedded
/Users/MAS/Library/Developer/Xcode/DerivedData/apptest-aijwmhfiximgzkhcmnluxrscflyc/Build/Products/Debug-iphoneos/apptest.app/embedded.mobileprovision
此文件可以复制到你的本地目录,并可用于对任何 IPA 文件进行签名,即使是具有不同标识符的文件。
cp /Users/MAS/Library/Developer/Xcode/DerivedData/apptest-aijwmhfiximgzkhcmnluxrscflyc/Build/Products/Debug-iphoneos/apptest.app/embedded.mobileprovision ./embedded.mobileprovision
检查 Provisioning Profile¶
获得 Provisioning Profile 后,你可以使用 security 命令检查其内容。你将在 profile 中找到授予应用程序的授权,以及允许的证书和设备。
$ security cms -D -i embedded.mobileprovision
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>AppIDName</key>
<string>XC org mas testapp</string>
<key>ApplicationIdentifierPrefix</key>
<array>
<string>QH868V5764</string>
</array>
<key>CreationDate</key>
<date>2024-12-26T07:22:22Z</date>
<key>Platform</key>
<array>
<string>iOS</string>
<string>xrOS</string>
<string>visionOS</string>
</array>
<key>IsXcodeManaged</key>
<true/>
<key>DeveloperCertificates</key>
<array>
<data>...SNIP...</data>
</array>
<key>DER-Encoded-Profile</key>
<data>...SNIP...</data>
<key>Entitlements</key>
<dict>
<key>application-identifier</key>
<string>QH868V5764.org.mas.apptest</string>
<key>keychain-access-groups</key>
<array>
<string>QH868V5764.*</string>
</array>
<key>get-task-allow</key>
<true/>
<key>com.apple.developer.team-identifier</key>
<string>QH868V5764</string>
</dict>
<key>ExpirationDate</key>
<date>2025-01-02T07:22:22Z</date>
<key>Name</key>
<string>iOS Team Provisioning Profile: org.mas.testapp</string>
<key>ProvisionedDevices</key>
<array>
<string>...SNIP...</string>
</array>
<key>LocalProvision</key>
<true/>
<key>TeamIdentifier</key>
<array>
<string>QH868V5764</string>
</array>
<key>TeamName</key>
<string>OWASP MAS</string>
<key>TimeToLive</key>
<integer>7</integer>
<key>UUID</key>
<string>...SNIP...</string>
<key>Version</key>
<integer>1</integer>
</dict>
</plist>