我想实现安全网 API 来验证设备状态我发现的最简单的方法之一是安全网帮助器类,它使实现变得如此简单 github.com/scottyab/safetynethelper。我从 securitynetlib 复制了所有类并将它们添加到我的代码中。我按照植入的方法,但我得到一个错误代码
final SafetyNetHelper safetyNetHelper = new SafetyNetHelper(BuildConfig.API1);
public boolean safetynet()
{
safetyNetHelper.requestTest(getApplicationContext(), new SafetyNetHelper.SafetyNetWrapperCallback() {
@Override
public void error(int errorCode, String msg) {
//handle and retry depending on errorCode
}
@Override
public void success(boolean ctsProfileMatch) {
if(ctsProfileMatch){
safetynet=true;
}else{
safetynet=false;
}
}
});
return safetynet;
}`
04-20 22:32:50.950 28741-28741/com.aashish.smart D/SafetyNetHelper:apkDigest:IQUb5ULuwdbqOwpQn3jZev2EGXcjtk/yGYUvk1c64F8= 04-20 22:32:51.028 28741-28741/tyNetSafety.com连接的服务 04-20 22:32:51.028 28741-28741/com.aashish.smart V/SafetyNetHelper:运行 SafetyNet.API 测试 04-20 22:32:54.499 28741-28741/com.aashish.smart D/SafetyNetResponse: decodedJWTPayload json:{"nonce":"tnd1YpjORIX4teJEd7LuigDWNhWkF6s4T7Ay811BxsM=","timestampMs":1461171774655,"apkPackageName":"com.aashish.smart","apkDigestSha256":"IQUb5ULuwdbqOwpQn3jZev2EGXcjtk/yGYUvk1c64F8=","ctsProfileMatch":true,"extension" :"CQ6MIM+qMkMv","apkCertificateDigestSha256":["PHKalK4AF5EmDbPL5eBQS9EZJVPkgp06cr64rVQ7B7w="]} 04-20 22:32:54.500 28741-28741/com.aashish.smart E/SafetyNetHelper:无效的 apkCertificateDigest,本地/预期 =[MIIDizCCAnOgAwIBAgIEPIOxdDANBgkqhkiG9w0BAQsFADB2MQswCQYDVQQGEwJJTjETMBEGA1UECBMKVGFtaWwgTmFkdTEQMA4GA1UEBxMHQ2hlbm5haTEOMAwGA1UEChMFU21hcnQxEzARBgNVBAsTClRlY2hpbmljYWwxGzAZBgNVBAMTEkFhc2hpc2ggVml2ZWthbmFuZD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invalid apkCertificateDigest, response = [PHKalK4AF5EmDbPL5eBQS9EZJVPkgp06cr64rVQ7B7w=] 04-20 22:32:54.657 28741-4205/com.aashish.smart E/AndroidDeviceVerifier:验证 JWS 消息时出现问题:IG6eWNkmNZYXuEj14nqWrSM+AniDcW3U/NwROXOERZfvtBiiwuy0Oc8GG31VmYAd6jgdkfsXfd+96wZxqH8PRtq3m1tjXYGb9Kg1CM1oDdN5H6xtqjU24nSpQEWWs6THuWHA1LEsAnnO0JM3lm0ltBOuIGJtWBd5S6tHMgi4U+m1z/oJAW0HAyWwbuwy7/YP1uEKlEEM669bUYG6iQ4dE3cIB5guZF2qMjwPKscW9bRjoviTgJUGmmVRdpd1Dk/OOZFUEK4A+ii5c7SLW2e//QoN3WV30zNHJArCvFfTGRbeZpwOl4Z4=] 04-20 22:32:54.500 28741-28741/com.aashish.smart E/SafetyNetHelper: invalid apkCertificateDigest, response = [PHKalK4AF5EmDbPL5eBQS9EZJVPkgp06cr64rVQ7B7w =] 04-20 22:32:54.657 28741-4205/com.aashish.smart E/AndroidDeviceVerifier:验证 JWS 消息时出现问题:IG6eWNkmNZYXuEj14nqWrSM+AniDcW3U/NwROXOERZfvtBiiwuy0Oc8GG31VmYAd6jgdkfsXfd+96wZxqH8PRtq3m1tjXYGb9Kg1CM1oDdN5H6xtqjU24nSpQEWWs6THuWHA1LEsAnnO0JM3lm0ltBOuIGJtWBd5S6tHMgi4U+m1z/oJAW0HAyWwbuwy7/YP1uEKlEEM669bUYG6iQ4dE3cIB5guZF2qMjwPKscW9bRjoviTgJUGmmVRdpd1Dk/OOZFUEK4A+ii5c7SLW2e//QoN3WV30zNHJArCvFfTGRbeZpwOl4Z4=] 04-20 22:32:54.500 28741-28741/com.aashish.smart E/SafetyNetHelper: invalid apkCertificateDigest, response = [PHKalK4AF5EmDbPL5eBQS9EZJVPkgp06cr64rVQ7B7w =] 04-20 22:32:54.657 28741-4205/com.aashish.smart E/AndroidDeviceVerifier:验证 JWS 消息时出现问题:响应 = [PHKalK4AF5EmDbPL5eBQS9EZJVPkgp06cr64rVQ7B7w=] 04-20 22:32:54.657 28741-4205/com.aashish.smart E/AndroidDeviceVerifier:验证 JWS 消息时出现问题:响应 = [PHKalK4AF5EmDbPL5eBQS9EZJVPkgp06cr64rVQ7B7w=] 04-20 22:32:54.657 28741-4205/com.aashish.smart E/AndroidDeviceVerifier:验证 JWS 消息时出现问题:https://www.googleapis.com/androidcheck/v1/attestations/verify?key=A.......................... .......0 java.io.FileNotFoundException: https://www.googleapis.com/androidcheck/v1/attestations/verify?key=A...... ......................0 在 com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:238) 在 com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getInputStream(DelegatingHttpsURLConnection.java:210) 在 com.android.okhttp.internal .huc.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java) 在 com.aashish.smart.AndroidDeviceVerifier$AndroidDeviceVerifierTask.doInBackground(AndroidDeviceVerifier.java:113) 在 com.aashish.smart。AndroidDeviceVerifier$AndroidDeviceVerifierTask.doInBackground(AndroidDeviceVerifier.java:82) 在 android.os.AsyncTask$2.call(AsyncTask.java:295) 在 java.util.concurrent.FutureTask.run(FutureTask.java:237) 在 android.os。 AsyncTask$SerialExecutor$1.run(AsyncTask.java:234) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:第588章)
完整日志:pastebin(dot)com/YXkS7NgW
有人可以帮我找出我无法找到的错误。或者是否有任何其他教程可供我使用安全网 API