javax.net.ssl.SSLException:由对等方关闭的连接(在 VOLLEY ANDROID < 4.4 上)



我有一个与Web服务器通信以检索某些数据的应用程序,该应用程序始终工作正常,但是现在显示此错误:

javax.net.ssl.sslexception:连接由peer

关闭

这仅在我使用Android&lt;4.4如果是6.0>它正常工作

 public void volleyJsonObjectRequest(String url){
    String  REQUEST_TAG = "com.androidtutorialpoint.volleyJsonObjectRequest";
    pDialog = new ProgressDialog(LoginActivity.this);
    pDialog.setMessage("Efetuando login..");
    pDialog.setIndeterminate(false);
    pDialog.setCancelable(false);
    pDialog.show();
    StringRequest postRequest = new StringRequest(Request.Method.POST, url,
            new Response.Listener<String>() {
                @Override
                public void onResponse(String response) {
                    try {
                        json      = new JSONObject(response);
                        userId    = json.getString("userid");
                        userType  = json.getString("usertype");
                        dbversion = json.getInt("dbversion");
                        success   = json.getInt(TAG_SUCCESS);
                        message   = json.getString(TAG_MESSAGE);
                        if (pDialog != null && pDialog.isShowing()) {
                            pDialog.dismiss();
                        }
                        enviadoComSucesso();

                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                }
            },
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    error.printStackTrace();
                    if (pDialog != null && pDialog.isShowing()) {
                        pDialog.dismiss();
                    }
                    userMsg("Não foi possível fazer conexão, por favor tenta novamente.");
                }
            }
    ) {
        @Override
        protected Map<String, String> getParams()
        {
            String usuario  = LoginActivity.this.userTemp;
            String password = LoginActivity.this.passTemp;
            Map<String, String> param = new HashMap<>();
            //ENVIO DOS DADOS DE AVALIAÇÕES
            param.put("usuario", usuario);
            param.put("password", password);

            return param;
        }
    };
    // Adding JsonObject request to request queue
    AppSingleton.getInstance(getApplicationContext()).addToRequestQueue(postRequest,REQUEST_TAG);
    postRequest.setRetryPolicy(new DefaultRetryPolicy(
            2000,
            DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
            DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
}

为什么现在显示此错误?我所有的应用程序现在都有此错误。当我看到此错误时,我搜索并通过粘性

找到了该解决方案

问题是由于TLSV1在后端被禁用。根据情况,可以有两种解决这个问题的方法。 1.在后端服务器上启用TLSV1。 2.如建议,更新SSLENGINE以支持移动应用程序上的更高TLS版本。

,但是我面对迪福特,因为不是凌空抽射,我必须做什么?

我几个月前已经面对这个问题,解决方案是从后端启用TLSV1协议

检查此

SSL protocols supported by devices lower than 4.4 "TLSv1" and "SSLv3"
SSL protocols supported by devices higher than 4.4 "TLSv1", "TLSv1.1" and "TLSv1.2"

您的排球代码没有问题

最新更新