【问题标题】:javax.net.ssl.SSLException: Connection closed by peer ( ON VOLLEY ANDROID < 4.4 )javax.net.ssl.SSLException:连接被对等方关闭(ON VOLLEY ANDROID < 4.4)
【发布时间】:2018-07-31 10:05:39
【问题描述】:

我有一个与 Web 服务器通信以检索一些数据的应用程序,该应用程序始终运行良好,但现在显示此错误:

javax.net.ssl.SSLException:连接被对等方关闭

这只发生在我使用 android 它工作正常

 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));
}

为什么现在出现这个错误?我所有的应用程序现在都有这个错误。当我看到这个错误时,我通过 Sticky 搜索并找到了这个解决方案

问题是由于后端禁用了 TLSv1。 根据具体情况,可以有两种方法来解决这个问题。 1. 在后端服务器上启用 TLSv1。 2. 按照建议,更新 SSLEngine 以在移动应用上支持更高的 TLS 版本。

但我面临困难,因为不是 VOLLEY APROACH,我必须做什么?

【问题讨论】:

    标签: android server android-volley backend sslexception


    【解决方案1】:

    几个月前我遇到过这个问题,解决方案是从后端启用 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"
    

    您的 Volley 代码没有问题

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-08-21
      • 2017-09-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-08-21
      • 2016-08-28
      • 1970-01-01
      相关资源
      最近更新 更多