【问题标题】:iOS MDM - How to close or stop connection after device responds back with valid responseiOS MDM - 如何在设备响应有效响应后关闭或停止连接
【发布时间】:2014-10-13 23:26:10
【问题描述】:

我们正在构建一个 iOS MDM 服务器来管理 iOS 设备。 以下是将 iOS 设备注册到 MDM 服务器所涉及的步骤

  1. 发送注册配置
  2. 执行 SCEP
  3. 发送 MDM 服务器证书。
  4. 创建 APNS 证书。
  5. 向设备发送推送通知。

设备收到推送通知并联系 MDM 服务器的“serverUrl”。它以如下所示的 Status = "Idle" 响应

<?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>Status</key>
    <string>Idle</string>
    <key>UDID</key>
    <string><udid-of-device></string>
</dict>
</plist>

响应此命令以获取设备信息,发送如下。

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <dict>
        <key>Command</key>
        <dict>
            <key>RequestType</key>
            <string>DeviceInformation</string>
            <key>Queries</key>
            <array>
                <string>UDID</string>
                <string>DeviceName</string>
                <string>OSVersion</string>
                <string>ModelName</string>
                <string>IMEI</string>
            </array>
        </dict>
        <key>CommandUUID</key>
        <string>command-for-the-session</string>
    </dict>
</plist>

设备响应如下所示的设备信息

<?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>CommandUUID</key>
    <string>command-for-the-session</string>
    <key>QueryResponses</key>
    <dict>
        <key>DeviceName</key>
        <string>iPhone</string>
        <key>IMEI</key>
        <string>01 353150 432467 8</string>
        <key>ModelName</key>
        <string>iPhone</string>
        <key>OSVersion</key>
        <string>7.1</string>
        <key>UDID</key>
        <string><udid-device></string>
    </dict>
    <key>Status</key>
    <string>Acknowledged</string>
    <key>UDID</key>
    <string><udid-device></string>
</dict>
</plist>

此流程按要求工作。 在此之后,我想结束与设备的连接,因为没有更多内容要发送到设备。

我的问题是在我们从设备收到该 CommandUUID 的有效详细信息后如何停止或关闭此连接。 它一直在调用 mdm 服务器 url,并且没有结束连接。

我尝试发送一个空的 plist 来停止连接,但没有成功。

请帮忙。

感谢阅读!

【问题讨论】:

    标签: java ios iphone mdm javapns


    【解决方案1】:

    设备将通过发送以下内容不断向您的服务器查询新命令:

    <?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>Status</key>
        <string>Idle</string>
        <key>UDID</key>
        <string><udid-of-device></string>
    </dict>
    </plist>
    

    在这种情况下,如果您没有任何命令,则应返回带有空正文的 HTTP 200。这会向设备发出信号,它应该停止轮询,直到您发送下一个推送通知。

    【讨论】:

    • 感谢您的回复。你所有的cmets都帮了我很多。我很困惑并发送了一个空的plist。相反,我们需要发送空的响应正文。如果一切顺利,响应状态在 java 中默认为 200。
    • @Samreen 我正在尝试在 PHP 中构建 MDM。你有任何自己的文件。我已阅读 mdm 协议 pdf 和其他几篇文章。但是我仍然无法弄清楚。请帮帮我。
    • 您好,sau,由于公司政策,不允许共享文档。相信我,Apple 已经提供了足够的文档,我已经通过 stackoverflow 解决了一些问题。你可以参考我所有关于这个实现的帖子。另外请让我知道你卡在哪里了??
    【解决方案2】:

    这就是我在 java 中所做的发送和清空响应。

    如果一切顺利,响应状态默认为 200。

    发送空响应的代码:

    response.setStatus(200); // set status explicitly in case device polls to the mdm server
    OutputStream outStream = response.getOutputStream();
    outStream.write(new byte[0]);
    outStream.close();
    

    服务器日志如下:

    iPhone mdmd[302] <Notice>: (Note ) MDM: mdmd starting...
     iPhone mdmd[302] <Notice>: (Note ) MDM: Looking for managed app states to clean up
     iPhone profiled[303] <Notice>: (Note ) profiled: Service starting...
     iPhone mdmd[302] <Notice>: (Note ) MDM: Network reachability has changed.
     iPhone mdmd[302] <Notice>: (Note ) MDM: Network reachability has changed.
     iPhone mdmd[302] <Notice>: (Note ) MDM: Push token received.
    iPhone mdmd[302] <Notice>: (Note ) MDM: Push token received.
    iPhone mdmd[302] <Notice>: (Note ) MDM: Received push notification.
    iPhone mdmd[302] <Notice>: (Note ) MDM: Polling MDM server https://myserver-url:port/server for next command.
     iPhone mdmd[302] <Notice>: (Note ) MDM: Transaction completed. Status: 200
     iPhone mdmd[302] <Notice>: (Note ) MDM: Attempting to perform MDM request: DeviceInformation
    iPhone mdmd[302] <Notice>: (Note ) MDM: Command Status: Acknowledged
    iPhone mdmd[302] <Notice>: (Note ) MDM: Polling MDM server https://myserver-url:port/server for next command.
    iPhone profiled[303] <Notice>: (Note ) profiled: Service stopping.
    iPhone mdmd[302] <Notice>: (Note ) MDM: Transaction completed. Status: 200
     iPhone mdmd[302] <Notice>: (Note ) MDM: Server has no commands for this device.
    iPhone mdmd[302] <Notice>: (Note ) MDM: mdmd stopping.
    

    【讨论】:

    • 嗨@Samreen,我们得到如下日志,Polling MDM server https://port/api/serverapi?request= for next command. Handling request type: DeviceLock. Command Status: Acknowledged. Transaction completed. Status: 200, ResponseUUID: (Idle). Could not parse command. Error: (null). 即使在发回 200 之后你也可以看到,我们收到错误 Could not parse command. Error: (null) 然后再次轮询继续进行,我们确定我们发送200 响应停止轮询 return this.Request.CreateResponse(200); 与空正文。你能帮我们解决我们做错了什么吗?
    猜你喜欢
    • 2013-11-10
    • 2017-04-25
    • 2019-02-04
    • 1970-01-01
    • 1970-01-01
    • 2022-01-18
    • 2018-12-12
    • 2023-04-10
    • 2020-04-01
    相关资源
    最近更新 更多