【发布时间】:2019-05-28 10:31:24
【问题描述】:
我正在创建一个支付 android 库 (aar),我必须确保我在 back-end 中收到的所有请求都来自我的库而不是假库。
我该怎么做?
【问题讨论】:
标签: android security android-security rest-security
我正在创建一个支付 android 库 (aar),我必须确保我在 back-end 中收到的所有请求都来自我的库而不是假库。
我该怎么做?
【问题讨论】:
标签: android security android-security rest-security
我之前用过两种方式:
1- 简单而坏的方法:尝试在您的应用程序中使用像 JWT 这样的硬编码字符串,并使用强大的混淆器来避免反编译应用程序。
2- 更好的方法:您可以使用instance id 并将其发送到您的后端,服务器可以从 Google 查询此 id,并且在响应中有一些元素,如 package id,服务器可以使用它来接受或拒绝要求。
来自 Google 的示例响应:
{
"application":"com.iid.example",
"authorizedEntity":"123456782354",
"platform":"Android",
"attestStatus":"ROOTED",
"appSigner":"1a2bc3d4e5",
"connectionType":"WIFI",
"connectDate":"2015-05-12
}
}
参考:https://developers.google.com/instance-id/reference/server
【讨论】:
MY_API_KEY?如果找到,假库可以生成有效的instance id,我的back-end 将接受请求