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

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

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

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

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

public void login() {
        final ProgressDialog progressDialog = new ProgressDialog(LoginActivity.this, R.style.Custom_Progress_Dialog);
        progressDialog.setIndeterminate(true);
        progressDialog.setMessage("Authenticating...");
        progressDialog.show();
        Log.d(TAG, "loginURL: "+loginURL);
        RequestQueue queue = Volley.newRequestQueue(this);
        StringRequest postRequest = new StringRequest(Request.Method.POST, loginURL,
                new com.android.volley.Response.Listener<String>() {
                    @Override
                    public void onResponse(String response) {
                        // response
                        Log.d(TAG, "Response: " + response);
                        try {
                            JSONObject jsonObject = new JSONObject(response);
                            status = jsonObject.getString("status");
                            //phone = jsonObject.getString("phone");
                            if(status.equals("success")) {
                                Intent main = new Intent(LoginActivity.this, MessagesActivity.class);
                                editor.putBoolean("is_logged_in", true);
                                editor.putString("username", input_username.getText().toString());
                                editor.commit();
                                startActivity(main);
                                finish();
                            }
                            else if(status.equals("incorrect")) {
                                ToastMaker.createLongToast(LoginActivity.this, "Incorrect Username or Password");
                                progressDialog.dismiss();
                            }
                            else if(status.equals("not verified")) {
                                ToastMaker.createLongToast(LoginActivity.this, "Please verify your account in the email we sent");
                                progressDialog.dismiss();
                            }
                            else {//Toast.makeText(getApplicationContext(), "There was a problem", Toast.LENGTH_LONG).show();
                                ToastMaker.createLongToast(LoginActivity.this, "There was a problem...");
                                progressDialog.dismiss();
                            }

                        } catch(JSONException e) {
                            Log.d(TAG, "JSONException: "+e.getMessage());
                            ToastMaker.createLongToast(LoginActivity.this, "JSONException: "+e.getMessage());
                        }
                    }
                },
                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
                        // error
                        Log.d(TAG, error.getMessage());
                        progressDialog.dismiss();
                    }
                }
        ) {
            @Override
            protected Map<String, String> getParams() {
                Map<String, String> params = new HashMap<>();
                params.put("username", input_username.getText().toString());
                params.put("password", input_password.getText().toString());
                return params;
            }
        };
        queue.add(postRequest);
    }

暂无答案!

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

相关问题