我们已经跟踪了Scottyab Safetynet Library
我们面临着“status{statuscode=network\u error,resolution=null}”事件的错误,尽管我们的android设备中有4g互联网连接,包名为com.safetynet.sample,其中as sample project在包名为com.scottyab.safetynet.sample的情况下运行良好。我们有支票但没有工作。
下面是我们面对这个问题的代码

private void runSafetyNetTest() {
    Log.v(TAG, "running SafetyNet.API Test");
    requestNonce = generateOneTimeRequestNonce();
    requestTimestamp = System.currentTimeMillis();
    writeLog("running SafetyNet.API Test");
    SafetyNet.SafetyNetApi.attest(googleApiClient, requestNonce)
            .setResultCallback(new ResultCallback<SafetyNetApi.AttestationResult>() {
                                   @Override
                                   public void onResult(final SafetyNetApi.AttestationResult result) {
                                       writeLog("running SafetyNet.API Result");
                                   //result = Status{statusCode=NETWORK_ERROR, resolution=null}
                                       if (!validateResultStatus(result)) {
                                           return;
                                       }

                                       final String jwsResult = result.getJwsResult();
                                       final SafetyNetResponse response = parseJsonWebSignature(jwsResult);
                                       lastResponse = response;
                                       writeLog("Res :: " + response);

                                       //validate payload of the response
                                       if (validateSafetyNetResponsePayload(response)) {
                                           if (!TextUtils.isEmpty(googleDeviceVerificationApiKey)) {
                                               //if the api key is set, run the AndroidDeviceVerifier
                                               AndroidDeviceVerifier androidDeviceVerifier = new AndroidDeviceVerifier(googleDeviceVerificationApiKey, jwsResult);
                                               androidDeviceVerifier.verify(new AndroidDeviceVerifier.AndroidDeviceVerifierCallback() {
                                                   @Override
                                                   public void error(String errorMsg) {
                                                       callback.error(RESPONSE_ERROR_VALIDATING_SIGNATURE, "Response signature validation error: " + errorMsg);
                                                   }

                                                   @Override
                                                   public void success(boolean isValidSignature) {
                                                       if (isValidSignature) {
                                                           callback.success(response.isCtsProfileMatch(), response.isBasicIntegrity());
                                                       } else {
                                                           callback.error(RESPONSE_FAILED_SIGNATURE_VALIDATION, "Response signature invalid");

                                                       }
                                                   }
                                               });
                                           } else {
                                               Log.w(TAG, "No google Device Verification ApiKey defined");
                                               callback.error(RESPONSE_FAILED_SIGNATURE_VALIDATION_NO_API_KEY, "No Google Device Verification ApiKey defined. Marking as failed. SafetyNet CtsProfileMatch: " + response.isCtsProfileMatch());
                                           }
                                       } else {
                                           callback.error(RESPONSE_VALIDATION_FAILED, "Response payload validation failed");
                                       }
                                   }
                               }

            );
}

最佳答案

这可能与认证api已标记为不推荐使用有关。新的不依赖于google client api,您应该检查this。google还发布了一个使用新api的示例应用程序,您可以检查here

07-27 16:54