将 iPhone/iPad 与 Mac 连接(Apple 方式)
当Apple的远程应用程序尝试连接到本地网络(使用WiFi)上的Mac(运行iTunes)时,用户需要输入iPhone提供的密码作为安全措施。这种方法已被许多其他应用程序采用(例如,Rowmote、Pastebot...)。有没有API可以提供这种工作方式?
假设 Bonjour 正在运行,iPhone 如何检查 Mac 上输入的密码是否正确,而不解析 Mac 发布的 NSNetService?或者,iPhone 是否解析 Mac 正在发布的 NSNetService,并等待密码得到确认,然后再处理可能通过 NSNetService 发送的任何其他数据包(密码以外的数据包)。
我的问题有一个解决方案,但我想知道是否有一个我忽略的 API 提供了现成的解决方案。
欢迎建议和指点。
提前致谢,
巴特
When Apple's Remote app tries to connect to a Mac (running iTunes) on a local network (using WiFi), the user needs to enter a passcode provided by the iPhone as a security measure. This approach has been adopted by a number of other apps (e.g., Rowmote, Pastebot, ...). Is there an API that provides this way of working?
Assuming Bonjour is in play, how does an iPhone checks if the passcode entered on a Mac is correct without resolving the NSNetService the Mac is publishing? Or does the iPhone resolve the NSNetService a Mac is publishing and waits for the passcode to be confirmed before processing any other packets that might be sent via the NSNetService (packets other than the passcode).
I have a solution for my problem, but I would like to know if there's an API I have overlooked that provides a ready-made solution.
Advice and pointers are welcome.
Thanks in advance,
Bart
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不相信苹果为此提供了 API。我只是使用 Bonjour API 打开两个设备之间的连接,然后让一个设备随机创建一个 4 位数的密码并向另一台设备询问该密码。另一个设备会显示一个 UI 来询问用户密码,然后将其传回并等待答案。如果匹配,设备会存储彼此的标识符,以便在下次连接时跳过此过程。
编辑:感谢 tc 指出此实现并不完全安全。我现在让一台设备创建一个唯一的随机密码,并将其发送到另一台设备,然后存储该密码的 SHA1 哈希值以供将来参考。然后,另一台设备存储密码,并在连接时将其发回以进行身份验证。用户执行一次数字代码操作,以便让设备知道它们将来应该相互信任,但现在为了让逆向工程师连接到设备,他们必须知道设备的标识符和密码有效的已连接设备。 (或者他们必须有权访问这两个设备并执行数字代码操作;显然,没有真正的方法可以阻止任何人这样做)。
I don't believe there is an Apple provided API for this. I simply use the Bonjour APIs to open a connection between two devices, then have one randomly create a 4 digit passcode and ask the other device for it. The other device presents a UI to ask the user for the passcode, then transmits it back and waits for an answer. If they match, the devices store each other's identifiers to skip over this process the next time they connect.
Edit: Thanks to tc for pointing out that this implementation isn't totally secure. I'm now having one device create a unique, random password, and send it over to the other device, then store the SHA1 hash of the password for future reference. Then the other device stores the password and sends it back over whenever it connects for authentication. The user does the number code thing once in order to let the devices know that they should trust each other in the future, but now in order for a reverse engineer to connect to a device they would have to know both the identifier of and password for a valid, connected device. (Or they'd have to have access to both devices and do the number code thing; there isn't really a way to stop anyone from doing that, obviously).