android截击错误“找不到认证路径的信任锚”仅在真实设备上,并且在家庭wifi上

pes8fvy9  于 2021-06-30  发布在  Java
关注(0)|答案(0)|浏览(138)

更新:没有骰子。我的配置一切正常。我不是不小心被挡了。当我连接到wifi时,它根本不工作,但在模拟器和不使用wifi的物理设备上工作。
再次编辑:所以,我发现这种情况只发生在我使用wifi的时候。我将手机从wifi上取下,https请求成功。我将检查我的apache/iptables配置,确保我没有弄错什么(我最近确实弄乱了一些事情,所以这是可能的)。我会带着我的发现回来的。
编辑:应该注意的是,我的sslcertificatechainfile也安装在web服务器上(我在各种问题/博客中看到过这一点)。不管怎样,它已经工作了好几个星期了。只是突然停止了工作。
我已经测试我的应用程序好几个星期了,反复使用截取请求通过后端服务器登录。突然,我得到以下错误,尽管没有代码被更改:

  1. javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.

我已经看到了这个答案,还有很多其他的答案,但是我想知道为什么这会突然发生,在我第一次编写登录代码之后一切都很好?它在仿真器上工作,但在真实设备上不再工作。
我的登录方法:

  1. public void login() {
  2. final ProgressDialog progressDialog = new ProgressDialog(LoginActivity.this, R.style.Custom_Progress_Dialog);
  3. progressDialog.setIndeterminate(true);
  4. progressDialog.setMessage("Authenticating...");
  5. progressDialog.show();
  6. Log.d(TAG, "loginURL: "+loginURL);
  7. RequestQueue queue = Volley.newRequestQueue(this);
  8. StringRequest postRequest = new StringRequest(Request.Method.POST, loginURL,
  9. new com.android.volley.Response.Listener<String>() {
  10. @Override
  11. public void onResponse(String response) {
  12. // response
  13. Log.d(TAG, "Response: " + response);
  14. try {
  15. JSONObject jsonObject = new JSONObject(response);
  16. status = jsonObject.getString("status");
  17. //phone = jsonObject.getString("phone");
  18. if(status.equals("success")) {
  19. Intent main = new Intent(LoginActivity.this, MessagesActivity.class);
  20. editor.putBoolean("is_logged_in", true);
  21. editor.putString("username", input_username.getText().toString());
  22. editor.commit();
  23. startActivity(main);
  24. finish();
  25. }
  26. else if(status.equals("incorrect")) {
  27. ToastMaker.createLongToast(LoginActivity.this, "Incorrect Username or Password");
  28. progressDialog.dismiss();
  29. }
  30. else if(status.equals("not verified")) {
  31. ToastMaker.createLongToast(LoginActivity.this, "Please verify your account in the email we sent");
  32. progressDialog.dismiss();
  33. }
  34. else {//Toast.makeText(getApplicationContext(), "There was a problem", Toast.LENGTH_LONG).show();
  35. ToastMaker.createLongToast(LoginActivity.this, "There was a problem...");
  36. progressDialog.dismiss();
  37. }
  38. } catch(JSONException e) {
  39. Log.d(TAG, "JSONException: "+e.getMessage());
  40. ToastMaker.createLongToast(LoginActivity.this, "JSONException: "+e.getMessage());
  41. }
  42. }
  43. },
  44. new Response.ErrorListener() {
  45. @Override
  46. public void onErrorResponse(VolleyError error) {
  47. // error
  48. Log.d(TAG, error.getMessage());
  49. progressDialog.dismiss();
  50. }
  51. }
  52. ) {
  53. @Override
  54. protected Map<String, String> getParams() {
  55. Map<String, String> params = new HashMap<>();
  56. params.put("username", input_username.getText().toString());
  57. params.put("password", input_password.getText().toString());
  58. return params;
  59. }
  60. };
  61. queue.add(postRequest);
  62. }

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题