duangan6797 2013-12-03 20:00
浏览 19
已采纳

小型API安全性最佳实践

I am in a situation where I make an iPhone app and a RESTful API (via a php script) to communicate with individual clients warehouse databases.

Currently I manually setup individual web servers with a self signed certificate. Create a user with a special long random password (it is hard coded into the app). Setup their web server so that my php script requires Basic Authentication and only grants access to the specific user.

On my app's side the username/password is hard coded and it ignores the fact that the server has a self signed certificate.

Is there anything wrong with this model?

  • 写回答

1条回答 默认 最新

  • douliang1369 2013-12-03 20:29
    关注

    Anyone could easily capture the username/password by pointing the app to their own server with Basic Authentication setup and a self-signed certificate.

    To prevent this, you could also verify that the certificate signature (or public key) and the common name matches the self-signed certificate that you created (again, hard coded). This is known as certificate pinning.

    Still, this assumes that the username and password are at least difficult to obtain by disassembling the code, and of course understanding that a hard coded username and password can always be stolen by a determined cracker who can read your disassembled code.

    With the username and password, they can access your API on their own terms, of course, while someone else pays for the account.

    Rather than hard code values into the app, can you have the app go through some setup process where the user enters credentials the first time? Even with this, an individual user's credentials may be stolen from their device, but at least it's a single user, and you can block access and setup a new account. This is the standard scenario.

    Also, it may be feasible to release this to your customer using something like TestFlight (you can even roll your own) rather than through the AppStore. This will help limit the cases where individually built apps get into the wild, not to mention helping reduce the clutter in the app store.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教