Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
javax.net.ssl.sslhandshake异常:javax.net.ssl.SSLProtocolException:ssl握手中止:_Java_Android_Ssl_Android Volley - Fatal编程技术网

javax.net.ssl.sslhandshake异常:javax.net.ssl.SSLProtocolException:ssl握手中止:

javax.net.ssl.sslhandshake异常:javax.net.ssl.SSLProtocolException:ssl握手中止:,java,android,ssl,android-volley,Java,Android,Ssl,Android Volley,我在尝试在android lollipop以下的设备上运行时遇到以下错误,对于lollipop以上的版本,它运行得非常好 javax.net.ssl.SSLHandshakeException: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0x943e670: Failure in SSL library, usually a protocol error error:14077410:SSL routin

我在尝试在android lollipop以下的设备上运行时遇到以下错误,对于lollipop以上的版本,它运行得非常好

javax.net.ssl.SSLHandshakeException: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0x943e670: Failure in SSL library, usually a protocol error
    error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure (external/openssl/ssl/s23_clnt.c:658 0xb750d3a1:0x00000000)
这是我注册用户的方法:

        String tag_string_req = "register";
            StringRequest strReq = new StringRequest(Request.Method.POST,
                    AppConfig.URL_REGISTER, new Response.Listener<String>() {

                @Override
                public void onResponse(String response) {
                    Log.d(TAG, "Register Response: " + response.toString());
                    hideDialog();

                    try {
                        JSONObject jObj = new JSONObject(response);
                        boolean error = jObj.getBoolean("error");
                        if (!error) {

                            String id = jObj.getString("id");
                            finish();
                        } else {
                            String errorMsg = jObj.getString("error_msg");
                            Toast.makeText(getApplicationContext(),
                                    errorMsg, Toast.LENGTH_LONG).show();
                        }
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                }
            }, new Response.ErrorListener() {

                @Override
                public void onErrorResponse(VolleyError error) {
                    Log.e(TAG, "Registration Error: " + error.getMessage());
                    Toast.makeText(getApplicationContext(),
                            error.getMessage(), Toast.LENGTH_LONG).show();
                    hideDialog();
                }
            }) {

                @Override
                protected Map<String, String> getParams() {
                    Map<String, String> params = new HashMap<String, String>();
                    params.put("user_name", txtSEditName.getText().toString().trim());
                    params.put("password", txtSEditPhone.getText().toString().trim());

                    return params;
                }

            };
            AppController.getInstance().addToRequestQueue(strReq, tag_string_req);
有人能帮我解决这个问题吗

错误:javax.net.ssl.SSLHandshakeException: javax.net.ssl.SSLProtocolException:ssl握手中止:


我试着找出错误,这对我来说很有效。我所了解的是,对于低于棒棒糖的设备,默认情况下不启用协议TLSv1.1和TLSv1.2。为了使它们适用于使用jellybean或kitkat的设备,我们必须使用SSLSocketFactory

现在我对Volley singleton的getRequestQueue()方法做了以下更改:

public RequestQueue getRequestQueue() {


    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN
            && Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
        Log.d("msg", "HI, I m a kitkat phone");
        try {
            ProviderInstaller.installIfNeeded(getApplicationContext());
        } catch (GooglePlayServicesRepairableException e) {
            // Indicates that Google Play services is out of date, disabled, etc.
            // Prompt the user to install/update/enable Google Play services.
            GooglePlayServicesUtil.showErrorNotification(e.getConnectionStatusCode(), getApplicationContext());
            e.printStackTrace();

        } catch (GooglePlayServicesNotAvailableException e) {
            // Indicates a non-recoverable error; the ProviderInstaller is not able
            // to install an up-to-date Provider.

            e.printStackTrace();
        }

        HttpStack stack = null;
        try {
            stack = new HurlStack(null, new TLSSocketFactory());
        } catch (KeyManagementException e) {
            e.printStackTrace();
            Log.d("Your Wrapper Class", "Could not create new stack for TLS v1.2");
            stack = new HurlStack();
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
            Log.d("Your Wrapper Class", "Could not create new stack for TLS v1.2");
            stack = new HurlStack();
        }
        mRequestQueue = Volley.newRequestQueue(getApplicationContext(), stack);
    } else {
        mRequestQueue = Volley.newRequestQueue(getApplicationContext());
    }
    return mRequestQueue;
}
}

另一个步骤是在gradle文件的依赖项中添加以下实现:

implementation 'com.google.android.gms:play-services-base:11.0.0'

我希望这能帮助你解决这个问题

我试图找出错误,这对我很有效。我所了解的是,对于低于棒棒糖的设备,默认情况下不启用协议TLSv1.1和TLSv1.2。为了使它们适用于使用jellybean或kitkat的设备,我们必须使用SSLSocketFactory

现在我对Volley singleton的getRequestQueue()方法做了以下更改:

public RequestQueue getRequestQueue() {


    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN
            && Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
        Log.d("msg", "HI, I m a kitkat phone");
        try {
            ProviderInstaller.installIfNeeded(getApplicationContext());
        } catch (GooglePlayServicesRepairableException e) {
            // Indicates that Google Play services is out of date, disabled, etc.
            // Prompt the user to install/update/enable Google Play services.
            GooglePlayServicesUtil.showErrorNotification(e.getConnectionStatusCode(), getApplicationContext());
            e.printStackTrace();

        } catch (GooglePlayServicesNotAvailableException e) {
            // Indicates a non-recoverable error; the ProviderInstaller is not able
            // to install an up-to-date Provider.

            e.printStackTrace();
        }

        HttpStack stack = null;
        try {
            stack = new HurlStack(null, new TLSSocketFactory());
        } catch (KeyManagementException e) {
            e.printStackTrace();
            Log.d("Your Wrapper Class", "Could not create new stack for TLS v1.2");
            stack = new HurlStack();
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
            Log.d("Your Wrapper Class", "Could not create new stack for TLS v1.2");
            stack = new HurlStack();
        }
        mRequestQueue = Volley.newRequestQueue(getApplicationContext(), stack);
    } else {
        mRequestQueue = Volley.newRequestQueue(getApplicationContext());
    }
    return mRequestQueue;
}
}

另一个步骤是在gradle文件的依赖项中添加以下实现:

implementation 'com.google.android.gms:play-services-base:11.0.0'

我希望这能帮助你解决这个问题

也许我能帮助某人。 在我的例子中,问题来自Web服务器。我尝试更改Web服务器,并使用Github作为测试,一切都很顺利。
因此,我的建议是首先检查并确认SSLxxx所需的网站支持。

可能我可以帮助某人。 在我的例子中,问题来自Web服务器。我尝试更改Web服务器,并使用Github作为测试,一切都很顺利。 因此,我的建议是首先检查并确认SSLxxx所需的网站支持

implementation 'com.google.android.gms:play-services-base:11.0.0'