1.如何生成
用代码生成mobileconfig文件啊。具体生成的内容如下:
<plist version="1.0">
<dict>
<key>PayloadContent</key>
<array>
<dict>
<key>PayloadContent</key>
<array>
<dict>
<key>DefaultsData</key>
<dict>
<key>apns</key>
<array>
<dict>
<key>apn</key>
<string>test</string>
<key>proxyPort</key>
<integer>0</integer>
</dict>
</array>
</dict>
<key>DefaultsDomainName</key>
<string>com.apple.managedCarrier</string>
</dict>
</array>
<key>PayloadDescription</key>
<string>提供对营运商“接入点名称”的自定义。</string>
<key>PayloadDisplayName</key>
<string>高级</string>
<key>PayloadIdentifier</key>
<string>apn</string>
<key>PayloadOrganization</key>
<string></string>
<key>PayloadType</key>
<string>com.apple.apn.managed</string>
<key>PayloadUUID</key>
<string>27791D83-5A08-4CE8-9577-BB1517041ED4</string>
<key>PayloadVersion</key>
<integer>1</integer>
</dict>
</array>
<key>PayloadDescription</key>
<string>描述文件描述。</string>
<key>PayloadDisplayName</key>
<string>描述文件名称</string>
<key>PayloadOrganization</key>
<string></string>
<key>PayloadRemovalDisallowed</key>
<false/>
<key>PayloadType</key>
<string>Configuration</string>
<key>PayloadUUID</key>
<string>DD0E4351-9F6E-43F1-9D17-AA2DE1EDFC79</string>
<key>PayloadVersion</key>
<integer>1</integer>
</dict>
</plist>
你需要填写回调数据的PayloadDescription,PayloadDisplayName,PayloadOrganization,PayloadType,PayloadVersion。。。和PayloadUUID。
该PayloadUUID仅仅是随机生成的唯一字符串,用来标识唯一。
2.签名描述文件
.mobileconfig签名网络上大多都是使用ssl证书进行签名,可以参考
http://www.rootmanager.com/iphone-ota-configuration/iphone-ota-setup-with-signed-mobileconfig.html
本文主要讲,使用苹果开发者证书进行签名达到目的,本文两种方法,一种是刀耕火种的一步步操作,一种使用脚本签名
一.导出苹果证书进行签名
1.从钥匙串(keychain)中导出证书
实用工具->钥匙串访问->选择要导出的证书,导出生成p12文件 InnovCertificates.p12
然后转换成 InnovCertificates.pem 文件
2. p12换成pem格式方法
p12在线转换pem https://www.sslshopper.com/ssl-converter.html
(证书)cer.p12文件 转cer.pem文件
openssl pkcs12 -clcerts -nokeys -out cer.pem -in cer.p12
(私钥)key.p12文件转key.pem文件
openssl pkcs12 -nocerts -out key.pem -inkey.p12
3.下载 Apple Root Certificate 和 Apple Intermediate Certificate
(对于本篇文章 .mobileconfig文件的验证我使用了苹果的以下两个证书.
Apple Root Certificate(苹果根证书)
Apple Application Integration Certificate (苹果应用集成证书 )
你也可以使用这些证书或者苹果提供的其他证书 地址: http://www.apple.com/certificateauthority/
下载的文件中包括证书(cer)和私钥(key)
(在命令行中读取证书,参考链接 info.ssl.com/article.aspx?id=12149)
根据这个文件我们可以解压出来证书.
上边所有文件准备号后,运行命令行工具,运行以下命令
结果就是签名并且验证后的 .mobileconfig文件
二.脚本签名
借助于强大的github,找到了一个python脚本进行签名
地址:https://github.com/nmcspadden/ProfileSigner
1.签名一个mobileconfig
profile_signer.py与 mobileconfig 放在同一目录,终端进入目录执行
2.加密一个mobileconfig
3.签名并且加密一个mobileconfig
"3rd Party Mac Developer Application "为你的证书在钥匙串中的全名,选择证书,显示简介,复制常用名称即可,比如
iPhone Developer: jakey.shao xxxx@xxx.com (W26TLNwW63)
iPhone Distribution: XXX Network Technology Co., Ltd. (L5T8PFT6T5)