iOS 使用自主开发的 MDM 进行设备注册?
iOS Device Enrollment with Self-Developed MDM?
我正在尝试开发一个非常简单的概念验证 iOS MDM,它将允许 iOS 设备的 OTA 注册。这并不是要成为某些 MobileIron 的替代品或任何东西。这真的只是一个学习练习。我正在 Java 中使用 JAX-RS 为 RESTful 服务端点开发我的代码。
此时,我可以从我的 iOS 中获取 URL (http://myhost/enroll),这将 return 注册响应以启动设备注册过程.响应 returned 看起来像这样:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Inc//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PayloadContent</key>
<dict>
<key>URL</key>
<string>https://myhost/profile</string>
<key>DeviceAttributes</key>
<array>
<string>UDID</string>
<string>IMEI</string>
<string>ICCID</string>
<string>VERSION</string>
<string>PRODUCT</string>
</array>
<key>Challenge</key>
<string>MySuperSecureChallenge</string>
</dict>
<key>PayloadOrganization</key>
<string>Example Inc.</string>
<key>PayloadDisplayName</key>
<string>Profile Service</string>
<key>PayloadVersion</key>
<integer>1</integer>
<key>PayloadUUID</key>
<string>fdb376e5-b5bb-4d8c-829e-e90865f990c9</string>
<key>PayloadIdentifier</key>
<string>com.example.mobileconfig.profile-service</string>
<key>PayloadDescription</key>
<string>Enter device into the Example Inc encrypted profile service</string>
<key>PayloadType</key>
<string>Profile Service</string>
</dict>
</plist>
一旦我的设备收到此有效负载,它会将我带到“设置”应用并提示我安装配置文件。当我单击 "Install" 时,它会向另一个 URL (http://myhost/profile) 执行 HTTP POST
并包含我在来自 /enroll 的响应中请求的属性。
我的 /profile
端点能够成功地从我的 iOS 设备中提取签名响应,它看起来像这样:
<?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>CHALLENGE</key>
<string>MySuperSecureChallenge</string>
<key>IMEI</key>
<string>__MY_IMEI__</string>
<key>PRODUCT</key>
<string>iPhone10,4</string>
<key>UDID</key>
<string>__MY_UDID__</string>
<key>VERSION</key>
<string>15B202</string>
</dict>
</plist>
我的问题是:现在怎么办??我发现 example payloads like this(来自 Apple)展示了如何进行 SCEP 注册。但是,我不想为这个简单的概念验证做 SCEP。在这个阶段我还有什么可以 return 的吗?如果是这样,响应应该包含什么并且看起来像什么?如果我 不 使用 SCEP,我还没有找到任何文档概述我的 /profile
端点应该 returned 的内容,所以我有点卡住了.
更新: 我在网上找到了一些资源,暗示我需要使用 SCEP 或在有效负载中提供 PKCS#12 格式的证书。所以,我已经将 /profile
的 return 值更新为如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Inc//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PayloadVersion</key>
<integer>1</integer>
<key>PayloadType</key>
<string>Configuration</string>
<key>PayloadContent</key>
<array>
<dict>
<key>PayloadContent</key>
<dict>
<key>Challenge</key>
<string>MyChallengeGoesHere</string>
</dict>
<key>PayloadDescription</key>
<string>Provides device encryption identity</string>
<key>PayloadUUID</key>
<string>fd8a6b9e-0fed-406f-9571-8ec98722b713</string>
<key>PayloadType</key>
<string>com.apple.security.pkcs12</string>
<key>PayloadDisplayName</key>
<string>Cert Test</string>
<key>PayloadVersion</key>
<integer>1</integer>
<key>PayloadOrganization</key>
<string>Example, Inc.</string>
<key>PayloadIdentifier</key>
<string>com.example.profileservice.webclip</string>
<key>PayloadContent</key>
<string>__MY_BASE64_ENCODED_PKCS12_CERT__</string>
<key>Password</key>
<string>__MY_CERT_PASSWORD__</string>
</dict>
</array>
</dict>
</plist>
我正在 return 将此值返回给客户端,但是当我在我的 iOS 设备上单击 Install
时,我收到一条错误消息:
Profile Installation Failed A connection to the server could not be
established.
现在,我知道通信不是问题,因为我在日志和调试器中看到了与 /profile
的连接。还有什么我想念的吗?配置文件是否需要进行数字签名?如果是这样,它是什么格式?我应该使用哪个证书来签署它?
经过大量的反复试验,我终于弄清楚了这个配置文件的问题所在。我遗漏了几个参数:PayloadIdentifier
和 PayloadUUID
。此外,包含我的 base64 编码证书的 PayloadContent
参数的值应该是 data
,而不是 string
。所以,我的新个人资料如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Inc//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PayloadVersion</key>
<integer>1</integer>
<key>PayloadType</key>
<string>Configuration</string>
<key>PayloadUUID</key>
<string>9f93912b-5fd2-4455-99fd-13b9a47b4581</string>
<key>PayloadIdentifier</key>
<string>org.example.mymdm</string>
<key>PayloadContent</key>
<array>
<dict>
<key>PayloadType</key>
<string>com.apple.security.pkcs12</string>
<key>PayloadUUID</key>
<string>f78c5002-3907-4f67-b631-d41c44283628</string>
<key>PayloadVersion</key>
<integer>1</integer>
<key>PayloadIdentifier</key>
<string>com.mymdm.cert</string>
<key>Password</key>
<string>__MY_CERT_PASSWORD__</string>
<key>PayloadContent</key>
<data>__MY_BASE64_ENCODED_P12__</data>
</dict>
</array>
</dict>
</plist>
进行这些更改后,我就能够在我的 iOS 设备上成功安装配置文件。
我正在尝试开发一个非常简单的概念验证 iOS MDM,它将允许 iOS 设备的 OTA 注册。这并不是要成为某些 MobileIron 的替代品或任何东西。这真的只是一个学习练习。我正在 Java 中使用 JAX-RS 为 RESTful 服务端点开发我的代码。
此时,我可以从我的 iOS 中获取 URL (http://myhost/enroll),这将 return 注册响应以启动设备注册过程.响应 returned 看起来像这样:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Inc//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PayloadContent</key>
<dict>
<key>URL</key>
<string>https://myhost/profile</string>
<key>DeviceAttributes</key>
<array>
<string>UDID</string>
<string>IMEI</string>
<string>ICCID</string>
<string>VERSION</string>
<string>PRODUCT</string>
</array>
<key>Challenge</key>
<string>MySuperSecureChallenge</string>
</dict>
<key>PayloadOrganization</key>
<string>Example Inc.</string>
<key>PayloadDisplayName</key>
<string>Profile Service</string>
<key>PayloadVersion</key>
<integer>1</integer>
<key>PayloadUUID</key>
<string>fdb376e5-b5bb-4d8c-829e-e90865f990c9</string>
<key>PayloadIdentifier</key>
<string>com.example.mobileconfig.profile-service</string>
<key>PayloadDescription</key>
<string>Enter device into the Example Inc encrypted profile service</string>
<key>PayloadType</key>
<string>Profile Service</string>
</dict>
</plist>
一旦我的设备收到此有效负载,它会将我带到“设置”应用并提示我安装配置文件。当我单击 "Install" 时,它会向另一个 URL (http://myhost/profile) 执行 HTTP POST
并包含我在来自 /enroll 的响应中请求的属性。
我的 /profile
端点能够成功地从我的 iOS 设备中提取签名响应,它看起来像这样:
<?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>CHALLENGE</key>
<string>MySuperSecureChallenge</string>
<key>IMEI</key>
<string>__MY_IMEI__</string>
<key>PRODUCT</key>
<string>iPhone10,4</string>
<key>UDID</key>
<string>__MY_UDID__</string>
<key>VERSION</key>
<string>15B202</string>
</dict>
</plist>
我的问题是:现在怎么办??我发现 example payloads like this(来自 Apple)展示了如何进行 SCEP 注册。但是,我不想为这个简单的概念验证做 SCEP。在这个阶段我还有什么可以 return 的吗?如果是这样,响应应该包含什么并且看起来像什么?如果我 不 使用 SCEP,我还没有找到任何文档概述我的 /profile
端点应该 returned 的内容,所以我有点卡住了.
更新: 我在网上找到了一些资源,暗示我需要使用 SCEP 或在有效负载中提供 PKCS#12 格式的证书。所以,我已经将 /profile
的 return 值更新为如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Inc//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PayloadVersion</key>
<integer>1</integer>
<key>PayloadType</key>
<string>Configuration</string>
<key>PayloadContent</key>
<array>
<dict>
<key>PayloadContent</key>
<dict>
<key>Challenge</key>
<string>MyChallengeGoesHere</string>
</dict>
<key>PayloadDescription</key>
<string>Provides device encryption identity</string>
<key>PayloadUUID</key>
<string>fd8a6b9e-0fed-406f-9571-8ec98722b713</string>
<key>PayloadType</key>
<string>com.apple.security.pkcs12</string>
<key>PayloadDisplayName</key>
<string>Cert Test</string>
<key>PayloadVersion</key>
<integer>1</integer>
<key>PayloadOrganization</key>
<string>Example, Inc.</string>
<key>PayloadIdentifier</key>
<string>com.example.profileservice.webclip</string>
<key>PayloadContent</key>
<string>__MY_BASE64_ENCODED_PKCS12_CERT__</string>
<key>Password</key>
<string>__MY_CERT_PASSWORD__</string>
</dict>
</array>
</dict>
</plist>
我正在 return 将此值返回给客户端,但是当我在我的 iOS 设备上单击 Install
时,我收到一条错误消息:
Profile Installation Failed A connection to the server could not be established.
现在,我知道通信不是问题,因为我在日志和调试器中看到了与 /profile
的连接。还有什么我想念的吗?配置文件是否需要进行数字签名?如果是这样,它是什么格式?我应该使用哪个证书来签署它?
经过大量的反复试验,我终于弄清楚了这个配置文件的问题所在。我遗漏了几个参数:PayloadIdentifier
和 PayloadUUID
。此外,包含我的 base64 编码证书的 PayloadContent
参数的值应该是 data
,而不是 string
。所以,我的新个人资料如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Inc//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PayloadVersion</key>
<integer>1</integer>
<key>PayloadType</key>
<string>Configuration</string>
<key>PayloadUUID</key>
<string>9f93912b-5fd2-4455-99fd-13b9a47b4581</string>
<key>PayloadIdentifier</key>
<string>org.example.mymdm</string>
<key>PayloadContent</key>
<array>
<dict>
<key>PayloadType</key>
<string>com.apple.security.pkcs12</string>
<key>PayloadUUID</key>
<string>f78c5002-3907-4f67-b631-d41c44283628</string>
<key>PayloadVersion</key>
<integer>1</integer>
<key>PayloadIdentifier</key>
<string>com.mymdm.cert</string>
<key>Password</key>
<string>__MY_CERT_PASSWORD__</string>
<key>PayloadContent</key>
<data>__MY_BASE64_ENCODED_P12__</data>
</dict>
</array>
</dict>
</plist>
进行这些更改后,我就能够在我的 iOS 设备上成功安装配置文件。