如何验证来自 iOS 应用程序的 http 请求?
我有一个通过 https 与服务器通信的 iOS 应用程序。
是否可以对应用程序进行身份验证,以便服务器仅响应来自该应用程序的请求?换句话说,它不会响应来自浏览器/curl/另一个应用程序/等的http请求?
我对验证用户身份不感兴趣 - 只是确保只有我的应用程序可以与服务器通信。
我考虑过:
- 服务器和应用程序上的共享秘密。但任何人都可以查看应用程序包内部来提取秘密。
- 使用推送通知。应用程序联系服务器,并告诉服务器其推送通知令牌。服务器发送推送通知到达应用程序。其他任何东西都无法接收通知,因此在其中嵌入一个共享密钥,应用程序从此可以使用该密钥。但推送通知可能会延迟发送,或者根本不发送。许多用户不想启用它们。
显然,苹果会对设备进行身份验证,因此它知道向何处发送推送通知。但是有什么办法可以连接到这个吗?
I have an iOS app that communicates over https with a server.
Is it possible to authenticate the app, so that the server will only respond to requests from that app? In other words, it won't respond to http requests from a browser/curl/another app/etc?
I'm not interested in authenticating the user- just being sure that only my app can communicate with the server.
What I've considered:
-Shared secret on server and app. But anyone can look inside the app bundle to extract the secret.
-Using push notifications. App contacts server, and tells server its push notification token. Server sends a push notification which reaches app. Nothing else can receive the notification, so embed a shared secret in it, which the app can use from then on. But push notifications can be delivered late, or not at all. And many users don't want to enable them.
Obviously Apple authenticates devices so it knows where to send push notifications. But is there any way of hooking into this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否考虑过使用您的 ios 设备的 MAC 地址?我在一个应用程序中使用它,该应用程序登录需要将设备识别为终端的服务器,并使用它为该终端创建会话。
Have you thought about using MAC address of your ios device? I use this in an app that logs on a server that needs to identify a device as a terminal and uses that to create a session for that terminal.