Android https握手终止异常

时间:2016-05-29 21:14:48

标签: java android ssl https handshake

我在尝试发出https请求时会随机获取此异常,有时它会起作用,有时无法与此异常进行握手。 而我正在尝试使用棒棒糖和棉花糖。

javax.net.ssl.SSLProtocolException: 
SSL handshake terminated: ssl=0x9d397c00: Failure in SSL library,  usually a protocol error
error:100c543e:SSL routines:ssl3_read_bytes:TLSV1_ALERT_INAPPROPRIATE_FALLBACK (external/boringssl/src/ssl/s3_pkt.c:972 0x9b0bb3e0:0x00000001)

以下是我发出请求的方式

URL url;
HttpURLConnection connection;
try {
    String serverUrl = "...";
    url = new URL(serverUrl);

    connection = (HttpURLConnection) url.openConnection();

    BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));

    int responseCode = connection.getResponseCode();
    if (responseCode == HttpURLConnection.HTTP_OK) {
        Log.i(TAG, "OK");
        Log.i(TAG, "response " + in.readLine());
    } else {
        Log.e(TAG, "Error " + responseCode);
    }

    in.close();
} catch (Exception e) {
    e.printStackTrace();
}

0 个答案:

没有答案